How to retrieve User's phone number from Twilio in Bot Framework? - sms

Have the bot working just fine via SMS. Now looking for the best way to retrieve the User's phone number being used in the SMS conversation.
Seems like it should be pretty straight forward (easy to do in a native Twilio app), but just not finding the example code or way to get at it from within the Bot Framework using the C# libraries.
I played a bit with the ChannelData off of Activity, but it's not there or I'm not using it correctly.
Any pointers to relevant documentation or sample code would be tremendously helpful!

Your bot's Post handler receives a list of Microsoft.Bot.Connector.Activity when end users message the bot. Each Activity has a "From" Channel Account that contains an "Id" and "Name". You can find the Twilio phone number there.

Related

Sending a message to users as a bot in bot channel of Microsoft Teams using the Graph API

I have created a bot by following the steps mentioned in the doc.I have authenticated user using oauth 2.0 (auth code grant) as mentioned in the doc and in reverse I got a access token. But when I send message to channel in the teams using (/teams/{id}/channels/{id}/messages) API the message was sent on behalf of me. But I want my bot as the sender of message. Here is the image of the message that I have sent using the above API. and is there any way to send direct message to user as a bot?
Instead of using the Graph, there's another approach using the Bot Framework itself, to send a message to a team channel, a group chat, or a 1-1 conversation. The code doesn't even need to live inside the bot itself, it just needs to leverage the bot framework under the covers (for example, I have several Azure Functions that pro-actively message users). This idea is called "Proactive messaging" and you can read more about it in the docs here.
You do need to get certain fields when the user first installs the bot though, or any time the bot receives a message. I've described that more at Programmatically sending a message to a bot in Microsoft Teams. You haven't said what language you're using, but there are examples for a bunch of them - I can send you links if you let me know what you're using.

Automated/Bot message posting to Microsoft-Teams chat room

How can I automatically post messages to chat rooms in Microsoft-Teams? This is for one-way messaging: i.e. posting messages, not reading messages.
The big picture here is we are evaluating different Group Chat solutions, and one requirement is to post error messages to chat rooms from various services & programs.
A sensible approach seems to be to build a Bot using the REST API however just the authentication seems crazy complex, even then I can't work out how to just post a message. We're looking for a general solution that can be used simply in different scripting languages (Perl, Python, shell scripts, etc), so we don't want to use the .NET SDK or Node.js SDK.
We've already looked at Slack and Cisco Spark. Posting messages in both of these is super simple, so I'm hoping there's a similarly simple solution for Microsoft-Teams?!
For example:
In Slack you can use incoming webhooks to post messages. You use the web interface to get a unique webhook URL for each chat room, and then do simple HTTP POST to that URL (with a JSON message payload) to post to that chat room as the Bot. I had it working in 10 minutes.
In Cisco Spark you create a Bot which gives you a unique Access Token. You then get a room_id for the chat room and use those together to do an HTTP POST (again with a JSON payload) to create a message in the chat room.
So how do you programmatically post/create/send messages to a chat room in Microsoft-Teams?
The simplest way to do what you want is to post a message to a channel using an "Incoming Webhook" connector. For more information, see here: https://msdn.microsoft.com/en-us/microsoft-teams/connectors?f=255&MSPPError=-2147217396#setting-up-a-custom-incoming-webhook
What you're describing is precisely how the Office 365 Connectors work. A Connector allows you to post messages into a Group or Team using web-hooks and a simple JSON payload.
There is a playground for playing with these that is super helpful. One note however, there is a bug in the playground's webhook implementation, so for testing purposes, I would stick to the Send via Email option. This doesn't affect how these work in production, the bug is isolated to the Playground app itself.

Rocketchat adding a name to incoming Twilio SMS numbers

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!

Twilio SMS Physical Phone Integration

In a perfect world, the solution I'm looking for would be an api resource tied to my physical phone, e.g. I could POST an sms message to https://url.com/api/sms, and this api would have the end result of sending an sms from my physical phone. This means that the sms conversation would appear natively in my phone; if the recipient replies to the sms, it would appear just as a normal conversation as if I had physically typed the original sms via my phone.
I understand that I could set the replyto/callback/caller-id via Twilio's api. This would mean that the sms gets sent out by the api, and if the recipient replies to it, I could have the reply forwarded to my phone. But what would be missing in this scenario is the original message sent via the api, that the recipient is replying to.
Is there a streamlined way to achieve this, perhaps with Zapier?
One arduous solution I have in mind is to write an on-phone-app to intermediate the sms transmission so that I essentially have an sms-controlled api on the physical phone vs. a traditional http api. (On android, the api would "listen" via DATA_SMS_RECEIVED_ACTION and then send via sendTextMessage). But this seems cumbersome and would also require updating the app code when/if android changes the underlying SmsManager library. The advantage of this is that I could avoid Twilio altogether, by using my service provider's email-to-sms to send to the on-phone-makeshift-sms-api.
Twilio developer evangelist here.
I think you are looking for a feature that we just announced in preview. This is known as Hosted SMS and allows you to add SMS powered by Twilio to your existing phone number.
You need to apply to get access to Hosted SMS as it is newly in testing. You can do so with the form here: https://www.twilio.com/sms/hosted
I've set up texting to a physical phone by using Twilio's SIM cards and associating it to a phone number.

Sending SMS from Twilio doesnt show friendly name on phone

When I send a test sms from https://www.twilio.com/user/account/developer-tools/api-explorer/message-create with a predefined friendly name, it doesnt apear on my phone. I only see the number.
-if this isnt possible, do you know other providers with this function that work?
[UPDATE]: Twilio now supports this feature.
You can now send messages from an alphanumeric sender ID using Twilio. I wrote up a blog post on how you can achieve this in Ruby and you can check out this article on how to get started with an alphanumeric sender ID on Twilio for more of an overview. Then check out the documentation on how to send an SMS message from an alphanumeric ID.
[UPDATE] Previous answer is below.
Twilio developer evangelist here.
You're absolutely right, the friendly name defined in your account is actually for your uses only and is not intended to appear in place of the number when sending an SMS. We have a few reasons for this, which might be interesting to you depending on your use case.
I don't have a particular company that I can recommend that does allow you to do this. A Google search might help though.

Resources