kingzing1
kingzing1

Reputation: 115

DialogFlow- Invoke intent without training phrases and saving response

I'm trying to build a basic "question/answer" app in Actions using DialogFlow. Right now I have two intents:

Intent 1: User says "Ask me a question" and the intent responds "Tell me about yourself"

Intent 2: I'd like to capture the user response to "tell me about yourself", but frankly there's no way to write enough training phrases to cover it.

I tried following this suggestion, and having Intent 1 send an output context called save_response and Intent 2 has an input context of save_response. Then for the training phrase I used @sys.any:save_response

When I try this action, it just invokes the default fallback intent every time. Thoughts on where I might be going wrong?

Upvotes: 1

Views: 2874

Answers (2)

Prisoner
Prisoner

Reputation: 50731

In general, having an Intent with a training phrase that consists only of @sys.any may not always work as you expect.

Better would be to have a Fallback Intent that has the Input Context set to make sure you only capture things in that state (save_response in your case) and then to use the full text captured in your fulfillment.

When doing it this way, you do not need the "Intent 2" you described - or rather, this would be a Fallback Intent that you create in the Dialogflow UI. The Fallback Intent is triggered if no other Intent would match what the user has said.

To create a Fallback Intent, select the three dots in the upper right of the Dialogflow UI

enter image description here

then select "Create Fallback Intent"

enter image description here

The Fallback Intent editor is very similar to the normal Intent editor. The biggest difference is that the phrases you enter (and you don't need to enter any) will explicitly not match this Intent, and there are no parameters. Other aspects (the name, the Incoming Context, turning on fulfillment) are the same.

enter image description here

Upvotes: 2

sid8491
sid8491

Reputation: 6800

You need to create 2 intents, in the first intent your training phrase would be Ask me a question, output context will be save_response and response will be the question which you want to throw at the user.

Then in intent 2, you need to do following:

  • Set input context to save_response, so that it will only be triggered when this is present in the contexts

context

  • Go to actions and parameters section and create a parameter named answer, give entity type as @sys.any

parameter

  • Then go to training phrases section and add any training phrase, then highlight it all, and select the parameter you just created

training phrase

  • After that, your training phrases and entity section will be looking like something like below image

post selection

  • Save the intent and you are done

result-1 result-2

Hope it helps.

Upvotes: 8

Related Questions