Alexa (experimental)¶
This is a connector that can export an Agent
to the Alexa format.
Warning
Alexa connector is experimental, it is published mainly to study the case and gather feedback: expect relevant rough edges. Also,
predict and trigger are not implemented (you don’t call Alexa, Alexa calls you)
Entities
Sys.Email
andSys.Url
are not available in Alexa (regex entites aren’t supported either, which makes it difficult to work around this one)Intent relations are not considered
Official Request/Response schemas: https://github.com/alexa/alexa-apis-for-python/tree/master/ask-sdk-model/ask_sdk_model
-
class
AlexaConnector
(agent_cls, invocation_name, default_session=None, default_language='en')[source]¶ This is an implementation of
Connector
that enables Agents to work as Alexa projects.Warning
This connector is experimental. Features may not be complete and behavior may change in next releases.
At the moment, all you can do is to
export()
an Agent in the Alexa format, and start the fulfillment development server withrun_dev_server()
. You will have to configure your Alexa agent from the console to hit your URL instead of its default lambda for fulfillment.- Parameters
agent_cls (
Type
[Agent
]) –invocation_name (
str
) –default_session (
Optional
[str
]) –default_language (
str
) –
-
export
(destination)[source]¶ Export Agent in the given folder:
from example_agent.agent import ExampleAgent from intents.connectors._experimental.alexa import AlexaConnector alexa = AlexaConnector(ExampleAgent, "any invocation") alexa.export("./TMP_ALEXA")
The export will generate one JSON file per language, they can be imported from the Alexa console. Destination will be overwritten if already existing.
- Parameters
destination (
str
) –
-
fulfill
(fulfillment_request)[source]¶ This method is responsible for handling requests coming from a fulfillment interface. We are at that point in the flow when an intent was triggered/predicted, and Service is calling the webhook service for fulfillment. Refer to
intents.fulfillment
for a more detailed explanation.In this method, Connector interprets the body of the request, builds a
FulfillmentContext
object, builds theIntent
object that is references in the request, and calls itsfulfill()
method.This will produce a
FulfillmentResult
object, that Connector will translate into a Service-compatible response (a dictionary) and return to caller.- Parameters
fulfillment_request (
FulfillmentRequest
) – A raw fulfillment request, as it is sent by the Prediction service (typically via a standard REST webhook call)- Return type
dict
- Returns
An object containing a response that Service can read
-
predict
(message, session=None, language=None)[source]¶ Not implemented
- Parameters
message (
str
) –session (
Optional
[str
]) –language (
Optional
[str
]) –
- Return type