Q&A App with publishing to Lex
Objective
This document aims at guiding users to develop a sample Q and A app for Lex using the custom app features .
Pre-requisites
A VoiceWorx Account
For steps to create a VoiceWorx account, follow the steps at https://docs.voiceworx.ai/general/voiceworx-create-account
An active AWS Account
You should have an active AWS Account. If you do not have it, you can create an AWS account at https://portal.aws.amazon.com/billing/signup#/start
AWS Accounts Include 12 Months of Free Tier Access
AWS Account - Access Key, Secret access key and AWS Region Name To be able to connect to Amazon Lex from the VoiceWorx platform, one AWS IAM user is required and user should have the required permissions to access Lex service.
Following is a json document which you can use to create an IAM policy and assign it to the IAM user in the AWS console.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VoiceWorx",
"Effect": "Allow",
"Action": [
"lex:*",
"lambda:*",
"iam:*"
],
"Resource": "*"
}
]
}
For more information on creating IAM users and assigning policies, refer to the AWS official documentation https://aws.amazon.com/premiumsupport/knowledge-center/create-access-key/
You can also refer to the simplified VoiceWorx documentation at https://docs.voiceworx.ai/aws-iam-users
To proceed with these steps all pre-requisites must be satisfied. If something is missing, please return to pre-requisites to ensure all are fulfilled.
Now let’s begin using VoiceWorx platform with Amazon Lambda.
Setup connection to Amazon Lex
Login to the VoiceWorx platform,use left navigation menu and click “Integration” then select “Connect System”. In the resulting page, click “Connect External Systems”.
Select Integration Category: Custom
Select System Type: Amazon Lex
Click: Connect System
Once in “Connect System” the configuration screen below will appear. Provide connection information as shown below:
Service Instance Name: You can give any value of your choice.
Consumer Key: This information is made available in pre-requisites #4
Consumer Secret: This information is made available in pre-requisites #4
Region: This information is made available in pre-requisites #4
Click: Validate and Save Settings
See below additional information.
The table below explains each of the inputs shown on this screen:
Once validation is confirmed the details of integration will be saved. The integrations listing page will be shown as below.
Lex connection is ready to use for future usage.
Create a new connection for the Internal Data
Create another connection for Internal Data. Internal Data means the data source that VoiceWorx provides by default.
Click on Add New Connection on the Connect System page from the left navigation.
You should see a small popup screen as shown below.
Select Custom for the Integration Category
Select Internal Content for the System Type
Give any name of your choice for the system Instance Name.
Click on Connect System button and this should quickly create a connection for the internal Content for you.
You should see a newly created connection as shown in below screenshot.
Now the connection is ready to use with the skill
Create an App to utilize internal data
To create a skill, browse to Custom Apps > Manage Apps and click on New Custom App button, you should see a small popup screen as shown below.
Click on ‘Save’ and app should get created and selected for the next steps.
Create a Data Source
A Data Source connects the Skill with the integration. Once you have a skill created, you can go to Data Sources either by clicking on “Setup Data Source” button (as shown in the previous screenshot) or by clicking on “Data Sources” tab.
To create a data source, click on ‘Create New Data Source’ button and you should see a popup screen as shown below
Give a name of your choice and make sure you select the same connection that you have created in Step 2. In this example, it is “My Contacts”. If you want to make this connection as private to you, select the available option “Consider as a Personalized Data Source”. If selected, other users in your organization will not be able to use it.
Now click on Save. Once a data source is created, you are ready to start creating various methods and use JSON Data.
Sample Data (JSON file):
We are going to use sample contacts data in JSON format. You should have a contact created with following JSON data. For this, copy the following sample JSON data, paste it in notepad and save it as a .json file.
{
"Contacts": [
{
"name": "Martin",
"contactnumber": "(678)345 6789",
"country": "US",
"occupation": "Businessman"
},
{
"name": "Bob",
"contactnumber": "(678) 045 6789",
"country": "US",
"occupation": "Engineer"
},
{
"name": "James",
"contactnumber": "(678) 123 0456",
"country": "Canada",
"occupation": "Teacher"
}
]
}
Go to Content submenu in Content menu and click on add new content.
Fill following details:
The content created now can be accessed using methods.
Create Methods
Method-1: GetContactNumberMethod
Let’s created first method which returns contact number of a person.
For each of the inputs, enter values as shown below.
Now click on save & test. Once you test this method, it should provide you following sample result.
Sample Response:
Contact Number of martin is (678) 045 6789
Method-2: GetLocationMethod
Let’s created another method which returns location of a person.
For each of the inputs, enter values as shown below.
Sample Response:
Bob lives in US
Method-3: GetOccupationMethod
Let’s created another method which returns occupation of a person.
For each of the inputs, enter values as shown below.
Sample Response:
Bob is Engineer
Create Intent
Now it’s time to create one or more intents. You shall create intents corresponding to each method.
On the Intent creation screen, you should see a popup screen for creating intent.
GetContactNumberIntent
GetOccupationIntent
GetLocationIntent
Create a slot
We need to create a slot as the method we are using that uses one variable. Go to the Slots tab and select GetOccupationIntent from the intent dropdown. Repeat the same for other two intents as well.
Now click on Create new slot button and you should see a add slot screen. Enter required values as shown below and click on save to create the slot.
Create Utterance
Now let’s create an utterance which we will be using from Lex to test the bot/skill
Go to the Utterances tab and then select the intent that we have already created, now click on Create New Utterance button.
This should bring a create utterance screen. Enter the values as shown in below screenshot.
Click on save and an utterance should get created.
Repeat the similar process for other two intents.
Create Input
The method we are using requires an input, so we need to create an input from the Inputs screen. Go to the inputs tab and then click on Create New Input button.
On the Add new Custom input screen, fill the details as shown below and click on save.
Once saved, you should see input in the list. In the similar way, create intent for rest of the intents as well.
Create Input Parameter
On the inputs list, click on the Manage Parameter button in the Action column – as shown below.
Once you are in the Manage Input Parameters screen, click on Add New Input Parameter
On the Add input parameter screen, enter values as shown in the below screenshot.
Click on Save and input parameter should get created. Again, repeat the same process for the rest two inputs as well. Create “Name” parameter for each of them.
Now we are ready to publish the skill on any platform.
Publish to Amazon Lex
In the top menu tabs, select “Publish” then click “Add App Publishing”.
Once in “Add App Publishing” the popup screen will appear. Fill in the details below and click on Save.
Now the publish profile has been created, click on action then click on publish to alexa.
Once in “Publish” the publish process is initiated. The screen shown below will appear.
Click “Publish to Lex V1” and this will initiate the publish process. The following results screen will appear as shown below. The results screen has an option to go to the “Go To Lex Skill” or “Go To Skill Publishing”.
Test the skill on Amazon Lex
On the skill publishing results page, you have a button Go To Lex Skill as shown in above diagram.
When you click on it, you will be redirected to the Alexa developer console.
On the Test chatbot, ensure “Build Completed” else you may not be able to Test the skill.
Once you are on Amazon Lex bot test screen, you can invoke the intents using the utterances.
Congratulations!
You have successfully completed Q and A Chat bot for Amazon Lex using VoiceWorx.
Last updated