Last active
May 13, 2017 17:46
-
-
Save gittimos/b549adce612236d1db50279e20107000 to your computer and use it in GitHub Desktop.
Using the AWS Lex API with the AWS SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let AWS = require('aws-sdk') | |
let credentials = new AWS.SharedIniFileCredentials({profile: 'default'}); | |
AWS.config.credentials = credentials; | |
AWS.config.update({region: 'us-east-1'}); | |
let lexruntime = new AWS.LexRuntime({ | |
apiVersion: '2016-11-28', | |
}); | |
let params = { | |
botAlias: '$LATEST', /* required */ | |
botName: 'BookTrip', /* required */ | |
inputText: 'I want a make hotel reservations', /* required */ | |
userId: '4o9s3dhx6nlhe038dbn3s3fujd3118f5w', /* required */ | |
sessionAttributes: { | |
someKey: 'STRING_VALUE', | |
/* anotherKey: ... */ | |
} | |
}; | |
lexruntime.postText(params, function (err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment