【发布时间】:2020-02-14 09:47:30
【问题描述】:
我需要在 msteams 的频道上主动创建对话。所以我找了一些例子,但没有找到任何真正主动对话创建的例子。所有示例首先包括处理消息,并使用上下文创建对话。 更准确地说,我有 facebook、whatsapp 和 web 小部件。例如,用户从 facebook 写,我通过 fb webhook 获取消息,我需要创建新线程(在频道内回复块),只有在那之后,才会有人使用线程块在频道中回答,我会收到消息。 据我了解,我需要引导对话对象并使用 adapter.createConversation({ ...convFields }),但例如我没有 serviceUrl。
// i am using adapter from examples
new BotFrameworkAdapter({
appId: id,
appPassword: password
});
// then i have something like that in examples
const conversationParameters = {
isGroup: true,
channelData: {
channel: {
id: 'msteams'
}
},
activity: 'dsada'
};
const connectorClient = this.adapter.createConnectorClient(
context.activity.serviceUrl // i don't have context to get that serviceUrl, because i must do it first, not handle message and create thread after that.
);
const conversationResourceResponse = await connectorClient.conversations.createConversation(
conversationParameters as any
);
const conversationReference = TurnContext.getConversationReference(
context.activity // same here, i don't have context
);
conversationReference.conversation.id = conversationResourceResponse.id;
return [conversationReference, conversationResourceResponse.activityId];
【问题讨论】:
标签: javascript node.js botframework microsoft-teams