Can I use custom JSON format for incoming webhooks - slack

I have a JSON payload that is being sent to Slack using the URL provided by Slack when installing the Incoming Webhook app.
The JSON payload is not in the expected format by slack.
I would like to write an app (or find a way) that receives this JSON phrase it to the correct format and then displays it on the configured slack Channel.
See example below:
if i send the following JSON
{"message":"Allow me to reintroduce myself!"}.
This will not work. we need to change "message" to "text".
So my json payload is not within the needed format, however it is still a json.
How can i catch the json payload? and parse it ?
i would like to do this all on slack with no third party or "middle man" apps.
Is that possible ?

No.
Slack does not provide a custom format for incoming webhooks. You need to adhere to the official format.
There also is no way to intercept the message and transform it to the Slack format.
The only way to achieve this is to use a "middle man" app for the transform:
Message is send to middle man app's URL
Middle man app transforms to Slack format
Middle man sends message to Slack

Related

Can we send file as an attachment along with message in teams programmatically?

Can we send file as an attachment along with message in teams using webhooks or api?
Currently we can send only text message using webhooks and not attach files.
I want to mimic the action in the screenshot below:-
Attach file present in the system
There are ways to first upload file to one drive and then send its link in the teams message but I do not want to use that solution.
Is there a way to directly upload file from your system as an attachment to the microsoft teams using webhook or any alternative way.
Thanks!!
Currently it is not supported to send attachments using webhook. You will need to use bot to send and receive attachments. You can refer this link.
https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/bots-filesv4

Get Message Without History From Gmail API

I'm using the Gmail RESTful API directly (not from some library).
Looking at the documentation here Gmail Documentation.
I have managed to get the content of the message body, however it also returns the whole history chain for the current message.
Is there a way to get a response from the API only the requested message body, without the whole thread history?
According to this thread, it is not possible because it is part of the email's body content and you're specifying the ID of the message to retrieve.
You are getting the full reply message. When the report replied, they quoted the original message and this the text of the original is in the reply message. You may just want to do what Gmail and many other modern emails apps do and collapse/hide any reply text which begins with >.
References:
How to get the reply message without the original message from the Gmail API
GMAIL API : How to get the reply without the original message
Most efficient way to get new messages

Markdown is not working in the Bot Framework Twilio channel

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!

Can you send rich text messages via Twilio?

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.

How track responses for an SMS to multiple recipients with the Twilio API?

I would like to send a text message survey (eg. "How happy were you with X service? Reply 1 for satisified, Reply 2 for not satisfied") to multiple recipients. From the responses, I would like to create a report on the recipients that responded 1 vs the ones that responded 2. What is the best way to do this with the Twilio API? Does my app need to store the results from my incoming SMS message or does Twilio store these so I can query the results? If the former is the case and TwiML is involved, how do I parse the response and store the result? Thanks!
** Disclaimer: Twilio evangelist here **
Chirag:
So it sounds like you have two requirements here:
Use Twilio to send outbound text messages to different recipients
Capture a users reply to that message
For the first requirement, you can start by going to Twilio.com and signing up for a new account. Its free to start and we give you a Twilio phone number you can use to start to build your app. Once you have the Twilio phone number, you can use the REST API to start sending outbound text messages from that Twilio phone number. We have a quickstart that shows you how to do this:
http://www.twilio.com/docs/quickstart/php/sms/sending-via-rest
Note that this link goes to the PHP sample, but you can use the drop down at the top of the page to pick from other stacks like .NET, Java, Python or Ruby.
Once you've sent an outbound message you need to capture the replies to that message (your second requirement). Twilio uses something called a webhook to notify you about incoming SMS messages.
A webhook is basically a URL exposed by your application and associated with your Twilio phone number. You can configure the URL associated with your phone number in the Twilio dashboard.
Each time we receive an incoming SMS message on your Twilio phone number, we will make an HTTP request to that URL. As part of that HTTP request we send along metadata about the inbound message like the phone number that the message was sent from and the Body of the message. The full list of parameters we send is here:
http://www.twilio.com/docs/api/twiml/sms/twilio_request
Now your app can pull those parameters out of the request and do whatever it wants with them. Since we already are sending the body of the message as we receive it, Tims suggestion of tracking the responses based on the From parameter and storing the message body in your own database is a good suggestion.
This quickstart shows receving an incoming text message, grabbing the From parameter and then responding by sending back from TwiML:
http://www.twilio.com/docs/quickstart/php/sms/replying-to-sms-messages
In your case, if you don't want to reply to the incoming message, just omit the TwiML response.
Hope the helps. Lets me know if you need more info.
Devin
Track the responses using the From parameter (and using Body to identify the selection). Yes, Twilio stores those messages, and you could query the API - but it's likely better to just store it in your own database.

Resources