how to send more than ten messages via Twilio - twilio

I currently have developed a REST API that Twilio posts when an incoming message comes to a short code. Sometimes the reply message can have more than 10 sms messages and it looks like Twilio has a limit for the reply message as I see error in the Notification logs mentioning that it cannot send more than 10 messages. So what is the best way to get through this error?
Should I call the Twilio API for sending out the messages instead of using the Twilio Response? If so what should my HTTP response be? Little confused on what response should I be sending for the HTTP Response. Please advise.

I would just send nothing as the response, but use the opportunity to send out the 10+ messages using the twilio api.
Alternatively, send the first messages as the response and that send the 9+ immediately after as a new conversation.

Related

Not Receiving Twilio message using conversation API in rails

I am working on Twilio conversation API and trying to implement a custom solution. Outbound messages are working perfectly. But the problem is I am unable to receive a message. When I send a message to Twilio trial number from my mobile phone, it shows the status as sent, but I don't know what's going on and why I am not receiving that message in my controller as i have already added a global conversatioin webhook for onMessageAdded filter. Here is my route:
support_webhooks_messages_incoming POST /support/webhooks/messages/incoming

Twilio SMS: Is there a way to recognize status updates from SMS generated with SMS API vs TwiML <message/> responses?

My service is sending SMS to users in two different ways:
The main one is the SMS API, my service sends a request to Twilio with all the SMS data, and get the SMS id in the response. With that id it waits for the sms status updates to check if the text was delivered.
But there is another way, as a response to a user sending a text to my service, using a TwiML <message> in the Response. In this case, I send back a SMS to the user, but there is no SMS id to check for status updates (because the service sends the text in the response, not in the request).
So in this scenario, there are status updates from SMS ids that the service can not recognize.
My question is: is there a way to get the SMS id from TwiML <message>s? Or be able to recognise which status updates come from TwiML messages?
Or my only way to do this is to always call the SMS API and do not return a text using TwiML for this scenario?
Thanks in advance!
Twilio developer evangelist here.
The way to get an SID from replying to a message using <Message> is to wait for the status callback webhook. Of course, as you say here, when you reply that way you don't store the details of the message in your system. What you could do is wait for the first status callback webhook and if you find a message SID that you don't already have in your system, use the REST API to look up that message, save the details and be prepared for further status callbacks.
Alternatively, there is nothing wrong with using the REST API to send the message instead of <Message> and just returning an empty <Response> to an incoming webhook.

Twilio not sending webhooks in Progammable Chat

I would like to ask a question or maybe report a bug after solving my doubts. I started working with Programmable Chat and Twilio do not want to send a webhook to specific url but only when I'm sending message from my PHP code. I downloaded example node app and sending message from that, everything is working really nice, I'm getting post request from Twilio but if only I will send message from PHP, nothing at all. And strange is, after sending message from PHP, it will appear immediately in chat which means that it's working.
How does it possible? Could it mean that Twilio on theirs backend has an a bug when they receive message from PHP and becuase of that they are not fire webhook event?
I eliminated all differences, everything is that same beside that one message is sending from PHP and another from node. Same situation from API Explorer.
Gif presentation
Twilio developer evangelist here.
When you send messages to Programmable Chat from the REST API then webhooks aren't triggered. I think the reasoning is because you are making the call from your server, then your server is already aware that you are sending a message and you don't need to receive a webhook to do so. It also saves from the potential of infinite loops (if your webhook sends a message via the REST API, the requests would just go in circles).
So, it's not a bug, but a design choice. If you need to trigger your webhooks when you send a message from the REST API, you will need to make the webhook from your own server.

How to find relation between send and received message in twillio

I am using Copilot API of twillio to send sms. so i am able to send sms to end user. Now if user reply to that sms, i am receiving the callback (PHP Script). Using that callback URL, i am able to get the reply message.
Now i want to do is, i am trying to find a relation between sent and received(which end user reply) message. so i can then forward the reply message to their sender.
I will have UI like below, where user enter the message and number where he wants to receive reply.
But the problem is i am not able to find relation between send/receive message.
Any advice will be helpful.
Twilio developer evangelist here.
Other than storing the information on your server upon sending/receiving a message, you could make use of the cookies stored at Twilio.
When Twilio makes a request to your server and it returns a cookie (a Set-Cookie HTTP response header), Twilio stores this cookie and associates it with the From and To numbers for the incoming call or SMS message.
A little caveat to this is the fact that this cookie is only stored for four hours, so unless that works for you, I'd suggest using the from & the to as composite keys to find a relation.
Hope this helps you

Twilio is sending their own messages for Start/Help and Stop instead of using our API reply message

Our database shows that we are sending reply messages to Twilio for START/STOP and HELP message. But when we send a text for the above messages we are getting responses from Twilio instead of our REST API Web Service response. How do we make Twilio send our responses instead of twilio response?
This seems to be working fine during the testing phase and seems to be something new after our API went Live. How do we fix this? This is causing issues as we activate/deactivate a number based on START/STOP text and that is not happening when Twilio is sending their own message as our users have to follow some procedure after they send a STOP text. Even the HELP text is not coming to our web service and instead Twilio is sending a default Help text from their side.
You need to contact Twilio via support and ask them to turn their opt-out processing off.

Resources