[英]MS Teams bot - create conversation in newly created Group returns 405 BadArgument
我正在尝试使用 Nodejs + botframework v4.9.2 为刚刚创建的频道创建新的对话。
我有
Conversations.createConversation
from bot sdk, it's basically calling POST https://directline.botframework.com/v3/conversations with passing new channel id and getting 405 BadArgument This channel does not support this operation
我在本地运行机器人并通过 ngrok 代理。 我也可以访问 GET /v3/conversations。
更新代码
获取团队成员GET ${graphUrl}/groups/${teamId}/members
创建新频道
const createChannelRequest: IGraphCreateChannelBody = {
"@odata.type": "#Microsoft.Teams.Core.channel",
displayName: channelName,
description: `This channel is for incident id : ${incidentId}`,
members: membersIds.map(memberId => (
{
"@odata.type": "#microsoft.graph.aadUserConversationMember",
"user@odata.bind": `https://graph.microsoft.com/beta/users('${memberId}')`,
roles: ["owner"]
}
))
};
return await graphClient.createChannel(teamId, createChannelRequest);
createChannel 基本上是POST ${graphUrl}/teams/${teamId}/channels
创建新标签POST ${graphUrl}/teams/${req.teamId}/channels/${req.channelId}/tabs
其中 channelId 是 createChannelResponse.id
创建新对话
const client = new BotConnector.ConnectorClient(credentials, {baseUri: serviceUrl});
const {bot} = TurnContext.getConversationReference(activity);
const createConversationResponse = await client.conversations.createConversation({
bot,
activity: incidentActivity,
members: teamMembers.value.map(member => ({
id: member.id,
name: member.displayName
})),
channelData: {
channel: {
id: newIncidentChannelId
},
tenant: {
id: tenantId
}
},
isGroup: true
});
createConversation 以 405 失败的地方
[根据上述评论发布完整答案]
在Teams的上下文中没有必要(也不会工作)使用createConversation
,因为对话是在创建 Team/Channel/Group 聊天本身的那一刻创建的( createConversation
存在于其他 Bot Framework 场景中,并且是不适用于团队)。 因此, SendToConversation
是正确的操作。
至于如何使用SendToConversation
,您需要准备好一些重要的变量,最常见的获得这些变量的时间是当您的机器人首先添加到频道/聊天/其他任何内容时。 您可以在此处阅读有关此内容的更多信息,但更一般地说,这在 Teams 中被认为是一种称为“主动”消息传递的东西,值得更多地阅读该主题。 请参阅此处和此处作为良好的起点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.