使用 Graph API 在 Microsoft Teams 的机器人频道中向用户发送消息作为机器人

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

我按照我使用上述 API 发送的消息 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 中提到的步骤创建了一个机器人。有什么方法可以作为机器人向用户发送直接消息吗?

除了使用 Graph,还有另一种使用 Bot Framework 本身的方法,可以将消息发送到团队频道、群聊或一对一对话。代码甚至不需要存在于机器人内部,它只需要在幕后利用机器人框架(例如,我有几个主动向用户发送消息的 Azure Functions)。这个想法称为 "Proactive messaging",您可以在文档 here.

中阅读更多相关信息

确实需要在用户首次安装机器人时或机器人收到消息时获取某些字段。我在 中对此进行了更多描述。您没有说您使用的是什么语言,但是有很多示例 - 如果您让我知道您使用的是什么,我可以向您发送链接。