Created
August 29, 2019 04:41
-
-
Save CPsridharCP/c95133678232039b1268f6a9e793e314 to your computer and use it in GitHub Desktop.
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
exports.handler = function(context, event, callback) { | |
var parameter = event.CurrentInput.substr(event.CurrentInput.indexOf(" ") + 1); | |
console.log(parameter); | |
const replySms = parameter != 'You are amazing !' ? {"actions": [{"say": "[••] Speaking "+parameter+"!"}]} : {"actions": [{"say": "[••] Sorry i did't understand, What should i say again"}]} | |
const replyErrorSms = {"actions": [{"say": "[••] Oops an error occured, Could you please try again.."}]}; | |
const axios = require('axios') | |
axios.post('https://<lambda-api-gateway-endpoint>.amazonaws.com/default/<function-name>', { | |
'text': parameter | |
}) | |
.then((res) => { | |
console.log(res.data); | |
callback(null, replySms); | |
}) | |
.catch((error) => { | |
console.log(error); | |
callback(null, replyErrorSms); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment