Botframework V4: changing dialog upon sending proactive message

185 Views Asked by At

I've been working on a bot build with the V4 botframework SDK and we already have created mulitple dialogs for various purposes. One of our dialogs is used to capture data that is used to create a meeting record in a CRM environment. Now, we want to send the user that used this dialog a proactive message when the enddate of the meeting is passed.

As a Proof of concept, I've created a console application that creates a proactive message and sends this message to the user using the same channel the user used before. this seems to work, but the user cannot respond to this proactive message as the user is still in one of our dialogs. I would like to send a proactive message that starts a new dialog for the user.

At the moment, this is my code:

using System;
using System.Threading.Tasks;
using Microsoft.Bot.Connector;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;

namespace TestBotframeworkSdkProActiveMessages
{
    class Program
    {
        static void Main(string[] args)
        {
            SendProActiveMessgae().Wait();
        }

        private static async Task SendProActiveMessgae()
        {
            var uri = new Uri("https://smba.trafficmanager.net/emea/");
            var appId = "MYAPPID";
            var appSecret = "MYAPPSECRET";
            var connector = new ConnectorClient(uri, appId, appSecret);
            var convoId = "MYCONVERSATIONID";
            var activity = new Activity()
            {
                Type = ActivityTypes.Message,
                From = new ChannelAccount("BOTID", "KaiBot_DEV"),
                Recipient = new ChannelAccount("USERID", "User Name"),
                Conversation = new ConversationAccount(false, "personal", convoId),
                Text = "My bot's message"
            };
            try
            {
                MicrosoftAppCredentials.TrustServiceUrl( "https://smba.trafficmanager.net/emea/");
                await connector.Conversations.SendToConversationAsync(convoId, activity);
            }
            catch (Exception ex)
            {
            Console.WriteLine(ex.Message);
            }
        }
    }
}
0

There are 0 best solutions below