Skip to content

Instantly share code, notes, and snippets.

@gittimos
Last active May 13, 2017 17:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gittimos/b549adce612236d1db50279e20107000 to your computer and use it in GitHub Desktop.
Save gittimos/b549adce612236d1db50279e20107000 to your computer and use it in GitHub Desktop.
Using the AWS Lex API with the AWS SDK
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