2

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?

digitai
  • 1,870
  • 2
  • 20
  • 37

1 Answers1

2

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".

Callout to fulfillment webhook

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.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Thanks @Prisoner, your answers clarify ideas and show a path on how to go forward. Looking for, I found that yes indeed the request was done however it was passed through GCP via a api.dialogflow request, for sure via intentHandler, no direct request to the server. – digitai Apr 30 '20 at 14:58
  • do you know why when requesting webhook from DialogFlow console, I receive the response from the custom webhook as expected, however when testing the web embedded demo, No response is received, instead the default response is displayed. – digitai Apr 30 '20 at 15:49
  • 1
    It sounds like this is a different issue, so you might want to open up a new question, providing screen shots, logs, and as many other details as you can that illustrates what you're seeing. – Prisoner Apr 30 '20 at 21:07
  • Yes, I agree, it's another creature, meanwhile I succesfully managed to fulfill this question, by your suggestion, handling many requests, now my agent is able to make different requests, one per intent!!! via a handler per intent. – digitai Apr 30 '20 at 22:04
  • 1
    Glad we were able to help! – Prisoner Apr 30 '20 at 22:15