Message sent by Microsoft Teams bot is not displayed in the conversation - botframework

I have tried to send MS Teams bot message request via rest api:
End point: https://smba.trafficmanager.net/ca/apis/v3/conversations/{conversation id}/activities
{"text":"test","type":"message"}
And got empty response:
{}
The message i sent did not appear in the conversation.
Any idea where i could have misconfigured?
It is possible that trustServiceUrl needs to be run before a message is sent, i can't find equivalent rest api to call.

You definitely do need call trustServiceUrl before sending the message. In addition, you need to have additional properties on your activity, like the destination user or tenant id. Please refer to the documents on this, and good starting places are here and here.

Related

MS Teams Incoming Webhook issue

I've created an incoming Teams Webhook connector within a Teams group (using the method below).
I can successfully curl to the webhook internally and get the message to display ok.
MS have checked my tenant and access is as expected.
When I apply my URL for the webhook to any external service they eventually come back stating there was a problem detected with the webhook (Please make sure that your webhook endpoint of xxx is responding with a 2xx response code within 30 seconds of initial connection.)
Can anyone advise what else may need to be done?
Thanks
In Microsoft Teams, choose More options (⋯) next to the channel name and then choose Connectors.
Scroll through the list of Connectors to Incoming Webhook, and choose Add.
Enter a name for the webhook, upload an image to associate with data from the webhook, and choose Create.
Copy the webhook to the clipboard and save it. You'll need the webhook URL for sending information to Microsoft Teams.
Choose Done.
Incoming webhooks are special type of Connector in Teams that provide a simple way for an external app to share content in team channels and are often used as tracking and notification tools. Teams provides a unique URL to which you send a JSON payload with the message that you want to POST, typically in a card format. Cards are user-interface (UI) containers that contain content and actions related to a single topic and are a way to present message data in a consistent way. Please test the incoming webhook url using postman and let us know the payload result or status code. Would be help full for us to understand more.

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.

Bot Framework SDK4 C# - send proactive message to a user in Teams / REST response timeout

Based on a GitHub sample, I created a dialog bot in Teams that collects information from a user and sends that to a Flow (Microsoft Flow/Power Automate) with a HTTP POST call.
After that the Bot waits for a response and sends it back to the user. This generally would be sufficient if the timeout for the call wasn't limited to 2 minutes - sometimes it takes longer to get the complete actions in Flow and get the response.
My question is how I could accomplish the same without getting the timeout. REST seemed the easiest as I'm not a programmer..
I checked the GitHub sample for proactive messaging (https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/16.proactive-messages), and that worked in the Emulator when I enter http://localhost:3978/api/notify, but I have no idea how to use it published to Azure. What would be the endpoint and how I could pass the message text?
Thanks
You should do some code modify if you want to send an message based on proactive-messages demo .
You can refer to my previous post which will meet your requirement.
After you modify the NotifyController.cs file , you can use send messages to a specific user with steps below :
Connect to your bot get current user ID :
Send message to this user by rest client tool or post man :
Result :
If you publish your bot to Azure , lets assume your Azure App service host is :https://xxxxxx.azurewebsites.net , then your bot message endpoint will be :https://xxxxxx.azurewebsites.net/api/messages and your /notify function endpoint will be : https://xxxxxx.azurewebsites.net/api/notify . In brief , just use your Azure App service endpoint to replace http://localhost:3978 will be fine .
Hope it helps . If there is anything unclear pls feel free to let me know .

Unable to get timestamp of the message posted by Slack App

Whenever my app posts ephemeral message to Slack channel (in response to a query by a user), I am unable to get the timestamp of my Slack app response. As I want to delete it once the user has made a selection using one of the buttons. Although I have subscribed to 'message.channels' event, I don't get a notification to my app whenever my app posts in the channel (in response to the user input), therefore, I am unable to get the timestamp of the message which I'll use to delete it. All I want is the timestamp of the message posted by my app so that I can delete it but I am unable to receive the timestamp. Please help!
For e.g. in Giphy app for Slack. Let's say the user invokes the app by calling '/giphy [dog]' where 'dog' is just an example of a search term. The app responds by sending a gif and user can either send it, shuffle to the next one or cancel it. I want a similar capability of cancelling the app response but I need the timestamp of the message in order to do so therefore I am asking for help.
Thanks.
Your approach can not work, because Slack is handling ephemeral messages differently from "normal" messages. They are only visible by one user and can not be modified by API methods (e.g. deletion).
But of course its possible to replace ephemeral messages. Here is how:
Your app can just reply to the interactive message request from Slack with a new message. That new message will by default override the original message including ephemeral messages.
You can reply in two ways:
Directly reply to the request from Slack with a message within 3 seconds
Send a message to the response_url from the Slack request within 30 minutes.
See here for the official documentation on how to respond to interactive messages.
This approach works both with interactive messages and slash commands.
See also this answer for a similar situation.

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