How to display a welcome message from my Bot using Microsoft Bot Framework

前端 未结 2 1482
离开以前
离开以前 2021-01-21 06:39

I want to display a welcome message whenever someone connects to my bot. I\'ve used the technique from the demo-ContosoFlowers sample on github (https://github.com/Microsoft/Bot

相关标签:
2条回答
  • 2021-01-21 07:19

    Create a class and have this in you callback url of fb. FacebookProfile is my class that holds the name and other information after the call.

     public static async Task<FacebookProfile> GetFacebookProfile(string accessToken)
                {
                    var uri = GetUri("https://graph.facebook.com/v2.6/me",
                        Tuple.Create("fields", "name,email,id,first_name,last_name"),
                        Tuple.Create("access_token", accessToken));
    
                    var res = await FacebookRequest<FacebookProfile>(uri);
                    return res;
                }
    
    0 讨论(0)
  • 2021-01-21 07:27

    I also tried out the ContosoFlowers demo today. I experienced the same behavior you describe: in the emulator, ConversationUpdate code is triggered but in Skype it is not. However, I did notice that the ContactRelationUpdate activity type does fire in Skype (I haven't tried Facebook Messenger). If your goal is to display a welcome message whenever someone "connects" to your bot, you could try using the ContactRelationUpdate activity type like this:

    else if (message.Type == ActivityTypes.ContactRelationUpdate)
    {
        if(message.Action == "add")
        {
            var reply = message.CreateReply("WELCOME!!!");
            ConnectorClient connector = new ConnectorClient(new Uri(message.ServiceUrl));
            await connector.Conversations.ReplyToActivityAsync(reply);
        }
    }
    
    0 讨论(0)
提交回复
热议问题