I am dev'ing a project where someone creates an event, and a group of people get an sms message inviting them. I want the recipient to be able to rsvp via sms. So if they respond "yes" I want to know what event_id they are responding to0.
I am passing a:
"statusCallback" => "https://cbd5-67-183-175-137.ngrok.io/receive-note/12345"
(not a real event id, just testing)
I don't care about the message status at this point, just if a response comes in. What parameter can I pass to the create message call that will allow me to dynamically track what event this invite was for? Is it a webhook or some kind of grouping?
Twilio developer evangelist here.
There is no concept of replying to a specific message in SMS, messages are just chronological.
The statusCallback URL for an SMS will only report on the status of the message you are sending to the end user, from queuing the message to be sent all the way through to delivery.
When a user sends an SMS to your Twilio number it triggers the incoming message webhook.
The incoming message webhook has no connection to an outbound message at all. So you will have to work out what message you think the user is replying to. A simple way to do this is to assume that they are replying to the last message you sent to them or the last event invite.
You are probably already considering what might happen if a user is sent invites to more than one event at the same time. How can you distinguish which event they are replying about. You have a couple of options here.
You can only ever send one SMS about an invite at a time, up until a timeout of sorts. That way, when a user replies you can always assume it's about the latest message.
Or, you can send invite message from different Twilio numbers. If you then store the outbound number with the invite you can look up replies based on the user's number and the number they replied to and calculate which invite they are responding to. To achieve this, you need more than one Twilio number, but you should only need as many numbers as the maximum estimated number of events a user might be invited to at one time.
Finally, you could ask the user to include an event ID or similar in their reply which you can then parse out, but this is likely to be a difficult ask of users.
This exists in SendGrid and is very useful. I don't understand how it's not implemented in Twilio.
Related
By default, Twilio trial accounts can only send SMS to numbers that are listed as Verified Caller IDs in the Twilio console. These numbers have to be added manually, and require a verification message before they can receive SMS. This is an excellent feature for development, as it prevents accidentally sending SMS to wrong numbers.
My problem, is that I am developing for a client whose account is already out of trial status. I don't want the software in development to be able to send text messages to any number, because there is a risk of sending dev messages to the client's actual customers. However, we need to be able to send to some numbers for testing. Is there any way to turn the trial behavior back on? That is, can we somehow configure Twilio to only allow sending SMS to verfied numbers, even if it is not a trial account?
If this isn't possible, I think I can query the Outgoing Caller IDs resource from my program to verify the recipient number against the list before sending. However, this puts the responsibility back on my development team, and the possibility for mistakes remains. I'd like to be able to block the behavior at the Twilio level.
This behavior is only applied for trial accounts, however I'll pass this feedback on internally.
You'll need to replicate this behavior yourself for your applications using an upgraded account.
As you mentioned, you can query the Outgoing Caller IDs to get the phone numbers you have already verified with Twilio and use that as an accept list.
However, for your use case, you can store and fetch the accept list using whatever way is most convenient for you, like in code, file, database, etc.
Depending on your needs, you could embed this logic directly into your app, or use a single shared library, or create a web API that all other apps have to use to send texts.
Good luck! We can't wait to see what you build!
Update after getting internal feedback.
You can create a new trial account, even with the same Twilio profile, which would give you promotional credits and the same verified Caller ID limits again.
The promotional credit should last you a long time for test scenarios.
I would like to build an app with twilio that requires to send the same message to 10 people at the same time.
However, on the documentation it is said:
Sandbox numbers are restricted to 1 message every 3 seconds.
So, does it mean that if I send the text: "Hello" to then person, the last person will receive the text after 30 seconds or so?
Yes, You're restricted to send a message at a time.
One thing, If you are using Twilio's WhatsApp sandbox then you can't send a free-form message like "hello". You can only able to use their pre-approved message template.
There are 2 reasons:
You are trying to send a message to a user who has not joined your sandbox.
You are sending a free form message outside the WhatsApp session to the user. A WhatsApp session lasts for 24 hours after the last inbound message you receive from a user. Outside a WhatsApp session, you may only send a pre-approved template message to the user, any message that doesn't match a pre-approved template will be sent by Twilio as a free form message. See a list of templates pre-approved for the sandbox here!.
For more details, you can see this FAQ https://www.twilio.com/docs/whatsapp/best-practices-and-faqs#sandbox
I have purchased two numbers from twilio one is for UK and the other one is for US.But when I try to send an SMS to that number from an Indian number.I get the response on a different thread.I want to get a response on the same thread so that my bot and the user have conversation on the same thread
Twilio developer evangelist here.
I'm afraid that in the Indian market we are currently forced to work under some restrictions. One of which is:
The sender IDs are changed to the format “XX-NNNNNN”
The sender IDs are altered before SMS messages are delivered to end
users. End users are very likely to see a sender ID composed of 2
letters followed by 6 numbers instead of the Sender ID you specified.
Due to the sender ID change, SMS recipients are unable to send a reply
back to your Twilio phone number.
Unfortunately that means that bot style conversations aren't currently possible in India.
I have got a trial account on Twilio with a free number. When I send an SMS through the Rest API I do receive the SMS, but from a different number than the one I have been assigned.
Is this so because of the trial? Will it be fixed when I upgrade my account?
I need the users to be able to reply back with the message to the same number they received the SMS from.
Twilio developer evangelist here.
My guess is that you are sending messages to a country that doesn't support maintaining the original sender ID. I see from your profile that you're from Pakistan, you can check out the guidelines for sending SMS to Pakistan here.
As you can see from the support table, we can't guarantee that your Long Code (that is the phone number) sender ID is preserved and Two Way SMS is not supported.
So, this is not due to your trial account, but limitations with sending SMS messages into Pakistan.
Is there a way create a group SMS with the twilio API, just like how I can send an SMS to two contacts on my phone and have the conversation saved in one chat log?
Basically if I have an SMS sent to a twilio number and another person could twilio see that it was sent to them as well as the other person?
It is not possible to send one message to multiple recipients with a single request. you can send only one single SMS with one request. So you can iterate through the array of phone numbers to send SMS.