How to send a 'conversationUpdate' to Microsoft Teams from bot manually?

前端 未结 1 1626
臣服心动
臣服心动 2021-01-22 05:36

I have a bot written with the help of bot framework v4. The bot is integrated with Microsoft Teams. I want to send a welcome message to the user when the user insta

相关标签:
1条回答
  • 2021-01-22 05:54

    I'm not sure of a way to force a ConversationUpdate to be sent in the way you're attempting to. Instead, I'd just throw something like this in OnMessageAsync():

    if (turnContext.Activity.Text == "fakeConversationUpdate")
    {
        var fakeTurnContext = new TurnContext(turnContext.Adapter, MessageFactory.Text(string.Empty));
        fakeTurnContext.Activity.AsConversationUpdateActivity();
        fakeTurnContext.Activity.Type = ActivityTypes.ConversationUpdate;
        fakeTurnContext.Activity.MembersAdded = new List<ChannelAccount>()
        {
            new ChannelAccount()
            {
                Id = "fakeUserId",
                Name = "fakeUserName"
            }
        };
        await OnConversationUpdateActivityAsync(new DelegatingTurnContext<IConversationUpdateActivity>(fakeTurnContext), cancellationToken);
    
    }
    

    Then to debug, you just write "fakeConversationUpdate" (which you can change/customize) to the bot in chat and it will send your fakeTurnContext (which you can change/customize) through OnConversationUpdateActivityAsync()

    0 讨论(0)
提交回复
热议问题