0

My code:

const client = require('twilio')(accountSid, authToken);
const issueResolution = 'Hi Malcolm, were we able to solve the issue that you were facing?';

client.messages
      .create({
         from: senderNumber, 
         body: issueResolution,
         to: receiverNumber,
       })
      .then(message => {
        console.log(JSON.stringify(message , null, 2));
      });

The body of the message conforms to the "sample_issue_resolution" WhatsApp template shown in the Twilio web console (at https://console.twilio.com/us1/develop/sms/senders/whatsapp-templates).

I can successfully use the above code to send a message to a number which has opted in to my Twilio WhatsApp sandbox. If I try to send a message to another number which has not opted in to the sandbox, there's no error message, but the message is never received. I get the same results when I use one of my custom approved templates. What could be going wrong / how can I debug this?

fblundun
  • 987
  • 7
  • 19

1 Answers1

0

I'd assume that this message is not matching any of your templates. There could be multiple reasons, such as a different whitespace character or a typo that differentiates both strings.

The Message Log should tell you why a message couldn't be delivered.

IObert
  • 2,118
  • 1
  • 10
  • 17
  • Thanks @IObert. I don't see any mismatch with my template. When I view the error logs for the last 30 days at https://console.twilio.com/us1/monitor/logs/debugger/errors I don't see any logs for failed message deliveries - even if I deliberately try sending a message which doesn't conform to any template. (I do see logs for earlier "template rejected" events from my previous failed template submissions.) Sounds like it's unexpected that I don't see errors here for messages which weren't delivered? – fblundun Feb 09 '23 at 17:32
  • 1
    So you don't see the message at all? That's weird. Is it possible that you're using another account? Otherwise, please reach out to support to find out why the messages are not showing in the log. – IObert Feb 09 '23 at 18:21
  • Ah, turns out I was looking at the "Errors" log page when I should have been looking at the "Messaging" log page. Once I looked at the correct logs I worked out that the problem was caused by me using a Twilio Sandbox number to send messages rather than using the new sender number I bought. – fblundun Feb 10 '23 at 13:35