Rocketchat adding a name to incoming Twilio SMS numbers - sms

With Rocket.chat and Twilio - the incoming chat 'user' is just a mobile number. This is not very user friendly if multiple conversations are ongoing. Responding to and tracking conversations by name and not phone number is much better if possible.
I have a database that could be used to match the incoming SMS phone numbers to a human name for most of my expected incoming SMS IM's. Trying to figure out the best way to do a lookup and add that to the Twilio # identity so that the 'chat' makes more sense to the in-house user who would be using it.
Appreciate any ideas anyone might have that would save me from re-inventing the wheel w/ Twilio and Rocket.Chat.
Related to RocketChat: How to send SMS Messages to Livechat channel from mobile

Twilio developer evangelist here.
I have not used RocketChat for this before, I just took a look through the code to see what I could find.
Turns out, RocketChat has a field for phone number on the user model and when an incoming message is received it looks up a user from their phone number. If the user is found, the message is sent from the user, otherwise a new user is created.
So, what you need to do is merge your database of usernames and phone numbers with the RocketChat User model.
Hope that helps!

Related

Pass a unique ID with Twilio HTTP POST

I am currently using Twilio to send balance notifications for customers who have opted into SMS notifications, but have run into an issue in positively identifying accounts in the message logs. A number of customers have multiple accounts due to the nature of my industry, but naturally use the same phone number across all accounts. Is there any way to pass a parameter containing their internal account ID in the HTTP POST request without including it in the message body? I've searched extensively through Twilio's API docs and cannot find this addressed anywhere.
Twilio developer evangelist here.
As far as I know there is currently no way to store metadata, like your account ID, within an SMS sent via Twilio.
One idea could be that you purchase a number of Twilio numbers and tie together a user's phone number, a Twilio phone number and the specific account. That way, if you always send balance notifications for a specific account from a specific number then you can identify that message in the logs as belonging to that user phone number for that account.
Alternatively, I'd have thought it would be useful for users, if they have more than one account, to see to which account you are referring in a balance notification. Would it be possible to include the account id (or some other identifier that the user would recognise) and then parse that out of the message when reconciling messages and accounts?
Not exactly the question but if you are using twilio webhooks for status callbacks you can pass query string params through the status_callback parameter when making the call to send the SMS message and get it sent to your endpoint

Connecting a 'sent' SMS to a 'received' SMS

I have built an app that sends out an SMS using the twilio number(the one assigned to me) when a message is sent I receive the SID number which is inserted into the db, along with some other general information, however I do not know how to connect the received SMS SID to the sent SMS SID that tells the system that user has responded....how does someone connect the outgoing message to what is received?
UPDATE:
Hello Devin, Thanks for the response! however, this does not help me much as I might send lets say one of three different people multiple messages in an hour.
my app is a notification app...basically it is a form that a user fills out with some basic info. one of these fileds they choose is a drop down of three different people(who the message will go to) they send the message. my app then inserts the form data explained above along with the SMSID that is returned by you guys into a DB.
the user(one of the three people descibed above) that was sent the notification above responds to the message, meaning that Twilio hits my "Request URL" and I save all the information that is returned by the user...however, and where the problem actually lies is that the SMSID for that reply is not the same as the SMSID of the sent notification...therefore I have no way to connect the SMS that was sent to the user with their response. I have looked at the cookies option and that is not what I am needing...actually your documentation actually acknowledges this issue but does not offer a solution as seen here under "Application Initiated Conversations"
https://www.twilio.com/blog/2014/07/the-definitive-guide-to-sms-conversation-tracking.html
So if you know of a way around this, I would love to hear it for sure :)
Twilio evangelist here.
The SMS protocol has no concept of a "conversation". Each message sent is unique and has no knowledge of messages sent before or after it. Twilios SMS Sid is simply a unique identifier for an individual message.
The typical way to solve this is to use the To/From phone number pair as the unique identifier of an SMS conversation. When you send your first outbound message, store the To/From phone number in your database. When the user replies Twilio will tell you what number they sent the message to and from and you can use that information to look up the original outbound message in your database.
If a "user" can be involved in several different conversations at once you either need to use a unique phone number for each seperate conversation (allowing you to use the technique above), or you need to have the user include some type of conversation ID in their reply (which you can use as the unique identifier).
You can buy a pool of numbers and as each conversation "ends", recycle the number for a new conversation.
Hope that helps.

Can the SMS forwarding number be removed from the reply using Twilio's to forward SMS messages to another phone number?

I want to use Twilio to create an SMS relaying service where the Twilio number is the only number that is exposed, much like web proxy servers that allow you to access the Internet anonymously. I've used the example php code that twilio provides, saved it to a php file and hosted it on a public web server, then updated the messages URL on the Twilio site accordingly. Any message sent to the Twilio number the is forwarded to my mobile. Everything works fine, except for the fact that when I reply to the forwarded message from my phone, the reply includes a header that says "Sent from your Twilio trial account - + mymobilenumber" I understand that the header is inserted because I have a trial account, however I don't want the mymobilenumber field to be exposed. Is it possible to hide this?
I should mention I'm not really a programmer but I'm learning with Twilio.
I followed the example given here:
https://www.twilio.com/help/faq/sms/how-do-i-forward-my-sms-messages-to-another-phone-number
Thx
Antonio
A short code is a 5 or 6-digit number that can send and receive messages with mobile phones. These high-throughput numbers are perfect for apps that need to send messages to lots of users or need to send time sensitive messages. You can buy shortcodes from Twilio or port existing short codes to our platform.

Twilio SMS verify destination phone numbers and verification ID

I have two questions.
I am creating a website for a client I am trying to code in Twilio SMS tools for end users and for management. I have the request and response tools built so I am all set functionally. So the questions are:
A. Can I send SMS message to any phone number OR does every number I send an SMS have to be added to twilio and verified before I can freely send SMS? It would be nice if I could just collect my phone numbers from the end users and free them from the pain of the verification process.
B. If I must verify end users then can I send SMS messages to them with their verification code? Right now an automated message call is sent to the phone number that wants SMS updates and you have to key in a six digit verification code....AND then you can send that person SMS messages. The phone call is kind of awkward.
A. Once you have a regular Twilio account, you can send an SMS to any phone number. However, some phone numbers (e.g., most landlines) cannot accept an SMS. If you try to send an SMS to those numbers with your cellphone, you will probably get a message back from the carrier that the number cannot accept SMS. However, Twilio will report success in sending the message, even though the message obviously cannot be sent to that number, and you will get no indication that the message did not go through.
But, no, there is no need to specifically add the numbers as verified for them to work with Twilio.
You can use a service like https://www.carrierlookup.com/ (which Twilio told me about) to check if a phone number can receive SMS messages.
B. -- you do not need to verify end users through Twilio, although I do think there are restrictions on a Twilio trial account that will be removed once you have a paid Twilio account.
Twilio evangelist here
Once you upgrade, you can send a message to any phone number. While you are using a trial account, you have to verify a number in order to send a message to it. More info about how a trial account works is here:
http://www.twilio.com/help/faq/twilio-basics/how-does-twilios-free-trial-work
Hope that helps.
Regarding verification: Twilio has a service that allows verifying phone numbers, including format, carrier, if it's mobile or landline, etc: https://www.twilio.com/lookup
API Docs: https://www.twilio.com/docs/lookup/api

Providing context for SMS

I'm trying to figure out how to set up an SMS service where users can communicate with people on phones that are not participating in my service. "TextFree" on iPhone does something like what I want to do. They let you sign up, then you can send messages for "free" to other friends that aren't part of the service.
It looks like when you sign up for TextFree, they assign you an email address [user#textfree.us]. People outside the service without MMS capabilities can't send an SMS to this user. The user must first send an SMS to them, starting a conversation. I think this is what they're doing:
Textfree signs up for an account with a bulk SMS provider, and is assigned a single phone #, like "123".
Joe signs up for TextFree, gets assigned email: joe#textfree.us.
Mary wants to send Joe an sms, but can't because she doesn't know what # to direct the sms to.
Joe sends an sms to Mary using textfree. This really just makes an http request to some textfree server. The server gets the request, and the destination # (Mary's phone).
The server sends the sms out using their bulk sms api provider.
Mary receives the sms, and sees the originator phone # as "123".
Mary replies to the sms, using this phone #, "123".
Their sms provider receives the message, and forwards it to textfree's http server.
Textfree now has to resolve that the sms received by Mary's phone # is destined for Joe (not sure how this can be done), so it can be delivered to Joe's account.
I think that all makes sense and seems feasible, I'm just not sure about that last step, how they could figure out which conversation sms' belong to. If all outside users are directing their sms to phone #123, how could I figure out which internal user the message is destined for? Is there some way to embed a unique identifier in an SMS, so that when the external user replies to the SMS, some unique ID can be embedded in there to provide that type of context to read on the reply side of things?
Long question, thanks for any thoughts!
As for the last part of your question (unique ID in SMS):
I know of no mechanism that could help you here. When replying to a short message phones only set the sender address as destination and the user is free to type the text. The headers in a short message PDU are solely for the basic transport parameters (encoding, sender-ID, ...). There is a way to define so called user data headers, but for this to be of any use for you, you'd have to be in control of most of the devices that are involved in the message delivery, including the handsets... So basically the only way I see to correlate messages with each other reliably is the use of some ID within the message text.
An alternate approach would be to rent a bunch of numbers and assign these permanently (I assume some subscription model here) to your users. This way you could use these as identification numbers within your service and forward the messages to their real phone numbers (or even a completely different media like email / instant messenger).

Resources