Using Translate Tables (Key Value Pairs) In Amazon Connect
In the previous IVR development environment we had a feature called Translate Tables that allowed you to access key/value pairs stored in a table. These key/value pairs can be used as flags or simple values accessed in the IVR application. Here is how I achieved this functionality in Amazon Connect:
DynamoDB - Used to store the key value pairs
Lambda - Function used to grab the value from the key value pair
Creating the table
From the AWS Console Click on Services and type DynamoDB
Click Create table
Table name: translateTable
Primary key: key of type String
Click Create
Click on Tables on the side of the DynamoDB main page and select translateTable.
Click Items to insert some sample values into the table
Click Create item
You can use the Tree View to create the entries:
Or the Text view:
{
"key": "Flag1",
"value": "true",
"description": "Description for Flag1"
}
We now have a key / value pair stored in our translateTable
Now we have to create a Lambda Function to retrieve the value.
Before we create a Lambda function we have to create an execution role for the function.
From the AWS Console Click Services and Type IAM
Click Roles and Create Roles
Chose Lambda under Common use cases Click Next: Permissions
In Filter policies type LambdaFull and check AWSLambdaFullAccess
Next:Tags
Next:Review
Rollname type myLambdaRole Click Create
You now have a Role that can be assigned to your lambda function
Now create your Lambda Function
In the AWS Console Click Services and type Lambda
Click Create Function
Function name type translateTableLookup
Runtime choose Node.js and Create function
Click on the translateTableLookup function to edit the Lambda function
In the Function code portion paste this code into the index.js file:
var AWS = require("aws-sdk");
var docClient = new AWS.DynamoDB.DocumentClient();
exports.handler = (event, context, callback) => {
var key = event.Details.Parameters.key;
console.log("Parameter key passed:" + key);
var params = {
TableName: 'translateTable',
Key:{
"key": key
}
};
docClient.get(params, function(err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
console.log(err);
callback(null, buildResponse(false));
}
else {
//DynamoDB Query Results: {"Item":{"key":"Flag1","description":"description of Flag1","value":"true"}}
console.log("DynamoDB Query Results:" + JSON.stringify(data));
if (data.Item.key == undefined) {
console.log("Key not Found in translateTable: " + key);
var recordFound = "False";
callback(null, buildResponse(true, recordFound));
}
else {
var recordFound = "True"
var key = data.Item.key;
var value = data.Item.value;
var description = data.Item.description;
callback(null, buildResponse(true, recordFound, key, value, description));
}
}
});
};
function buildResponse(isSuccess, recordFound, key, value, description) {
if (isSuccess) {
return {
recordFound: recordFound,
key: key,
value: value,
description: description,
lambdaResult: "Success"
};
}
else {
console.log("Lambda returned error to Connect");
return { lambdaResult: "Error" };
}
}
Next create a flow to speak back the value of Flag1 or play an error
In Amazon Connect Contact Flows click Create Contact Flow
Name the Flow: InboundTranslateTable
Drag on the Canvas:
Set logging behavior
Invoke AWS Lambda function
Check contact attributes
2 Play Prompts
Disconnect / hang up
Your flow should look like:
Before you can Invoke an AWS Lambda function in a contact flow you have to give Amazon Connect permission to invoke them.
Go to the Amazon Connect Home from the Services Menu
Click on your Instance Alias (Your Call Center)
Click on Contact Flows and Scroll to AWS Lambda
In the Function drop down list choose translateTableLookup and click +Add Lambda Function
Your Lambda function can now be invoked in an Amazon Connect Contact flow.
Back in the Contact Flow: Inbound Translate Table
Click on the Invoke AWS Lambda function:
Click Select a function and choose the translateTableLookup
For Function input parameters choose Use Text with
Destination key: key
And Value as Flag1
Click Save
Click on Check contact attributes and select
Type -> External
Attribute: lambdaResult
Conditions to check
Equals Success
Click Save
Draw the connection from = Success to the Top Play prompt
Draw the connection from No Match to the Bottom Play prompt
Click on the top play prompt
Click Text-to-speech or chat text
Click Enter text and copy and paste the following:
Translate Table Test.
The key name is $.External.key.
The value is $.External.value.
And the description is $.External.description.
Goodbye.
Click Save
Click on the bottom play prompt
Click Text-to-speech or chat text
Click Enter text and copy and paste the following:
We're sorry, an error occurred. Goodbye.
Click Save
Save and Publish your Contact Flow Inbound Translate Table.
Assign this flow to a phone number and call and test!








Caesars Palace Hotel & Casino - Mapyro
ReplyDeleteCompare reviews, 삼척 출장샵 photos & ratings for Caesars Palace Hotel & Casino in Las 제천 출장마사지 Vegas, NV 화성 출장마사지 - view the ✓menu, ⏰hours, 나주 출장샵 ☎️phone number, ☝address and 당진 출장안마 map.
Casino of Chance | 100% Welcome Bonus + 100 Spins
ReplyDeletePlay the latest free casino bonus 먹튀검증소 offers for 유출 픽 you. Play casino games and 토토 검증 win real money and get 메이저놀이터 리스트 샤오미 100 Welcome Spins - no deposit bonus! 토토 사이트 홍보 샤오 미