2
votes

I have a chatbot using dialogflow agent. I wrote a javascript back end code for its webhook fulfillment. I checked some condition in this code and if the condition is true I want a special intent to be triggered. How can I do this? What is the correct java script code to triggered an intent inside a java script if statement?

3
Can you update your question to explain this a little clearer? Inside your fulfillment, you want to trigger a different intent and the fulfillment for that one? (What is the data flow you're picturing here?)Prisoner
At first I explained it with details here ,but no body answered it.we.are
Asking the question a second time is frowned upon by StackOverflow. Asking it a second time with fewer details than the first time doesn't seem like a wise way to get an answer if you didn't the first time.Prisoner
Does this actually have to trigger the intent in dialogflow or is executing the code from a different intent in the webhook based on the if statement the desired result?Jordi

3 Answers

2
votes

What function do you intend to perform by triggering an intent? Diaglogflow has v1 & v2 API references for this. You can do GET/POST/PUT/DELETE operations by triggering an intent using ajax call in your javascript code. Please read more about this here https://dialogflow.com/docs/reference/agent/intents

0
votes

To make things clearer, DialogFlow intents are triggered by querying using the query API (https://dialogflow.com/docs/reference/agent/query)

Note: V1 of the DialogFlow API will deprecate soon, and will be replaced by V2 which is using gRPC.

This means that if you wish to trigger the intent programmatically and have the fulfilment triggered as well, you should have the following:

  1. Script (can be on JavaScript as you would like to) with REST API request (doable using the Axios library) to the DialogFlow Query API.

  2. DialogFlow will pick up the query, runs it through and triggers the Intent (if the query matches the intent).

  3. In processing the intent, because there is a fulfilment, DialogFlow will run the fulfilment, which is another API/webhook call to your server hosted somewhere.

  4. Your server will pick up the API request, and process accordingly.

Try out the Query API from DialogFlow and see if it works out for you.

0
votes

Okay, I am late here, but I have used the below approach to encounter such a situation. You can use custom event and intent chaining.

I followed the below URL and implemented the same. Maybe this help someone.

enter link description here