I am trying to build a bot service using google's dialogflow. I have already written an intent and that is having a web hook and static responses also. My question is how does dialogflow decides between static responses and whether to invoke the webhook?
If you have a webhook defined, and you have the "Enable webhook call for this intent" switched on, it will call the webhook. If your webhook returns a response, it will send that response to the user.
If you have the switch off, or if your webhook does not return anything (either because it times out or you choose not to send anything), then it will use the replies you have set in the Intent.
Related
I need a Dialogflow agent to query multiple times a REST webservice (endopoint) outside the Google Cloud.
Documentation, tutorials, everything points to enable fullfillment and on the intent that will trigger the network request, enable "webhook call for this intent".
Well, on the fulfillment panel, enable Webhook, and paste custom endpoint URL, and pass parameters from the context, auth parameters (to the endpoint, ), headers...
However when calling the intent, I noticed no network activity related to the webhook. So, the custom webhook is not invoked. Which is the first point of my question: How to trigger or make that when an intent is succesfully matched, the desired webhook is invoked.
I have no issues with the backend, endpoint, it's OK, works well via Postman, curl,... from any service.
My real issue is why, my custom webhook is not triggered, say no network activity, no fetch, no ajax, no nada. NO webhook request. I need to see at least a network request to the custom endpoint, no matter the type of response or the payload, this is not the matter of my question. Just how to send custom webhooks requests and send many, triggered for different intents. As far as I can see, only one custo webhook/endpoint is available.
Should it be invoked via events?
It sounds like you have several questions in there. Let's try to break them down.
Why isn't my webhook being called?
You don't show screen shots of your Intent or your configuration, but the most common reason why a webhook isn't called is because, although you have set the fulfillment URL, you haven't specifically enabled it for the Intent.
Make sure in the "Fulfillment" section at the bottom of your Intent, you have turned on "Enable webhook call for this intent".
That's good for one Intent. How do I set a different webhook for each Intent?
You don't.
Each Dialogflow agent can only call one webhook. The information sent to that webhook includes the Intent Name that is triggering it, and the webhook is expected to take appropriate action based on this name. The exact function that the webhook calls is sometimes referred to as the Intent Handler.
What if I need to?
Then you'll need to write a layer that handles the fulfillment dispatch from Dialogflow, verifies the request, extracts the Intent Name and other parameters from the JSON that is sent, makes the call to the other REST endpoints as appropriate, get the result back, and possibly format the results back to Dialogflow.
Can events help with this?
I don't see how.
Intents that are triggered by an Event work the same way as those that are triggered by user phrases. All Events in an agent still call the same webhook passing the same information.
Events are really most effective to represent exactly that - a user action rather than a the spoken or typed input from a user.
I am creating an app using Dialogflow and Actions on Google Node.js library.
The logic I am trying to implement is as follows:
User says: Initiate chat.
That user request triggers my webhook which then supplies the agent response.
User replies back to the agent - this is the tricky part because the user reply can be anything, thus the wrong Intent or the Fallback Intent can be triggered.
Is there a way to allow for the unpredictability of a user's response and to keep conversation going between user and agent? In another words, always trigger the same Intent (Chat Intent) regardless of what the user says?
In Dialogflow, you can configure the Default Fallback Intent to connect to web fulfillment. In your fulfillment, you can then route the user's query to your webhook and process a response however you'd want.
I have created an intent with an event. I'm sending a POST request as described in the docs with the proper sessionId (that corresponds to my conversation with my Bot On Slack)
When I send the request, the intent is triggered and the response to my request is correct, but there is no message displayed on Slack. I have double-checked the session, it is correct as I have put a context with some values that I can get back in my request's reponse.
Unfortunately it's not possible to send requests to dialogflow to display a message for the user. Your service (slack in this case) can send a query to dialogflow from a user input and then print the response, not the other way around.
What you could do instead is to add another endpoint to slack where your fulfillment can send messages directly to slack. In that case the fulfillment could send a query to dialogflow to get a formatted response and then send the response to slack.
I am new to dialogflow. I have the following requirement.
If user pings from api.i webview , a parameter should be made required.
If user pings from facebook messenger, a parameter should not be made required.
To achieve this, you can mark the value as required in your intent, then tell Dialogflow to use your webhook for slot-filling.
When the intent is matched, your webhook will receive a request that, if from the Facebook integration, will contain the originalRequest from Facebook.
If you detect the Facebook integration, you can respond to Dialogflow from your webhook including a value for the parameter, and Dialogflow will not prompt for it. If you do not detect Facebook, respond without the value and Dialogflow will prompt the user for it.
I have an intent in which I have few responses and webhook enabled. I don't understand how the webhook gets triggered all the time and not the static responses mentioned within intent.
How does the API.ai differentiate when to trigger webhook and when to return static response.
Thanks,
Janmajay
API.AI allows you to connect to third party services using webhooks. If you enable the webhook, then the API.AI will always ask the webhook for the response and will show you the response received from webhook.
If for some reason, the webhook query failed, then only the static text response will be displayed.
If however, you don't want to use webhook and instead want to show the static response then you just need to uncheck the webhook checkbox. After that, the static response will be displayed to the user always.