向用户发送主动消息:错误:ChatConnector:startConversation-错误开始对话

时间:2019-04-03 12:19:39

标签: node.js botframework microsoft-teams

我正在尝试向用户发送主动消息。这是对我的nodejs机器人中某个端点命中的响应。

我有类似以下内容:

app.get('/example-message', (req, res) => {
    var user = req.query.user;
    var serviceUrl = req.query.serviceUrl;

    var address = {
        channelId: "msteams",
        user: {
            id: user.userObjectId
        },
        channelData: {
            tenant: {
                id: TENANTID
            }
        },
        bot: {
             id: APPID,
             name: "ExampleBot"
        },
        serviceUrl: serviceUrl
    };
});

let msg = new builder.Message().address(address).text("Hello");
bot.send(msg, function(err, address){
    console.log("Error", err);
    console.log("Address", address);
});
console.log("Message sent to: " + address.user.id);

当前返回错误:

ERROR: ChatConnector: startConversation - error starting conversation.
Error: POST to 'https://smba.trafficmanager.net/emea/v3/conversations' failed: [400] Bad Request

我正尝试第一次向用户发送消息。这不在“ conversationUpdate”活动中,而是在简单的nodejs路由中。

这有可能吗?我做错什么了吗?

谢谢!

更新:

我已经能够使用connector.fetchMembers吸引用户进入团队循环,以填充address对象并发送消息。

如果有更简单的方法,那就太好了

0 个答案:

没有答案