1
votes

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?

1
I hope you will satisfied with @Hilton answer. Please take a look at Sending Proactive messageTrinetra-MSFT
I just want to know is there any way to send proactive messages using the Graph APIS? instead of using BotFramework? In the docs and everywhere the examples are writen using BotFramework. If possible I prefer to use graph APIS instead of botframework and I am using nodejsNikhil Ponduri
@NikhilPonduri What did you finally do to achieve this? I am looking for the same thing.Gautam
@Gautam we can only achieve this using botbuilder (microsoft botframework)Nikhil Ponduri

1 Answers

4
votes

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.