Skip to content

Instantly share code, notes, and snippets.

@jonchurch
Last active September 27, 2018 10:09
Show Gist options
  • Save jonchurch/f83fdf8a942dd53a58179aa489396976 to your computer and use it in GitHub Desktop.
Save jonchurch/f83fdf8a942dd53a58179aa489396976 to your computer and use it in GitHub Desktop.
Valid ElicitSlot AWS Lex Lambda response
'use strict';
exports.handler = (event, context, callback) => {
// Currently all possible fields
// {
// "sessionAttributes": {
// "key1": "value1",
// "key2": "value2"
// ...
// },
// "dialogAction": {
// "type": "ElicitIntent, ElicitSlot, ConfirmIntent, Delegate, or Close",
// "fulfillmentState": "Fulfilled or Failed",
// "message": {
// "contentType": "PlainText or SSML",
// "content": "message to convey to the user"
// },
// "intentName": "intent-name",
// "slots": {
// "slot-name": "value",
// "slot-name": "value",
// "slot-name": "value"
// },
// "slotToElicit" : "slot-name",
// "responseCard": {
// "version": integer-value,
// "contentType": "application/vnd.amazonaws.card.generic",
// "genericAttachments": [
// {
// "title":"card-title",
// "subTitle":"card-sub-title",
// "imageUrl":"URL of the image to be shown",
// "attachmentLinkUrl":"URL of the attachment to be associated with the card",
// "buttons":[
// {
// "text":"button-text",
// "value":"value sent to server on button click"
// }
// ]
// }
// ]
// }
// }
// }
// This is all that is required for a valid ElicitSlot response
var dummy = {
"sessionAttributes": {},
"dialogAction": {
"type": "ElicitSlot",
"intentName": "ScheduleRequest",
"slots": {
"MusicGroup": "null"
},
"slotToElicit": "MusicGroup"
}
}
// Respond to Lex by passing a proper JSON response to callback
callback(null, dummy)
};
@jonchurch
Copy link
Author

Here ScheduleRequest is the intent this function is being called in, and MusicGroup is a slot of the type AMAZON.MusicalGroup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment