Get Slot Value Alexa Python

Get Slot Value Alexa Python Average ratng: 3,6/5 3025 reviews

In our case, alexa responds with the output when user provides Invocation name with utterance. Example: “Alexa, Open Rail Gaadi to get the status of 12345” Slots: Slots represents how data or values are handled for processing the requests. Amazon provides built in slots which could be found here. One can provide their own custom slots if. Amazon Echo PHP file to control Honeywell Thermostat through a python script - echo.php. Use getslotnames to get the list of slot names created by the Optimizer. Args: var: A variable passed to minimize or applygradients. Returns: The Variable for the slot if it was created, None otherwise. Getslotnames getslotnames Return a list of the names of slots created by the Optimizer. This.event.request.intent.slots.name.value has the value of the name passed in via an utterance like 'Get fact about shaun'. Where the value above would be shaun taken from the utterance and available in the handler? Also, what other values are available on this object? This.attributes and this.events) 👍.

  1. Get Slot Value Alexa Python Programming
  2. Get Slot Value Alexa Python Tutorial
  3. Get Slot Value Alexa Python Ide
  4. Get Slot Value Alexa Python Codes

Prerequisites:

  1. Amazon developer’s account.
  2. Amazon web services account.
  3. Basics of python programming.

Topics Covered:

  1. Understanding architecture of alexa.
  2. Lambda function to create custom skill.
  3. Invocation name, Utterances and slots
  4. Zipping the files and its dependencies.
  5. Uploading and testing the skill.
  6. Submitting the skill for certification.

1. Let us understand the basic architecture of alexa with a simple diagram

User enables the skill from amazon alexa app in device, then the skill needs to be invoked using its ‘Invocation Name‘ here in this case ‘Rail Gaadi’ is the invocation name. when user prompts with utterance, alexa recognizes the utterance and converts that into the json object. Our custom skill reads the json object and process the request and sends the response back to alexa.

2. Creating lambda function and using the sample blueprint to develop custom skill

Codes
  • Login into lambda function console and click on create function
  • function name should be as simple as possible as it would be used in amazon resource name (ARN’s)
  • AWS Lambda function calls lambda_handler function to start your service, it is just like a main method or function which AWS Lambda understands.
  • In the context of creating custom skills, there are few functions which needs to be handled in lambda_handler which are as mentioned below.
  • on_session_started,on_launch, on_intent and on_session_ended as the name suggests all the method needs to be handled inside the lambda_handler.
  • on_session_started & on_session_ended is where your session starts & ends respectively.
  • on_launch this is where you prompt user with respective welcome note or with your app details
  • on_intent is where one implement the logic.

Note: try to understand the sample code in the blueprint and life would be easy.

3. Invocation Name, Utterances and Slots

let us understand invocation name, intents and utterance one by one as this is very important for any skill to understand and respond.

Invocation Name:

  • Alexa recognizes the skills by the invocation name provided in this case – Rail Gaadi is the invocation name.
  • Alexa responds with welcome message when user does not provide any specific request. example: “Alexa, Open Rail Gaadi

Utterance:

  • A user spoken statement or sentence which alexa understands to perform some action
  • In our case, alexa responds with the output when user provides Invocation name with utterance. example: “Alexa, Open Rail Gaadi to get the status of 12345”

Slots:

  • Slots represents how data or values are handled for processing the requests.
  • Amazon provides built in slots which could be found here.
  • One can provide their own custom slots if required.

Hurry! theoretical journey has been complete. we are few steps ahead to submitting the alexa app.

Get Slot Value Alexa Python Programming

  1. Login into amazon developer console.
  2. Click on the Alexa tab.

click on the Get Started button under alexa tab and user would be redirected to add skill page.

3. click on Add a New Skill button as shown below.

4. After clicking on add a new skill, we would be landing on Skill Information page here we have to provide app related information. Skill Type, Language, Name, Invocation Name and Global Fields.

  • Skill Type should be selected as Custom Interaction Model, as it is an custom skill.
  • Language is specific to region. Rail Gaadi is for indian market so i have selected English (India).
  • Name is which user would be seeing in the amazon alexa app for search. Name should be small and easy to remember.
  • Make sure invocation name and name should be same.
  • Global fields could be selected depending on the applications requirement.

Get Slot Value Alexa Python Tutorial

5. Interaction Model is where we would be providing sample utterance, slots and intent. here i have taken another example where user would be asking for places history. It provides code editor and as well GUI it is up to the user which needs to be picked up.

Get Slot Value Alexa Python Ide

6. After building and saving the model, we would be landing on Configuration tab. this is crucial as we are going to connect to skill to lambda function code by providing the ARN value in the Default field.

Here come the tricky part of zipping the code and uploading it to lambda function

7. Before zipping the folder make sure to complete all the error handling part.

  • Create and activate virtual environment, let us name it “zipfol“.
  • virtualenv zipfol
  • cd zipfol
  • source ./bin/activate
  • create a text file and include required libraries
  • pip install -r requirements.txt
  • move site-packages in the root folder and zip the folder
  • cd zipfol
  • source ./bin/activate
  • pip install -r requirements.txt
  • mv ./lib/python2.7/site-packages/* ../zipfol/
  • zip -r zipfol.zip *

8. Uploading the zip file to lambda function. if size of zip file is greater than 10 MB then use s3 bucket. it is very simple, just login into s3 bucket console,create s3 bucket and upload the zip file and use the link in lambda function.

9. Testing our code, provide the sample utterance in the service simulator and verify for the response as shown below.

10. Publishing Information sections is very important as it would be user facing, the information provided there would be shown to the user which helps to enable and access with ease.

11. Privacy and Compliance, finally we are one step behind of submitting our code to amazon alexa store. necessary details and accept the compliance. Click on Submit for Certification.

Note: Amazon performs all the basic and necessary steps and testing of your app and if it passes all the certification process. you would be sending an email and it would be live soon.

Python

Get Slot Value Alexa Python Codes

Thank You for reading this blog. please provide your comments and please share it.