从机器人向团队通道发送主动消息

时间:2019-10-04 07:24:10

标签: botframework microsoft-teams adaptive-cards

我有一个带有共享按钮的自适应卡,单击该按钮,我已经将该卡共享给其他团队频道,到目前为止,我可以将消息发送到同一团队频道,但是在发送时给其他团队的渠道给了我错误。 下面是我正在使用的代码:

                    var tenantID = activity.GetTenantId();
                    var message = Activity.CreateMessageActivity();
                    message.Text = "Hello World";
                    var conversationParameters = new ConversationParameters
                    {
                        IsGroup = true,
                        ChannelData = new TeamsChannelData
                        {
                            Channel = new ChannelInfo("ID of Channel to which message is to be sent"),
                            Team = new TeamInfo("ID of team to which message to be sent", "Name of team");                         

                            Tenant = new TenantInfo(tenantID),
                            Notification = new NotificationInfo(true)
                        },                       
                        Activity = (Activity)message
                    };                
                    MicrosoftAppCredentials.TrustServiceUrl(activity.ServiceUrl, DateTime.MaxValue);
                    var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl));                  
                    await connectorClient.Conversations.CreateConversationAsync(conversationParameters);

1 个答案:

答案 0 :(得分:0)

在提到bot-id等问题时,MS Teams非常挑剔(出于某种原因)。您需要确保在代码和清单中配置了相同的bot ID。

最重要的是,当您收到“无法访问应用程序”消息时,这很可能意味着您的漫游器消息传递端点(在azure或dev.botframework.com上的漫游器选项中配置)没有指向正确的网址。

通常,您无法将消息发送给以前从未与您的机器人进行过1:1对话的用户,也无法将消息发送给未将其添加为成员的任何团队。

相关问题