问题描述
我正在使用 nodejs 使用 Microsoft 团队集成。在 Teams 客户端中,您可以轻松复制指向对话的链接,这可用于随时导航到特定对话。
参考截图:https://www.dropbox.com/s/fog3ojddcb6mdis/screen%20shot%202021-02-10%20at%202.44.31%20pm.png?dl=0
有没有办法在创建对话时在 botframework 中获取此链接?我看到有用于群聊等的深层链接 api,需要提供用户列表。
这个没用https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/build-and-test/deep-links
我在开始对话时在 nodejs 中获得的活动对象是:
{
"localTimestamp": "2021-02-13T05:42:25.313Z","timestamp": "2021-02-13T05:42:25.313Z","type": "message","locale": "en-US","from": {
"name": "Stacy","id": "29:1a-Xb7uPrMwF2XqjMEHCC7ytV2xb2VUCqTA-n_s-k5ZyMCTKIL-ku2XkgbE167D_5ZbmVaqQxJGIQ13vypSqu-A","aadobjectId": "718ab805-850c-43ec-8d4e-4af0c543df75"
},"serviceUrl": "https://smba.trafficmanager.net/amer/","conversation": {
"isGroup": true,"conversationType": "channel","id": "19:a0a0088174a644cb91406f4d8f79d888@thread.tacv2;messageid=1613194945273","tenantId": "04e934f3-0866-4a6d-b07c-a4737e8f9865"
},"localTimezone": "America/Los_Angeles","recipient": {
"name": "MyBot","id": "28:a835cf1d-83a8-5ae9-845a-23a68a1df442"
},"id": "1613194445273","channelData": {
"channel": {
"id": "19:a0a0088174a644cb91459f4d8f79d888@thread.tacv2"
},"tenant": {
"id": "04e930f3-0866-4a6d-c07c-a4737e8f9865"
},"team": {
"id": "19:774d4103fe51420db1437130378b196e@thread.tacv2"
},"teamsChannelId": "19:a0a0088174a644cb91409f5d8f79d888@thread.tacv2","teamsTeamId": "19:774d4103fe51420db1437190478b196e@thread.tacv2"
},"attachments": [
{
"contentType": "text/html","content": "<div><div><span itemscope=\"\" itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">MyBot</span> opty </div>\n</div>"
}
],"textformat": "plain","channelId": "msteams","entities": [
{
"text": "<at>MyBot</at>","mentioned": {
"id": "28:a835cf1d-83a8-4ae9-845a-23a68a1df432","name": "MyBot"
},"type": "mention"
},{
"country": "US","platform": "Mac","timezone": "America/Los_Angeles","type": "clientInfo"
}
],"text": "opty"
}
解决方法
您可以使用 Get Chat Graph API
POST:https://graph.microsoft.com/beta/me/chats
这些权限需要在委托级别授予应用程序
Chat.ReadBasic
、Chat.Read,Chat.ReadWrite
您将能够看到chatType/Topic,您可以在此基础上获取chatId 并将其传递给Get Message in Chat, 所以最后你可以使用深层链接并使用创建深层链接来聊天 https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/build-and-test/deep-links#generating-a-deep-link-to-a-chat
注意:在群聊中创建特定消息的深层链接时,您应该拥有群聊ID和消息ID。您可以在 Bot 活动中获取消息 ID,稍后使用它来创建深层链接。