Closed AutomataVM closed 5 years ago
this code should be changed, from:
controller.hears('.*','message', (bot, message) => {
console.log('recibi el siguiente mensaje: ');
console.log(message);
bot.reply(message,'recibi el mensaje fuerte y claro');
});
to:
controller.hears('.*','message',async (bot, message) => {
console.log('recibi el siguiente mensaje: ');
console.log(message);
try {
await bot.reply(message,'recibi el mensaje fuerte y claro');
} catch(err) {
console.log('ERROR FROM TWILIO', err);
}
});
to
Note the async
and await
ah, it was so easy after all! thank you for the tip on the try catch code. Still I receive the same output when the bot.reply line gets executed:
(node:9388) UnhandledPromiseRejectionWarning (node:9388) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:9388) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre cated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
could it be something on twilio's end? I configured both webhooks for the whatsapp option and the phone number I am using towards my ngrok server in this way:
seems like it is something on twilio's', I keep getting this error
Error - 11200
Properties DEBUG EVENT SID NOe074bd2d2d32e55a467689617c8b6fff SERVICE SID RESOURCE SID SMfc372db44f9d9ec2311a1d5954e61075 TIMESTAMP 2019-08-16 12:08:10 UTC MESSAGE The URI scheme, of the URI null, must be equal (ignoring case) to 'http', 'https', 'ws', or 'wss'
not sure what it means though, guessing it is related to the url of the webhook
edit: it is not webhook related I think, changing it back to the https:// makes it work, maybe I am missing something in the bot.reply function??
What is the format of the message you are sending back to Twilio?
Is there a URL in it?
pretty sure it is the same as format the message parameter in the hears callback. Here's a bit of it:
{ SmsMessageSid: 'SM83f047ab14a65e47445fd4591863c1f0', NumMedia: '0', SmsSid: 'string', SmsStatus: 'received', Body: 'dasdas', To: 'whatsapp:+number', NumSegments: '1', MessageSid: 'string', AccountSid: 'string', From: 'whatsapp:+number', ApiVersion: '2010-04-01', type: 'message', user: 'whatsapp:+number', text: 'dasdas', channel: 'whatsapp:+number', value: undefined, reference: { activityId: 'string', user: { id: 'whatsapp:+number' }, bot: { id: 'whatsapp:+number' }, conversation: { id: 'whatsapp:+number' }, channelId: 'twilio-sms', serviceUrl: undefined }, . . . .
there's a serviceUrl field that is undefined, otherwise no URL
did you got any leads to it? regardless of the url, the main problem is that I can't catch the exception thrown.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has not been solved!
Twilio should solve this issue
I am also facing the same issue when using Java + Twilio to send message on whatsapp. message reaches to application but fail during response
once had the same problem and the solution is to sign up on the ngrok website then grab the auth token key and synchronize it with the ngrok on your machine .It should work
Hello! I was using the botkit package to make a simple chatbot using nodejs, Twilio and Whatsapp. I can receive messages from Whatsapp on my application just fine, the problem is when I try sending a reply to that message using bot.reply. The message that appears on the console output whenever the controller hears the message is:
The problem seems to be a missing catch block, though I don't know where it is supposed to be, inserted into, the controller? the bot.reply?
Here's my code:
I use ngrok to set up a server that can be accesed from outside. Afterwards, I configured the webhooks inside the phone numbers and whatsapp webhook. Also, I am using the whatsapp phone number instead of the trial number for the Twilio settings.
What was the result you received?
UnhandledPromiseRejectionWarning message
What did you expect?
the message to appear in the whatsapp conversation