akash verma
akash verma

Reputation: 159

Is it possible to trigger an intent based on the response(from webhook) of another intent?

I have an intent named "intent.address" with the action name "address_action" and the training phrase "My address". When this intent is triggered, response comes from my webhook saying "Alright! your address is USER_ADDRESS".

Used app.ask() here

What I want is, when this response comes from the webhook then another intent named "intent.conversation" (event name "actions_intent_CONFIRMATION")(here also webhook enabled) gets triggered, which will ask for user confirmation to continue or not? For example :

Alright your address is USER_ADDRESS

then next

Do you want ask address/directions again? 

Upvotes: 2

Views: 2078

Answers (1)

Prisoner
Prisoner

Reputation: 50741

Intents do not reflect what your webhook says, it reflects what the user says. Intents are what the user intends to do - what they want.

So no, you can't just trigger another Intent this way. There are a few ways to do what you're asking, however.

Using the Confirmation helper with the actions-on-google v1 node.js library

If you really want to use the Confirmation helper, you need to send back JSON, since the node.js v1 library doesn't support sending this helper directly. Your response will need to look something like:

{
  "data": {
    "google": {
      "expectUserResponse": true,
      "systemIntent": {
        "intent": "actions.intent.CONFIRMATION",
        "data": {
          "@type": "type.googleapis.com/google.actions.v2.ConfirmationValueSpec",
          "dialogSpec": {
            "requestConfirmationText": "Please confirm your order."
          }
        }
      }
    }
  }
}

If you're not already doing JSON in your responses, then you probably don't want to go this route.

Using the Confirmation helper with the actions-on-google v2 node.js library

If you've already switched to v2 of this library, then you have the ability to send a Confirmation with something like this

app.intent('ask_for_confirmation_detail', (conv) => {
  conv.ask("Here is some information.");
  conv.ask(new Confirmation('Can you confirm?'));
});

Or you can just use the Dialogflow way of doing this

In this scenario - you don't use the Confirmation helper at all, since it is pretty messy.

Instead, you include your question as part of the response, and you add two Followup Intents - one to handle what to do if they say "yes", and one if they say "no".

enter image description here

enter image description here

Upvotes: 3

Related Questions