I am trying to create a simple bot that sends images and hyperlinks by SMS using Twilio (trial account).
I do get the reply from the bot , but none of the markdown is working, even simple markdown elements like text or bing
Sample code I am using to send the message through Twilio SMS channel:
public async Task<Message> Post([FromBody]Message message)
{
if(message.Text == "Hello")
{
string messageText = "![Sample Image](http://aka.ms/Fo983c)";
return message.CreateReplyMessage(messageText);
}
Am I missing something? The emulator displays the image and other markdown properly, but when I test using my android phone and text the Twilio number to connect to the bot, it delivers raw HTML and not the rich content.
Twilio developer evangelist here. As pointed our earlier SMS is text only, so markdown or any other formatting will not work.
I just tried sending a message from a bot, and while I get the image correctly on the emulator or webchat, on SMS I only get the URL of the image (i.e. http://aka.ms/Fo983c).
According to the documentation, this is the expected behavior as it states:
Not all channels can represent all markdown fields. As appropriate
channels will fallback to a reasonable approximation, for example,
bold will be represented in text messaging as bold
So I guess for images, it will always fallback to the URL of the image.
As for sending MMS, it appears right now the botframework doesn't support it. To be clear, Twilio itself does support MMS for US and Canada, but it seems Microsoft's implementation didn't take advantage of that right now.
Hope this helps you.
I did this when I was first trying out the framework. Sorry but I don't have that code anymore however I don't recall having to do anything special. I simply sent a picture from my phone to my twilio number and then in the message properties for the message received by the bot there was an attachment field with a URL pointing to the image sent from my phone. Then I used a regular web request to pull down the image.
The details for the attachment objects and content url fields are outlined here.
Because there's no way to emulate the SMS channel you'll have to publish the code live to be able to test it out.
Have fun!
Related
When I send an SMS to my Twilio number which includes an image, there doesn't appear to be a filename associated with the image.
I'm using Twilio Studio.
Example:
Send an SMS text with image to my Twilio number
A Twilio Studio Flow pipes the {{trigger.message.MediaUrl0}} and sends an SMS text sent to my actual phone number
The URL is of the following format https://api.twilio.com/2010-04-01/Accounts/<long-GUID-1>/Messages/<long-GUID-2>/Media/<long-GUID-3>
Clicking on this URL opens a browser pointing to a translated URL https://s3-external-1.amazonaws.com/media.twiliocdn.com/<long-GUID-1>/<long-GUID-4> and showing the original image
But no filename.
I'm trying to access the filename so I can apply a naming convention to it. How is this accessed?
The URL to download the actual media is dynamically generated.
You can refer to the blog post here:
Retrieving Twilio MMS Image URLs with Node.js
I'm trying to send files to a channel in Teams, but I've found examples of asking a bot for something (for example I write 1 and he send me an image), and the bot's able send images or files like attachments (I don't need adaptive cards or message cards if your idea is Incoming webhook).
I need to send with a schedule request attachment files to teams, is that possible? For example, if such is possible to send a set of image attachment every 1 hour.
Thanks
In case this is still not resolved.
Please take a look at Send and receive files through your bot doc to see how your bot can send/receive file attachments.
For bot to trigger message based on backend trigger, please take a look at Send
proactive messages.
Sample code for both of these scenarios can be found in Bot Framework sample code repo.
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.
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.
I am trying to send a rich text message via Twilio. I am able to send regular SMS messages, but I want to include a hyperlink in the body of the text.
I tried the twilio mediaUrl to include an rtf file, but that didn't work. Including html in the body of a message doesn't work as it just sends in plain text.
I'm posting via curl to the twilio endpoints, so i'd prefer not to have to get into PHP or some other language to achieve this. I just want to send raw data to twilio and receive a rich text message back, if it's possible.
Twilio developer evangelist here.
Using Twilio you can send MMS messages to numbers in the US and Canada. When you pass a mediaUrl the file needs to be hosted somewhere publicly on the web and it will then be included within the message.
You can pass files of any of the mime types listed here, though when sending RTF the result will depend on how well the receiving device supports RTF files.
If you want to include a link, I'd recommend shortening the URL (using bit.ly or similar) and just sending it as part of the text. Most smart phones will auto link the URL. Built in SMS apps on phones don't support markup of any sort, which is why your attempt with HTML just showed the raw markup.
Let me know if this helps at all.