I want to test my if else condition in the Twilio function.
The condition is if the user will text "Hi", Twilio will send him a quote.
The problem the condition always runs false even if I texted "Hi".
I'm not sure if the event.Body
is the right code to get the value of the message body.
exports.handler = function (context, event, callback) {
const got = require('got');
got('https://cyan-sparrow-7490.twil.io/assets/quote.json').then(response =>{
let messageBody = event.Body;
const qotd = JSON.parse(response.body);
let quote = qotd.contents.quotes[0];
const quoteEffect = messageBody === "Hi"? callback(null,quote): callback(null,null);
callback(null,quoteEffect);
});
};