VoiceWorx.ai
Search…
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

  1. 1.
    A VoiceWorx Account
For steps to create a VoiceWorx account, follow the steps at https://docs.voiceworx.ai/general/voiceworx-create-account
  1. 1.
    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
  1. 1.
    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

  1. 1.
    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
  1. 1.
    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:
Input
Information
Service Instance Name
You can give any value of your choice.
Consumer Key
This is your AWS Access key ID
Consumer Secret
This is your AWS Secret access key
Region
AWS Region Name. The Lex service will be used in this region.
When used to publish the skill, it will be published in this region.
  1. 1.
    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

  1. 1.
    Create another connection for Internal Data. Internal Data means the data source that VoiceWorx provides by default.
  2. 2.
    Click on Add New Connection on the Connect System page from the left navigation.
You should see a small popup screen as shown below.
    1. 1.
      Select Custom for the Integration Category
    2. 2.
      Select Internal Content for the System Type
    3. 3.
      Give any name of your choice for the system Instance Name.
    4. 4.
      Click on Connect System button and this should quickly create a connection for the internal Content for you.
  1. 1.
    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

  1. 1.
    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.
Input
Information
Name
You can give any value of your choice.
Custom App Type
Select Search
Category
Please use the same category that you have used for the Intern Data.
Note: If category do not match then methods in this skill may not be able to access the JSON data.
Make this app as shared…
Select this if you want to share this skill with other users in your organization.
  1. 1.
    Click on ‘Save’ and app should get created and selected for the next steps.

Create a Data Source

  1. 1.
    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.
  1. 1.
    To create a data source, click on ‘Create New Data Source’ button and you should see a popup screen as shown below
  1. 1.
    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.
  2. 2.
    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):

  1. 1.
    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"
}
]
}
  1. 1.
    Go to Content submenu in Content menu and click on add new content.
Fill following details:
Contact Name: Contacts01
Content Code: Contacts01
Category : Sample (should be same as the app category)
Check Media/Data
Select Upload File
Upload the .json file created in above step and Click on Save
The content created now can be accessed using methods.

Create Methods

Method-1: GetContactNumberMethod

  1. 1.
    Let’s created first method which returns contact number of a person.
For each of the inputs, enter values as shown below.
Input
Value
Method Name
GetContactNumberMethod
Request Type
GetJsonContents
Parameters
  • ContentID
Contacts01 (same as ContentCode and ContentName in Content created in Step 14)
Record Limit
10
Record JsonPath
$.Contacts[?(@.name=='{{Name}}')]
Empty Result Template
Contact not found
Record Template
Contact Number of {{name}} is {{contactnumber}}
Result Template
{{Records}}
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

  1. 1.
    Let’s created another method which returns location of a person.
For each of the inputs, enter values as shown below.
Input
Value
Method Name
GetLocationMethod
Request Type
GetJsonContents
Parameters
  • ContentID
Contacts01
Record Limit
10
Record JsonPath
$.Contacts[?(@.name=='{{Name}}')]
Empty Result Template
Contact not found
Record Template
{{name}} lives in {{country}}
Result Template
{{Records}}

Sample Response:

Bob lives in US

Method-3: GetOccupationMethod

  1. 1.
    Let’s created another method which returns occupation of a person.
For each of the inputs, enter values as shown below.
Input
Value
Method Name
GetOccupationMethod
Request Type
GetJsonContents
Parameters
  • ContentID
Contacts01
Record Limit
10
Record JsonPath
$.Contacts[?(@.name=='{{Name}}')]
Empty Result Template
Contact not found
Record Template
Occupation of {{name}} is {{occupation}}
Result Template
{{Records}}

Sample Response:

Bob is Engineer

Create Intent

  1. 1.
    Now it’s time to create one or more intents. You shall create intents corresponding to each method.
  2. 2.
    Navigate to the Intents tab and then click on Create New Intent button as shown below
  3. 3.
    On the Intent creation screen, you should see a popup screen for creating intent.
    1. 1.
      GetContactNumberIntent
Intent Name
GetContactNumberIntent
Intent Type
Search
Intent Action
Execute Method
Primary Method
Data Source
The data source that you want to use (Contacts in JSON)
Data Source Method
GetContactNumberMethod
    1. 1.
      GetOccupationIntent
Intent Name
GetOccupationIntent
Intent Type
Search
Intent Action
Execute Method
Primary Method
Data Source
The data source that you want to use (Contacts in JSON)
Data Source Method
GetOccupationMethod
    1. 1.
      GetLocationIntent
Intent Name
GetLocationIntent
Intent Type
Search
Intent Action
Execute Method
Primary Method
Data Source
The data source that you want to use (Contacts in JSON)
Data Source Method
GetLocationMethod

Create a slot

  1. 1.
    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

  1. 1.
    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

  1. 1.
    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

  1. 1.
    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
  1. 1.
    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

  1. 1.
    In the top menu tabs, select “Publish” then click “Add App Publishing”.
  2. 2.
    Once in “Add App Publishing” the popup screen will appear. Fill in the details below and click on Save.
Input
Explanation
External Skill Name
This is the name of the skill. You can give name of your choice.
Skill Type
It should be “Search”
Channel
Must be “Amazon Alexa”
Auth Publish
Keep it selected
Skill Invocation
Before method
Welcome Message
Should be auto populated.
WelcomeBack Message
Should be auto populated, confirm to check.
Re-Prompt Message
Should be auto populated.
Help Message
Should be auto populated.
Goodbye Message
Should be auto populated.
Fall Back Message
Should be auto populated.
  1. 1.
    Now the publish profile has been created, click on action then click on publish to alexa.
  2. 2.
    Once in “Publish” the publish process is initiated. The screen shown below will appear.
  3. 3.
    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

  1. 1.
    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.
  1. 1.
    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.
Copy link
On this page
Pre-requisites
Setup connection to Amazon Lex
Create a new connection for the Internal Data
Create an App to utilize internal data
Create a Data Source
Sample Data (JSON file):
Create Methods
Method-1: GetContactNumberMethod
Method-2: GetLocationMethod
Method-3: GetOccupationMethod
Create Intent
Create a slot
Create Utterance
Create Input
Create Input Parameter
Publish to Amazon Lex
Test the skill on Amazon Lex