1

I have two intents get_name and get_age

in get_name I take the user name, this intent is enabled for fulfillment. In the editor, how to ask for confirmation of the name?

if confirmed, then I should add output context to get_name, so that get_age intent gets invoked.

i tried using the conv object to start a conversation without leaving the intent, but it does not even call the function.

function confirmation(agent){
    var entity_name = agent.name;
    var name = agent.parameters.name;
    var conv = agent.conv();
    conv.ask(`Is ${name} correct?`);
    agent.add(conv);
    var user_query = conv.query;
    if(user_query.entities.name=='yes'){
        agent.setContext({
            name: `${entity_name}`+'_done',
            lifespan: 2
        });
        agent.add(`Give your age ${name}`);
    }
}
Abhinay
  • 13
  • 5

1 Answers1

1

You're mixing up a couple of concepts. While it is possible to use the Inline Editor to do fulfillment, and it is possible to confirm an entry from a user without a Followup Intent, you will still need additional Intents to do the confirmation.

There are two important things to understand about Dialogflow fulfillment programming:

  1. All responses from the user have to come through an Intent. It doesn't need to be a unique or Followup Intent, but the intent of what the user says is always captured this way.
  2. When an Intent is triggered, it can send the information to an Intent Handler. This is the only way an Intent Handler gets information from the user. When a Handler is triggered, it does not wait for further user input. All it can do is send a reply.

So in your code, once you have sent

conv.ask(`Is ${name} correct?`);
agent.add(conv);

you will not get the response from that prompt in the same Intent Handler.

You will need another Intent that can capture the user saying yes or no. You can do this as one Intent or two - which you do is up to you. Based on what the user says, you then prompt them again.

Your issue is similar to what is described in this article, which points out that how we reply is based on two things:

  1. The current state (in your case, which question you are asking them to confirm)
  2. The user's reply ("yes", in which case you save the info and ask about the next question, or "no", in which case you repeat the question)
Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Thank you, I didn't know about handler not waiting for further input. This solved my problem. I will use another intent to handle confirmation. – Abhinay May 02 '19 at 11:20