Reputation: 194
I am using messaging (whatsapp and texting) with Twilio. I am having an issue with the message queue. Today I only sent 3 messages, but I had 20,000 failed messages per hour with error indicating bad "To" phone numbers. There are 22 distinct numbers (based on spreadsheet export of the page displaying the failures). I have fixed the numbers on my end, so I believe these must be old messages in the queue and/or retries.
My question is: as far as we know, our app is not retrying. We are trying to understand what's happening and fix this before we start getting billed for failed messages in a couple weeks. Does anyone here on stack exchange know if there is a twilio setting for retries and how to disable it? And has anyone had any luck/advice for easily clearing out the WHOLE message queue at Twilio? Thanks in advance for any help.
I have web only support with twilio and I tried opening a support ticket. I have seen in other stack exchange posts (e.g. Clearing/Deleting messages in Twilios SMS Message Queues) where people said that twilio cleared the queue for them, but when I asked for help doing that in the ticket they can't do that for me and I have to do it myself programmatically, one message at a time (e.g. iterate).
Regarding retries:
They sent me conflicting information about setting "autoRetry" but it didn't make sense. First they wrote: Disable Automatic Retries example: const accountSid = process.env.TWILIO_ACCOUNT_SID;const authToken = process.env.TWILIO_AUTH_TOKEN;const client = require('twilio')(accountSid, authToken, { autoRetry: false,});
Then when I said I couldn't find anything about autoRetry they wrote:
Twilio does not have a direct autoRetry setting for messages, but you can manage retries through your application logic. If you are using a Twilio helper library, you can set retry policies there.
For example, in Node.js:
Copy code blockconst accountSid = process.env.TWILIO_ACCOUNT_SID;const authToken = process.env.TWILIO_AUTH_TOKEN;const client = require('twilio')(accountSid, authToken, { autoRetry: false,});
Regarding clearing the message queue:
Also they said I understand that you are looking for a way to clear out all queued messages directly from the console.
Currently, clearing queued messages can only be done programmatically via the API. Here is a sample code snippet to help you clear out all queued messages:
Copy code blockconst accountSid = process.env.TWILIO_ACCOUNT_SID;const authToken = process.env.TWILIO_AUTH_TOKEN;const client = require('twilio')(accountSid, authToken);client.messages.each(message => { client.messages(message.sid).remove() .then(() => console.log(`Deleted message ${message.sid}`)) .catch(error => console.error(error));});
Or with Curl :Copy code blockcurl -X DELETE "https://api.twilio.com/2010-04-01/Accounts/[REDACTED ACCOUNT_SID]/Messages/[REDACTED MESSAGE_SID].json" \--user "[REDACTED ACCOUNT_SID]:[REDACTED AUTH_TOKEN]"
Then they wrote this, but which I don't understand and have asked for clarification about: We can stop the queue on our end enabling a flag, but when the flag "Fail all Outbound SMS" is enabled, Twilio will dequeue any existing or new messages directly to "failed" status until we remove it.
Upvotes: 0
Views: 198
Reputation: 194
It turns out our app is indeed retrying. We are going to try to tighten up our code to validate numbers before trying to send. And to not retry failed messages automatically.
Upvotes: 0
Reputation: 1
Dang...I'm having a very similar thing happening to me right now with Twilio...except they have tried to send over 300K Texts and I'm getting billed!!! I've opened a ticket, but Twilio is super slow to respond. I've asked them to remove the queued Texts. (I've waited to post this for a couple hours because of trying to deal with this...) Here was their initial response: "we can't stop messages for an specific number, but for the entire account, so I did it on that way, let me know if you need me to re-enable it. Also, let me know how was that loop generated, there is no bug on our side generating automatic messages, so you need to double check your code to stop any loop request before we can enable your outbound SMS again." I'll be digging into this deeper with my team, but from what we see this is a Twilio bug. Twilio has been VERY buggy in the last few months and this has been their worst bug! Also, it can't be coincidental that just today (when all this was happening), Twilio notified us and said "The verification status for XXX-XXX-XXXX is approved. You can now send messages to any OTP verified phone number as a destination." This number has been verified for over a year and has successfully sent Texts since. Today was the first issue with this number queuing and attempting to send the 300K+ Texts. Super frustrating and I'm looking at alternative SMS Gateways...
Upvotes: 0