I got the same message twice

后端 未结 2 516
一生所求
一生所求 2021-01-25 10:57

I used this code to send a different message if a new user start conversation :

IConversationUpdateActivity update = message;
            var client = new Connec         


        
2条回答
  •  北海茫月
    2021-01-25 11:54

    I'm looking into the facebook Name part... You should be able to just plug in this code:

                else if (message.Type == ActivityTypes.ConversationUpdate)
            {
                IConversationUpdateActivity iConversationUpdated = message as IConversationUpdateActivity;
                if (iConversationUpdated != null)
                {
                    ConnectorClient connector = new ConnectorClient(new System.Uri(message.ServiceUrl));
    
                    foreach (var member in iConversationUpdated.MembersAdded ?? System.Array.Empty())
                    {
                        // if the bot is added, then
                        if (member.Id == iConversationUpdated.Recipient.Id)
                        {
    
                            var reply = ((Activity)iConversationUpdated).CreateReply($"Hi Friend I'm Botty McBotface");
                            connector.Conversations.ReplyToActivityAsync(reply);
                        }
                    }
                }
            }
    

提交回复
热议问题