从团队Bot外部发送消息时未触发MS Teams对话框Bot事件 [英] MS Teams Dialog Bot Event Not Fired when message is sent from outside the Teams Bot

查看:89
本文介绍了从团队Bot外部发送消息时未触发MS Teams对话框Bot事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过现有对话从Windows窗体应用程序外部向我的MS Teams Chatbot发送一条消息.

I am sending a message on an existing conversation to my MS Teams Chatbot from outside i.e. a Windows Forms Application.

ChannelAccount userAccount = originalActivity.From; 
ChannelAccount botAccount = new ChannelAccount("GenerateReport", "AzureFunction");

var message = new Activity();//Microsoft.Bot.Schema.Activity.CreateEventActivity();
message.Type = ActivityTypes.Message;
message.From = originalActivity.Recipient; //new ChannelAccount("GenerateReport", "AzureFunction");//botAccount;
message.Value = originalActivity; 
((Activity)message).Text = "LongOperationResponse";
message.Recipient = originalActivity.From;// userAccount;
message.ChannelId = originalActivity.ChannelId;
message.Conversation = originalActivity.Conversation;

ResourceResponse response21= await connectorClient.Conversations.SendToConversationAsync((Activity)message);

消息活动已成功发送,并且消息显示在聊天机器人对话中.

The message activity is sent successfully and the message appears in the chat bot conversation.

当ma小组聊天机器人收到上述消息时,我还想以某种方式捕获事件.我在从ActivityHandler类继承的DialogBot类中附加了以下事件处理程序.

I would also like to somehow trap the event when the above message is received by the ma teams chatbot. I have attached the following Event handlers in DialogBot class that inherits from ActivityHandler class.

  • OnMessageActivityAsync
  • OnEventActivityAsync
  • OnTurnAsync

但是,使用上述逻辑从机器人外部发送消息时,上述事件处理程序都不会触发.

However, none of the above event handlers get triggered when the message is sent from outside the bot using the above logic.

仅当用户在聊天机器人中键入消息时,才会触发这些事件处理程序.

These event handlers get triggered only when a user types a message in the chatbot.

当团队的聊天机器人收到外部消息时,应该触发哪个事件?我该如何处理该事件.

Which event should get triggered when an outside message is received by the team's chatbot and how do I handle the event.

请帮助.

谢谢加甘

推荐答案

这个问题尚不清楚,但是现在阅读注释,我想我会更好地理解.您正在以机器人的身份 发送消息,但从机器人的外部发送消息(基本上是主动消息传递).结果,您的机器人代码根本不会得到通知,因为从Bot Framework的角度来看,为什么它会告诉 you you 正在发送消息-您知道当然,那已经.实际上,您只会收到通知:

The question was a bit unclear, but reading the comments now I think I understand it better. You are sending messages as the bot, but from outside of the bot (basically pro-active messaging). As a result, your bot code won't get notified at all because from Bot Framework's perspective, why would it tell you that you are sending a message - you'd know that already, of course. In practice, you will only get notified:

  1. 当邮件发送至您的漫游器
  2. 时根据会话类型进一步定义的
  3. .对于1-1,您将获得所有消息到您的机器人.对于群组聊天或团队频道对话,您将在机器人被@提及的地方获取消息
  1. when a message is sent to your bot
  2. that is further defined depending on conversation type. For a 1-1, you will get ALL messages TO your bot. For a group chat or Teams channel conversation, you will only get messages where you bot is @mentioned

这篇关于从团队Bot外部发送消息时未触发MS Teams对话框Bot事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆