Dec 22 2020 05:04 AM
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
Dec 22 2020 10:15 PM
@gagsbhatnagar - Out side the teams bot mean? How you are sending the message? Could you please explain your scenario in more detail?
Dec 23 2020 02:57 AM
@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 !
Dec 28 2020 01:39 AM
@gagsbhatnagar - when you use the message back functionality teams directly send the displaytext mentioned in the card. Are you not receiving the message?
Dec 31 2020 01:55 AM
Jan 06 2021 02:20 AM
@gagsbhatnagar - When you are sending message from the azure did you @mention the bot in the message? Are you sending message to team/Group/personal chat between user &bot? Could you please share the repro steps?
Jan 14 2021 07:39 PM
@Nikitha-MSFT I did not use @mention in the Activity message that I am sending as a personal chat between Bot and user. I tried using @mention in my code but it still did not result in bot event being triggered even though the message that I sent from outside the bot code appeared in the chat bot window.
Jan 14 2021 07:43 PM
Jan 19 2021 09:46 PM
@gagsbhatnagar - Yes, you can use Message extension.