Build the Alexa Interaction Model (the front-end) and point it to the back-end lambda function.
You will need an account with developer.amazon.com.
Go to developer.amazon.com and sign in with the same email address that you’ve registered your Amazon Echo with.
- Go to developer.amazon.com/alexa.
- Click Create Alexa Skills and then click Console. This opens the developer console and displays any skills you have already created.
- Click Create Skill.
- Enter the Skill name "MyTravelSkill".
- Skill name: This is the name customers will see when you publish the skill. You can edit this name later on the Distribution page.
- Default language: You can add additional languages to the skill later.
- Click the Custom model. Click here for more details about different models.
- Select Alexa-Hosted(Node.js) to host your backend code to the AWS.
- Click Create skill.
- Select Start from Scratch and then click Continue with template.
You should be landed to the Build page.
Users say a skill's invocation name to begin an interaction with a particular custom skill.
- From the left navigator, Click Invocations and then Skill Invocation Name
- Change to Skill Invocation Name to mytravelskill
An intent represents an action that fulfills a user's spoken request. Intents can optionally have arguments called Slots. The utterances specify the words and phrases users can say to invoke your intents.
- From the checklist, click the second bullet Intents, Samples, and Slots
- Enter the name of the new intent PlanMyTrip and click Create custom intent. This adds a new intent and opens its detail page, displaying the intent's sample utterances and slots.
- Click Create custom intent
- In the Intents Slots section, create below slots.
- Enter below sample utterances:
- i am going on a trip on friday
- i want to visit portland
- i want to travel from seattle to portland next friday
Once you have written a few utterances, note the words or phrases that represent variable information. These will become the intent's slots. For example, in the utterances identified above, the variables that are highlighted next friday, seattle, and portland.
- In an utterance, highlight the word or phrase representing the slot value.
- In the drop-down that appears, select the slot. This will replace the original value in the utterance with the slot name in curly brackets ({ }).
-
Click Save Model
-
Click Build Model.
By creating this intent, if user says: "Alexa, ask Plan My Trip i want to travel from seattle to portland next friday."
The Alexa service sends the Plan My Trip service a PlanMyTrip intent with the value "Seattle" in the fromCity slot, "Portland" in the toCity slot and the date for the next upcoming Friday travelDate slot. The service can then save this information and send back text to convert to speech.
Slots are defined with different types. The travelDate slot in the above example uses Amazon's built-in AMAZON.DATE type to convert words that indicate dates (such as "today" and "next friday") into a date format, while both fromCity and toCity use the built-in AMAZON.US_CITY slot.
- Click Code on the top menu.
- Open index.js file.
- Replace all code with the code here.
- Click Save.
- Click Deploy.
Use the simulator provided on the Test page in the developer console. This gives you access to most Alexa Skills Kit features without a device. You can interact with Alexa using either voice or text.
- Click Test from top menu
- You might get below pop-up. Click Allow to be able to use your microphone.
- Select Development from dropdown on top of the page
- In the Alexa Simulator tab, you can type or hold the mic icon to talk.
- Say below sentences and see the response from Alexa,
- ask mytravelskill i am going on a trip on friday
- ask mytravelskill i want to visit portland
- ask mytravelskill i want to travel from seattle to portland next friday
The Interaction Model is connected to a Lambda Function via Endpoints. Depending on the Intent detected, Lambda Function running on AWS executes a task () and the result is returned to the Interaction Model.
The Endpoint will receive POST requests when a user interacts with your Alexa Skill. You can link your Skill with Lambda (Recommended) or you can host your endpoint using an HTTPS web service that you manage.