Skip to content

Instantly share code, notes, and snippets.

@CPsridharCP
Created August 29, 2019 04:41
Show Gist options
  • Save CPsridharCP/c95133678232039b1268f6a9e793e314 to your computer and use it in GitHub Desktop.
Save CPsridharCP/c95133678232039b1268f6a9e793e314 to your computer and use it in GitHub Desktop.
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