Skip to content

Instantly share code, notes, and snippets.

@melvinlee
Created April 19, 2018 13:34
Show Gist options
  • Save melvinlee/c693bc678b1f2a62df804765bfc9d489 to your computer and use it in GitHub Desktop.
Save melvinlee/c693bc678b1f2a62df804765bfc9d489 to your computer and use it in GitHub Desktop.
Lex Responses Helper
module.exports.delegate = function(sessionAttributes, slots) {
return {
sessionAttributes,
dialogAction: {
type: 'Delegate',
slots
}
};
};
module.exports.elicitSlot = function(sessionAttributes, intentName, slots, slotToElicit, message, title, imageUrl, buttons) {
return {
sessionAttributes,
dialogAction: {
type: 'ElicitSlot',
intentName,
slots,
slotToElicit,
message,
responseCard: getResponseCard(title, imageUrl, buttons)
}
};
};
module.exports.close = function(sessionAttributes, fulfillmentState, message) {
return {
sessionAttributes,
dialogAction: {
type: 'Close',
fulfillmentState,
message
}
};
};
module.exports.confirmIntent = function(sessionAttributes, intentName, slots, message) {
return {
sessionAttributes,
dialogAction: {
type: 'ConfirmIntent',
intentName,
slots,
message
}
};
};
function getResponseCard(title, imageUrl, buttons) {
return {
contentType: 'application/vnd.amazonaws.card.generic',
genericAttachments: [
{
title,
imageUrl,
buttons
}
]
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment