Amazon Lambda : VoiceWorx Integration

Objective

This guide will help you to quickly connect to Amazon Lambda and create various methods to execute Lambda functions and get the function output. The purpose is to demonstrate how easy it is to integrate Amazon Lambda to the VoiceWorx platform.

Pre-requisites

  • 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

  • At least one Lambda Function

If you do not have any Lambda function, you can follow this document on how to create a lambda function. Or for detail information, you can run through this Run a Serverless "Hello, World!" tutorial.

If you would like to refer to the introduction video of Lambda, you can watch this getting started video at https://youtu.be/eOBq__h4OJ4

  • Access Key, Secret access key and AWS Region Name To be able to connect to Amazon Lambda from the VoiceWorx platform, one IAM user is required and user should have permissions to view and execute Amazon Lambda functions. It is recommended to have IAM policy named AWSLambdaFullAccess be assigned to the user.

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

  • A VoiceWorx Account

For steps to create a VoiceWorx account, follow the steps at https://docs.voiceworx.ai/general/voiceworx-create-account

Steps

To proceed with these steps, you should have all the pre-requisites satisfied. If you are missing something, please go back and make sure you satisfy all of them. For this particular demo, we strongly suggest that you create a lambda function as guided in this document.

Once done, you are ready to get started using VoiceWorx platform with Amazon Lambda.

Step 1 Connect to Amazon Lambda

Login to the VoiceWorx portal at https://portal.voiceworx.ai

To Configure Lambda, browse to: Integration > Connect System > Connect External System in the VoiceWorx platform and select options as shown below.

Once you click on “Connect System” button, you will be redirected to the configuration screen where you need to provide connection information as shown below.

If you do not have this information ready, please refer to the pre-requisites #3

The table below explains each of the inputs shown on this screen.

Fill the required information and click on “Validate and Save Settings” button, this will validate the details and if it is correct, integration will be saved, and you will be redirected to the integrations listing page as shown below.

Step 2 Create an App for Amazon Lambda

To create a skill, browse to Custom Apps > Manage Apps and click on New Custom App button as shown below.

You should see a small popup as shown below.

Click on save, this will create an app and you should see a screen as shown below,

This shows that an app is successfully created, and you have various options like setup data sources. This is explained in next step.

Step 3 Create a Data Source

To follow this step, make sure you have completed above Step 2. If not please go back and do it.

A Data Source connects the app with the Lambda integration we did in Step #1. Once you have a skill created, you can go to Data Sources by clicking on “Data Sources” tab.

Now you should see screen as shown below.

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 Lambda integration that you have created in Step 1 and click on Save.

Once a data source is created, you are ready to start creating various methods.

Step 4 Create Methods to fetch the data from Amazon Lambda

To use this step, make sure you have completed previous step. If not go back and complete it.

Methods allows you to execute the Lambda function. To access the methods, click on the “Methods” tab which is next to the “Data Sources” tab.

As of the publication date of this document, the VoiceWorx platform supports following Lambda methods,

  1. Get Functions

  2. Execute Function

Depending on requirement, you will have to use an appropriate method, this document will explain each of these methods with an example.

Let’s start with a use case.

Scenario/ Use Case (Contact Finder):

You have a Lambda function which takes name as an input, searches for the contact information for the provided name and returns phone number as an output.

You want to find Phone Number of your friend Rose. For this, you can use ExecuteFunction method as explained below.

Method: ExecuteFunction

This method requires two parameters as explained below.

Parameters:

Other than these two parameters, you need to provide the following standard inputs

Now, you can save and test the method to see the method is able to fetch data from Lambda function.

Sample Response: (Dependent on Lambda Function output)

{

"name": "Rose",

"phone": "(512) 757-6001",

"country": "USA"

}

Method: GetFunctions

This method returns all the available Lambda functions in your account for the given Region.

Parameters: Not required

Sample Response:

[

{

"CodeSha256": "Zoi4TT7+rac74irUovU5MfPzU8fxnRmdZQbujxkvU78=",

"CodeSize": 380,

"DeadLetterConfig": null,

"Description": "",

"Environment": null,

"FunctionArn": "arn:aws:lambda:us-east-2:939063855410:function:ContactFinder",

"FunctionName": "ContactFinder",

"Handler": "lambda_function.lambda_handler",

"KMSKeyArn": null,

"LastModified": "2020-08-07T20:41:58.491+0000",

"LastUpdateStatus": null,

"LastUpdateStatusReason": null,

"LastUpdateStatusReasonCode": null,

"Layers": [],

"MasterArn": null,

"MemorySize": 128,

"RevisionId": "4d001c08-5bdc-48de-b7c6-ec5bd3d85f5c",

"Role": "arn:aws:iam::9390636344510:role/Role_Lambda",

"Runtime": {

"Value": "python3.8"

},

"State": null,

"StateReason": null,

"StateReasonCode": null,

"Timeout": 3,

"TracingConfig": {

"Mode": {

"Value": "PassThrough"

}

},

"Version": "$LATEST",

"VpcConfig": null

}

]

Create Intents

  1. Now Create Intents for each method:

Fill the following details:

Create Utterances

  1. Create Utterances to invoke the intent. Utterances are short keywords that are used to invoke the intents created. In the Utterances tab, make sure that the correct intent is selected in the drop down. Click on Create New Utterances and provide details as shown below:

For example, if you are going to create utterance for GetFunctionsIntent, make sure the intent is selected, Click on Create New Utterance and fill the details and Save.

A sample utterance for ExecuteIntent is also shown below.

Create Inputs

  1. Now create Input for the intents:

Create Publish Profile and Publish

  1. Now that all components of the app have been set, let us create publish profile and publish the app to Lex Bot.

  2. Go to the publish tab and click on Add App Publishing.

  1. Fill in the following details in the resulting screen.

  1. Once saved, now you can click on the Actions to Publish to the selected Channel i.e. lex in our case.

  1. You will be directed to following screen, where you can select the Lex Account to which you want to deploy the bot.

  1. Click on Publish to V1 and on success you’ll get following screen. You can now click on Go to Lex Skill and test the bot in the Amazon Lex Chatbot.

  2. Here are some sample results:

Congratulations, you’ve successfully completed VoiceWorx integration with Amazon Lambda.

Last updated