Bot Framework v4 - Bot Initiate Conversation

前端 未结 4 705
一整个雨季
一整个雨季 2021-01-03 04:27

I am developing a bot for Microsoft Teams using the Bot Framework SDK v4 for NodeJS. Is there a way that the bot can automatically initiate a conversation in a channel, rath

4条回答
  •  执笔经年
    2021-01-03 05:15

    I ended up figuring it out and i wrote a bot controller that i can invoke on demand with the following code.

    var conversationParameters = new ConversationParameters
                {
                    IsGroup = true,
                    ChannelData = new TeamsChannelData
                    {
                        // this needs to come from the teams context.
                        Channel = new ChannelInfo(channelId),
                    },
                    Activity = (Activity)MessageFactory.Attachment(attachment)
                };
                // your service url may differ.
                MicrosoftAppCredentials.TrustServiceUrl(String.IsNullOrEmpty(serviceUrl) ? constantServiceUrl : serviceUrl, DateTime.MaxValue);
                var response = connectorClient.Conversations.CreateConversationAsync(conversationParameters).GetAwaiter().GetResult();
    

提交回复
热议问题