Using ConversationUpdate I show a welcome message. I have tested the code in bot framework emulator where it works fine.
I tried it in facebook messenger and got no response.
Question: Is it supported in messenger?
IConversationUpdateActivity update = message as IConversationUpdateActivity;
var client = new ConnectorClient(new System.Uri(update.ServiceUrl), new MicrosoftAppCredentials());
if (update.MembersAdded != null)
{
foreach (var newMember in update.MembersAdded)
{
if (newMember.Id != update.Recipient.Id)
{
var reply = ((Activity)update).CreateReply($"Hello "+newMember.Name);
client.Conversations.ReplyToActivityAsync(reply);
}
}
}
Specifically the bot must show the welcome message each time a member starts a conversation. Also I added the code:
newMember.Id != update.Recipient.Id
because the message was showing up twice in emulator.
The rest are quite simple and expected to work. Any thoughts?
The ConversationUpdate
event isn't supported in the Facebook Messenger channel. Facebook Messenger doesn't broadcast an event by default when the users opens a chat. There are two options to achieve similar behaviour:
Use the Get Started property to track new conversations. I wrote a blogpost about how to catch this specific event in BotBuilder V3, you can do something similar for BotBuilder V4.
Respond with your welcome message after the first message interaction of the user.