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.
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 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 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.
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 a case where I need to create a Bot in Slack that my users can use conversational language to get information out of my web app in real time. The scenario goes something like:
User asks the bot something like: #hrbot How many employees are in the Finance department?
Bot send the string to API.AI/ diagflow to resolve into a JSON request
API.AI sends the JSON request to my Web App endpoint via webhook to get the answer
Answer is returned to user's Slack channel
Question:
1. How do I get the auth token from api.ai to send message to slack?
With Dialogflow (formerly API.AI) you provide a webhook (a HTTPS URL where your server is) and Dialogflow will send a HTTPS request to your webhook when requests come to your Dialogflow agent. You can enable the Slack integration in your Dialogflow agent through the web interface and all requests from Slack will be sent to your Dialogflow agent and (if you configure it) to your webhook with NLU information and the original request from Slack.
Information about the request that is sent to your webhook is documented here: dialogflow.com/docs/fulfillment#request if you respond to the request the response will be forwarded to the user that trigger the request. The response format is documented here: dialogflow.com/docs/fulfillment#response