Created
April 19, 2018 13:34
-
-
Save melvinlee/c693bc678b1f2a62df804765bfc9d489 to your computer and use it in GitHub Desktop.
Lex Responses Helper
This file contains hidden or 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
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