Forum Discussion
MS Teams Bot Event Not Fired when message is sent from outside the Teams Bot
Hello,
I am sending a message on an existing conversation to my MS Teams Chat bot 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.
I would also like to somehow trap the event when the above message is received by the ma teams chat bot.
I have attached the following Event handlers in DialogBot class that inherits form ActivityHandler class.
- OnMessageActivityAsync
- OnEventActivityAsync
- OnTurnAsync
However, none of the above events handlers get triggered when the message is send from outside the bot using the above logic.
These event handlers get triggered only when user types a message in the chat bot.
Which event should get triggered when an outside message is received by the teams chat bot and how do I handle the event.
Please help.
Thanks,
Gagan
- Nikitha-MSFTMicrosoft
gagsbhatnagar - Out side the teams bot mean? How you are sending the message? Could you please explain your scenario in more detail?
- gagsbhatnagarCopper Contributor
Nikitha-MSFT I am trying to implement the following solution for managing a long running process in MS Teams Bot. However I am getting error while Event Activity Type message back to Bot from Azure Function.
When I send an Message Activity Type message back to Bot from Azure function no event get raised on the Bot side. I expected OnMessageActivityAsync or OnEventActivityAsync event handlers in DialogBot.cs to be raised when an Activity message gets sent from Azure Function.
I tried to send an Activity message to Bot from a sample windows application but still no events were triggered on the Bot side. On both occasions, the message send by Azure Function and sample Windows application appeared in the bot chat window.
Let me know if you need more information.
Thanks !
- Nikitha-MSFTMicrosoft
gagsbhatnagar - when you use the message back functionality teams directly send the displaytext mentioned in the card. Are you not receiving the message?