alexa_skill package

Submodules

alexa_skill.dates module

class alexa_skill.dates.AmazonDateParser

Bases: object

Amazon build-in date format parser.

Amazon Alexa API reference:
https://developer.amazon.com/docs/custom-skills/slot-type-reference.html#date
WEEK_MAPPER = {'w0': 'w00', 'w1': 'w01', 'w2': 'w02', 'w3': 'w03', 'w4': 'w04', 'w5': 'w05', 'w6': 'w06', 'w7': 'w07', 'w8': 'w08', 'w9': 'w09'}
classmethod create_periods(amazon_date, timezone=tzfile('/usr/share/zoneinfo/Europe/Berlin'))
classmethod to_date(amazon_date)

Parses alexa date output string to mapped time.

Parameters:amazon_date ((str)) – Amazon date string.
Returns:Datetime with parsed date and date type. Otherwise (None, None) if date is not parsable.
Return type:tuple

Note

Possible date types:
  • normal
  • week
  • weekend
  • month
  • year
class alexa_skill.dates.AmazonTimeParser

Bases: object

DAY_TIME_MAPPER = {'AV': (13, 0), 'EV': (18, 0), 'MO': (8, 30), 'NI': (21, 0)}
classmethod to_time(amazon_time)

Parses alexa time output string to mapped time.

Parameters:amazon_time ((str)) – Amazon string time. Possible choices: [MO, AV, EV, NI].
Returns:Time tuple with hour as first element and minutes as second, otherwise None when amazon_time is not parsable.
Return type:tuple

alexa_skill.messages module

alexa_skill.messages.cards(title, text, card_type='Simple', image=None)

Returns alexa cards

Parameters:
  • title (str) – A string containing the title of the card.
  • text (str) – A string containing the text content for a Standard card (not applicable for cards of type Simple)
  • card_type (str) – A string describing the type of card to render. Valid types are: * “Simple”: A card that contains a title and plain text content. * “Standard”: A card that contains a title, text content, and an image to display.
  • image (dict) – An image object that specifies the URLs for the image to display on a Standard card. Only applicable for Standard cards. You can provide two URLs, for use on different sized screens. * smallImageUrl * largeImageUrl
Returns:

Dictionary with cards details

Return type:

dict

Alexa API Reference:
https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#card-object
alexa_skill.messages.confirm_slots_directives(slots)

Used to ask user for missing slots.

When confirm_slots is used, Alexa respond to a end user with message specified in outputSpeech element and expects the value for specified slots with the same intent as was detect in previous message.

Alexa API Reference:
https://developer.amazon.com/docs/custom-skills/dialog-interface-reference.html#confirmslot
alexa_skill.messages.create_response(text, card_title='', should_end_session=True, reprompt=None, confirm_slots=False, speech_type='SSML')

Creates response for Alexa skill with answer for user intent.

Parameters:
  • text ((str)) – Text which should he responded to a user. Not required. Default: ‘’
  • card_title ((str)) – Tile used in alexa cards
  • should_end_session ((bool)) – Defines whether session should be close or not (Mike should listen for next user response or should close connection).
  • reprompt ((str)) – Defines reprompt output speech text. Default: will be no reprompt.
  • confirm_slots ((dict)) – Dict of slot name which require confirmation as key and updated intent dict as value.
  • speech_type ((str)) – Defines type of speech which should be returned. Choices: SSML or PlainText.
Returns:

Dict with Alexa response format.

Alexa API Reference:
https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#response-format
alexa_skill.messages.reprompt(text, speech_type='PlainText')

This object can only be included when sending a response to a [CanFulfillIntentRequest, LaunchRequest, IntentRequest, or InputHandlerEvent]

Parameters:
  • text ((str)) – Text which will be returned to the user.
  • speech_type ((str)) – Type in which text is formatted. Choices: [SSML, PlainText]. Default: SSML
Returns:

Dictionary with output speech

Return type:

dict

Alexa API Reference:
https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#reprompt-object
alexa_skill.messages.speech_output(text, speech_type='SSML')

This function is used for setting both the outputSpeech and the reprompt properties.

Parameters:
  • text ((str)) – Text which will be returned to the user.
  • speech_type ((str)) – Type in which text is formatted. Choices: [SSML, PlainText]. Default: SSML
Returns:

Alexa parsable dictionary.

Return type:

dict

Alexa API Reference:
https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#outputspeech-object

Module contents

class alexa_skill.Processor(request_body, buildin_intents, launch_message, session_end_message, *intents)

Bases: object

intent_name
intent_request()
Returns a list with:
0: message for user 1: bool: True when alexa request was handled by Backend 2: bool: if session should be ended
launch_request()
Returns a list with:
0: message for user 1: bool: True when alexa request was handled by Backend
locale

Used for setting i18n internationalization strings

request_type
session_attributes
session_end_request()
Returns a list with:
0: message for user 1: bool: True when alexa request was handled by Backend
session_hash

Return session hash of a user.

slots

Alexa slots which are defined in Alexa console.

API Reference:
https://developer.amazon.com/docs/custom-skills/slot-type-reference.html
Return type:dict