I have created a QnA maker Bot. Now I would like to wish the user with a greeting when the conversation starts. I saw in a link that this can be achieved using Conversation update, I have added the following code in QnABot.cs which comes inside the Bots folder
private async Task HandleSystemMessage(Activity message)
{
if (message.Type == ActivityTypes.DeleteUserData)
{
// Implement user deletion here
// If we handle user deletion, return a real message
}
else if (message.Type == ActivityTypes.ConversationUpdate)
{
if (message.MembersAdded.Any(o => o.Id == message.Recipient.Id))
{
ConnectorClient client = new ConnectorClient(new Uri(message.ServiceUrl));
var reply = message.CreateReply();
reply.Text = "Hello and Welcome ";
await client.Conversations.ReplyToActivityAsync(reply);
}
}
else if (message.Type == ActivityTypes.ContactRelationUpdate)
{
// Handle add/remove from contact lists
// Activity.From + Activity.Action represent what happened
}
else if (message.Type == ActivityTypes.Typing)
{
// Handle knowing tha the user is typing
}
}
Is this right place to add this code ?
I dont have a messagecontroller class, I only have BotController.cs should I add it there ?
Can I test this greeting in Bot Emulator or Should I try it in webchat itself ?
My requirement is to greet the user in the Directline Webchat.