Bot Framework, conversation in another conversation
NickName:Romário Carvalho Ask DateTime:2018-03-09T18:40:26

Bot Framework, conversation in another conversation

I created a bot using QnA Maker, which depending on the answer I should return the same answer or call another service, which in my case is to assemble a form flow from a JSON.

But when calling this service I start a new Conversation, so it does not return to the emulator.

I'm creating a conversation in another conversation. There must be something missing.

RootDialog.cs:

[Serializable]
public class RootDialog : QnAMakerDialog
{
    public RootDialog() : base(
        new QnAMakerService(
            new QnAMakerAttribute(
                ConfigurationManager.AppSettings["QnaSubscriptionKey"],
                ConfigurationManager.AppSettings["QnaKnowledgebaseId"],
                "Não encontrei sua resposta",
                0.5
                )
            )
        )
    {

    }

    protected override async Task RespondFromQnAMakerResultAsync(IDialogContext context, IMessageActivity message, QnAMakerResults result)
    {
        var primeiraResposta = result.Answers.First().Answer;

        if (primeiraResposta.IndexOf("form") == -1)
        {
            await context.PostAsync(primeiraResposta);
            return;
        }

        await Conversation.SendAsync(message, () => Chain.From(() => FormDialog.FromForm(() => Formulario.JsonForm.BuildJsonForm(), FormOptions.PromptFieldsWithValues)));

        return;

    }
}

MessagesController.cs

public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
    var connector = new ConnectorClient(new Uri(activity.ServiceUrl));

    if (activity.Type == ActivityTypes.ConversationUpdate)
    {
        if (activity.MembersAdded.Any(o => o.Id == activity.Recipient.Id))
        {
            var reply = activity.CreateReply();
            reply.Text = "Hello...";
            await connector.Conversations.ReplyToActivityAsync(reply);
        }

    }
    else if (activity.Type == ActivityTypes.Message)
    {
        // HEREE!!!
        await Conversation.SendAsync(activity, () => new Dialogs.RootDialog());

    }
    else
    {
        HandleSystemMessage(activity);
    }
    var response = Request.CreateResponse(HttpStatusCode.OK);
    return response;
}

The response of emulator:

I could not send, Repeat

Copyright Notice:Content Author:「Romário Carvalho」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/49191894/bot-framework-conversation-in-another-conversation

More about “Bot Framework, conversation in another conversation” related questions

Bot Framework, conversation in another conversation

I created a bot using QnA Maker, which depending on the answer I should return the same answer or call another service, which in my case is to assemble a form flow from a JSON. But when calling t...

Show Detail

Bot Framework v4 - Bot Initiate Conversation

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, rather than user initiating ...

Show Detail

Bot framework directline conversation data

I am using the Bot framework / DirectLine within a custom app. I replaced the default BotDataStore with a custom one (table storage using the bot builder extension). But still, the conversation (I...

Show Detail

Bot Framework - Bot initiates the conversation on Skype

I want my bot to display an introductory message when a user begins a new conversation. I've seen this working with bots in Skype where the bot sends a message before the user types anything. I ha...

Show Detail

Bot Framework: How to exit Conversation?

so right now I'm using Microsoft.Bot.Builder.Dialogs.Conversation.SendAsync and Microsoft.Bot.Builder.Dialogs.Conversation.ResumeAsync to implement a way to pause and resume conversation but it seems

Show Detail

Conversation state in Microsoft bot framework

I want to know how long a conversation state will be there if we haven't added any expiry method in the bot framework. Did anyone know anything about this?

Show Detail

Microsoft Bot Framework - Clear Conversation State

I am making a bot using Microsoft's Bot Framework, and I've noticed that when I make changes and deploy to Microsoft Teams, it uses the same conversation state and I have to write "/deleteprofile" to

Show Detail

Microsoft Bot Framework - Clear Conversation State

I am making a bot using Microsoft's Bot Framework, and I've noticed that when I make changes and deploy to Microsoft Teams, it uses the same conversation state and I have to write "/deleteprofile" to

Show Detail

Bot listening to another bot in group conversation

I have built a few bots with Bot Framework. One of them (let's call her BOT1) is an experiment that needs to listen to all messages in a group conversation (Slack, or Skype) that is invited to. Wo...

Show Detail

How will see the bot conversation count by adding telemetry in bot framework code?

How will see the conversation counts in application insights? I have added telemetry in my bot , still I am not able to see conversation counts and other than conversation counts. const{

Show Detail