Models

The SDK works on model classes rather than native Alexa JSON requests and responses. These model classes are generated using the Request, Response JSON schemas from the developer docs. The source code for the model classes can be found here.

Submodules

Note

Canonical imports have been added in the __init__.py of the package. This helps in importing the class directly from the package, than through the module.

For eg: if package a has module b with class C, you can do from a import C instead of from a.b import C.

ask_sdk_model.application module

class ask_sdk_model.application.Application(application_id=None)

Bases: object

An object containing an application ID. This is used to verify that the request was intended for your service.

Parameters:application_id ((optional) str) – A string representing the application identifier for your skill.
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.context module

class ask_sdk_model.context.Context(system=None, audio_player=None, automotive=None, display=None, geolocation=None, viewport=None)

Bases: object

Parameters:
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.device module

class ask_sdk_model.device.Device(device_id=None, supported_interfaces=None)

Bases: object

An object providing information about the device used to send the request. The device object contains both deviceId and supportedInterfaces properties. The deviceId property uniquely identifies the device. The supportedInterfaces property lists each interface that the device supports. For example, if supportedInterfaces includes AudioPlayer {}, then you know that the device supports streaming audio using the AudioPlayer interface.

Parameters:
  • device_id ((optional) str) – The deviceId property uniquely identifies the device.
  • supported_interfaces ((optional) ask_sdk_model.supported_interfaces.SupportedInterfaces) – Lists each interface that the device supports. For example, if supportedInterfaces includes AudioPlayer {}, then you know that the device supports streaming audio using the AudioPlayer interface
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.dialog_state module

class ask_sdk_model.dialog_state.DialogState

Bases: enum.Enum

Enumeration indicating the status of the multi-turn dialog. This property is included if the skill meets the requirements to use the Dialog directives. Note that COMPLETED is only possible when you use the Dialog.Delegate directive. If you use intent confirmation, dialogState is considered COMPLETED if the user denies the entire intent (for instance, by answering “no” when asked the confirmation prompt). Be sure to also check the confirmationStatus property on the Intent object before fulfilling the user’s request.

Allowed enum values: [STARTED, IN_PROGRESS, COMPLETED]

to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.directive module

class ask_sdk_model.directive.Directive(object_type=None)

Bases: object

Parameters:object_type ((optional) str) –

Note

This is an abstract class. Use the following mapping, to figure out the model class to be instantiated, that sets type variable.


CustomInterfaceController.StopEventHandler: ask_sdk_model.interfaces.custom_interface_controller.stop_event_handler_directive.StopEventHandlerDirective,





Dialog.UpdateDynamicEntities: ask_sdk_model.dialog.dynamic_entities_directive.DynamicEntitiesDirective,

CustomInterfaceController.StartEventHandler: ask_sdk_model.interfaces.custom_interface_controller.start_event_handler_directive.StartEventHandlerDirective,






Connections.StartConnection: ask_sdk_model.interfaces.connections.v1.start_connection_directive.StartConnectionDirective,


CustomInterfaceController.SendDirective: ask_sdk_model.interfaces.custom_interface_controller.send_directive_directive.SendDirectiveDirective,



Tasks.CompleteTask: ask_sdk_model.interfaces.tasks.complete_task_directive.CompleteTaskDirective,




classmethod get_real_child_model(data)

Returns the real base class specified by the discriminator

to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.intent module

class ask_sdk_model.intent.Intent(name=None, slots=None, confirmation_status=None)

Bases: object

An object that represents what the user wants.

Parameters:
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.intent_confirmation_status module

class ask_sdk_model.intent_confirmation_status.IntentConfirmationStatus

Bases: enum.Enum

Indication of whether an intent or slot has been explicitly confirmed or denied by the user, or neither.

Allowed enum values: [NONE, DENIED, CONFIRMED]

to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.intent_request module

class ask_sdk_model.intent_request.IntentRequest(request_id=None, timestamp=None, locale=None, dialog_state=None, intent=None)

Bases: ask_sdk_model.request.Request

An IntentRequest is an object that represents a request made to a skill based on what the user wants to do.

Parameters:
  • request_id ((optional) str) – Represents the unique identifier for the specific request.
  • timestamp ((optional) datetime) – Provides the date and time when Alexa sent the request as an ISO 8601 formatted string. Used to verify the request when hosting your skill as a web service.
  • locale ((optional) str) – A string indicating the user’s locale. For example: en-US. This value is only provided with certain request types.
  • dialog_state ((optional) ask_sdk_model.dialog_state.DialogState) – Enumeration indicating the status of the multi-turn dialog. This property is included if the skill meets the requirements to use the Dialog directives. Note that COMPLETED is only possible when you use the Dialog.Delegate directive. If you use intent confirmation, dialogState is considered COMPLETED if the user denies the entire intent (for instance, by answering “no” when asked the confirmation prompt). Be sure to also check the confirmationStatus property on the Intent object before fulfilling the user’s request.
  • intent ((optional) ask_sdk_model.intent.Intent) – An object that represents what the user wants.
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.launch_request module

class ask_sdk_model.launch_request.LaunchRequest(request_id=None, timestamp=None, locale=None, task=None)

Bases: ask_sdk_model.request.Request

Represents that a user made a request to an Alexa skill, but did not provide a specific intent.

Parameters:
  • request_id ((optional) str) – Represents the unique identifier for the specific request.
  • timestamp ((optional) datetime) – Provides the date and time when Alexa sent the request as an ISO 8601 formatted string. Used to verify the request when hosting your skill as a web service.
  • locale ((optional) str) – A string indicating the user’s locale. For example: en-US. This value is only provided with certain request types.
  • task ((optional) ask_sdk_model.task.Task) –
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.permissions module

class ask_sdk_model.permissions.Permissions(consent_token=None, scopes=None)

Bases: object

Contains a consentToken allowing the skill access to information that the customer has consented to provide, such as address information. Note that the consentToken is deprecated. Use the apiAccessToken available in the context object to determine the user’s permissions.

Parameters:
  • consent_token ((optional) str) – A token listing all the permissions granted for this user.
  • scopes ((optional) dict(str, ask_sdk_model.scope.Scope)) – A map where the key is a LoginWithAmazon(LWA) scope and value is a list of key:value pairs which describe the state of user actions on the LWA scope. For e.g. "scopes" :{ "alexa::devices:all:geolocation:read":{"status":"GRANTED"}} This value of "alexa::devices:all:geolocation:read" will determine if the Geolocation data access is granted by the user, or else it will show a card of type AskForPermissionsConsent to the user to get this permission.
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.request module

class ask_sdk_model.request.Request(object_type=None, request_id=None, timestamp=None, locale=None)

Bases: object

A request object that provides the details of the user’s request. The request body contains the parameters necessary for the service to perform its logic and generate a response.

Parameters:
  • object_type ((optional) str) – Describes the type of the request.
  • request_id ((optional) str) – Represents the unique identifier for the specific request.
  • timestamp ((optional) datetime) – Provides the date and time when Alexa sent the request as an ISO 8601 formatted string. Used to verify the request when hosting your skill as a web service.
  • locale ((optional) str) – A string indicating the user’s locale. For example: en-US. This value is only provided with certain request types.

Note

This is an abstract class. Use the following mapping, to figure out the model class to be instantiated, that sets type variable.




AlexaSkillEvent.ProactiveSubscriptionChanged: ask_sdk_model.events.skillevents.proactive_subscription_changed_request.ProactiveSubscriptionChangedRequest,







SessionResumedRequest: ask_sdk_model.session_resumed_request.SessionResumedRequest,






CustomInterfaceController.Expired: ask_sdk_model.interfaces.custom_interface_controller.expired_request.ExpiredRequest,










CustomInterfaceController.EventsReceived: ask_sdk_model.interfaces.custom_interface_controller.events_received_request.EventsReceivedRequest,













classmethod get_real_child_model(data)

Returns the real base class specified by the discriminator

to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.request_envelope module

class ask_sdk_model.request_envelope.RequestEnvelope(version=None, session=None, context=None, request=None)

Bases: object

Request wrapper for all requests sent to your Skill.

Parameters:
  • version ((optional) str) – The version specifier for the request.
  • session ((optional) ask_sdk_model.session.Session) – The session object provides additional context associated with the request.
  • context ((optional) ask_sdk_model.context.Context) – The context object provides your skill with information about the current state of the Alexa service and device at the time the request is sent to your service. This is included on all requests. For requests sent in the context of a session (LaunchRequest and IntentRequest), the context object duplicates the user and application information that is also available in the session.
  • request ((optional) ask_sdk_model.request.Request) – A request object that provides the details of the user’s request.
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.response module

class ask_sdk_model.response.Response(output_speech=None, card=None, reprompt=None, directives=None, should_end_session=None, can_fulfill_intent=None)

Bases: object

Parameters:
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.response_envelope module

class ask_sdk_model.response_envelope.ResponseEnvelope(version=None, session_attributes=None, user_agent=None, response=None)

Bases: object

Parameters:
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.session module

class ask_sdk_model.session.Session(new=None, session_id=None, user=None, attributes=None, application=None)

Bases: object

Represents a single execution of the alexa service

Parameters:
  • new ((optional) bool) – A boolean value indicating whether this is a new session. Returns true for a new session or false for an existing session.
  • session_id ((optional) str) – A string that represents a unique identifier per a user’s active session.
  • user ((optional) ask_sdk_model.user.User) – An object that describes the user making the request.
  • attributes ((optional) dict(str, object)) – A map of key-value pairs. The attributes map is empty for requests where a new session has started with the property new set to true. When returning your response, you can include data you need to persist during the session in the sessionAttributes property. The attributes you provide are then passed back to your skill on the next request.
  • application ((optional) ask_sdk_model.application.Application) –
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.session_ended_error module

class ask_sdk_model.session_ended_error.SessionEndedError(object_type=None, message=None)

Bases: object

An error object providing more information about the error that occurred.

Parameters:
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.session_ended_error_type module

class ask_sdk_model.session_ended_error_type.SessionEndedErrorType

Bases: enum.Enum

A string indicating the type of error that occurred.

Allowed enum values: [INVALID_RESPONSE, DEVICE_COMMUNICATION_ERROR, INTERNAL_SERVICE_ERROR, ENDPOINT_TIMEOUT]

to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.session_ended_reason module

class ask_sdk_model.session_ended_reason.SessionEndedReason

Bases: enum.Enum

The reason why session ended when not initiated from the Skill itself.

Allowed enum values: [USER_INITIATED, ERROR, EXCEEDED_MAX_REPROMPTS]

to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.session_ended_request module

class ask_sdk_model.session_ended_request.SessionEndedRequest(request_id=None, timestamp=None, locale=None, reason=None, error=None)

Bases: ask_sdk_model.request.Request

A SessionEndedRequest is an object that represents a request made to an Alexa skill to notify that a session was ended. Your service receives a SessionEndedRequest when a currently open session is closed for one of the following reasons: <ol><li>The user says “exit”</li><li>the user does not respond or says something that does not match an intent defined in your voice interface while the device is listening for the user’s response</li><li>an error occurs</li></ol>

Parameters:
  • request_id ((optional) str) – Represents the unique identifier for the specific request.
  • timestamp ((optional) datetime) – Provides the date and time when Alexa sent the request as an ISO 8601 formatted string. Used to verify the request when hosting your skill as a web service.
  • locale ((optional) str) – A string indicating the user’s locale. For example: en-US. This value is only provided with certain request types.
  • reason ((optional) ask_sdk_model.session_ended_reason.SessionEndedReason) – Describes why the session ended.
  • error ((optional) ask_sdk_model.session_ended_error.SessionEndedError) – An error object providing more information about the error that occurred.
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.slot module

class ask_sdk_model.slot.Slot(name=None, value=None, confirmation_status=None, resolutions=None)

Bases: object

Parameters:
  • name ((optional) str) – A string that represents the name of the slot.
  • value ((optional) str) – A string that represents the value the user spoke for the slot. This is the actual value the user spoke, not necessarily the canonical value or one of the synonyms defined for the entity. Note that AMAZON.LITERAL slot values sent to your service are always in all lower case.
  • confirmation_status ((optional) ask_sdk_model.slot_confirmation_status.SlotConfirmationStatus) – Indication of whether an intent or slot has been explicitly confirmed or denied by the user, or neither.
  • resolutions ((optional) ask_sdk_model.slu.entityresolution.resolutions.Resolutions) – Contains the results of entity resolution. These are organized by authority. An authority represents the source for the data provided for the slot. For a custom slot type, the authority is the slot type you defined.
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.slot_confirmation_status module

class ask_sdk_model.slot_confirmation_status.SlotConfirmationStatus

Bases: enum.Enum

An enumeration indicating whether the user has explicitly confirmed or denied the value of this slot.

Allowed enum values: [NONE, DENIED, CONFIRMED]

to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.supported_interfaces module

class ask_sdk_model.supported_interfaces.SupportedInterfaces(alexa_presentation_apl=None, audio_player=None, display=None, video_app=None, geolocation=None)

Bases: object

An object listing each interface that the device supports. For example, if supportedInterfaces includes AudioPlayer {}, then you know that the device supports streaming audio using the AudioPlayer interface.

Parameters:
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.user module

class ask_sdk_model.user.User(user_id=None, access_token=None, permissions=None)

Bases: object

An object that describes the Amazon account for which the skill is enabled.

Parameters:
  • user_id ((optional) str) – A string that represents a unique identifier for the user who made the request. The length of this identifier can vary, but is never more than 255 characters. The userId is automatically generated when a user enables the skill in the Alexa app. Note: Disabling and re-enabling a skill generates a new identifier.
  • access_token ((optional) str) – A token identifying the user in another system. This is only provided if the user has successfully linked their skill account with their Amazon account.
  • permissions ((optional) ask_sdk_model.permissions.Permissions) –
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.permission_status module

class ask_sdk_model.permission_status.PermissionStatus

Bases: enum.Enum

This denotes the status of the permission scope.

Allowed enum values: [GRANTED, DENIED]

to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.scope module

class ask_sdk_model.scope.Scope(status=None)

Bases: object

This is the value of LoginWithAmazon(LWA) consent scope. This object is used as in the key-value pairs that are provided in user.permissions.scopes object

Parameters:status ((optional) ask_sdk_model.permission_status.PermissionStatus) –
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model