首页 > 解决方案 > 错误:活动导致多个 Skype 活动 bot FrameWork

问题描述

我正在尝试使用主动消息向频道发送附件,下面是我的代码。

async function sendToChannelWithImage(message,channelId,img) {
    MicrosoftAppCredentials.trustServiceUrl('');

    var credentials = new MicrosoftAppCredentials('app-id', 'password');
    var client = new ConnectorClient(credentials, { baseUri: 'https://smba.trafficmanager.net/us/' });

    var conversationResponse = await client.conversations.createConversation({
        bot: {
            id: 'app-id',
            name: 'test'
        },
        isGroup: true,
        conversationType: "channel",
        channelData: {
            channel: { id: channelId }
        },
        activity: {
            type: 'message',
            text: message,
            attachments: [img]
        }
    });
}
const img = {contentType: 'image/*',contentUrl: "https://theysaidso.com/img/qod/qod-inspire.jpg"};
message = 'test'
channelId = 'testid'

在此我尝试使用机器人框架发送消息,我尝试过:https ://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-send-receive -附件

标签: node.jsbotframework

解决方案


将主动消息发送到 Teams 团队频道与将主动消息发送到个人对话没有什么不同,因此您应该sendToConversation使用createConversation. 要在任何地方发送主动消息,您需要确保您拥有对话 ID。在 Teams 中,信任服务 URL也很重要。

如果您想在团队频道中启动新线程,可以通过从对话 ID 中删除线程 ID 来实现。请参阅此处:Microsoft Bot - Node SDK:如何在不回复上一个的情况下发布到公共频道*。活动*

如果您想检查一下,似乎有一个关于在团队频道中启动新线程的示例:https ://github.com/microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/58.teams-start -new-thread-in-channel


推荐阅读