Tag Archives: webhook

Building bot-ready knowledge bases #9: Adding a webhook to our GROCERYbot project

Our experimental initiative to prototype a bot-ready information solution using Google’s Dialogflow

This post is part of a series. For more information and links to other posts in the series, see the “Building bot-ready knowledge bases” home page.

We’re extending our GROCERYbot series of posts with information about some of our follow-on Dialogflow projects. This one is about a webhook we added to GROCERYbot.

Two of the original DITA/XML-based files had tabular information that provided prices of various grocery items. The following image shows an example.

DITA/XML PDF output file: Prices of canned goods
DITA/XML PDF output file: Prices of canned goods

Out Dialogflow-based chatbot could not extract this information from the knowledge base, and could therefore not answer price queries from a user.

To correct this defect we added webhook fulfillment to GROCERYbot to allow it to look up information in an external data repository and return it in response to a user query about price. Our example is very simple, but it illustrates how a webhook works.

You can see the Dialogflow processing flow for fulfillment here.  In the GROCERYbot chatbot we have an intent named “UserAsksForAttributeOfCannedGood.” That intent handles questions from a user about the prices of canned goods. An example user query might be “tell me the price of large black olives.”

In this intent we have selected webhook fulfillment:

Selecting fulfillment
Selecting fulfillment

In the Fulfillment section of our GROCERYbot agent, we have specified the URL that leads to our webhook:

Specifying the webhook URL
Specifying the webhook URL

Once this setup is complete, every time the intent is selected, a call is made to the pricehook.php script running in an external web server. The argument to the script is a json object that contains, among other things, the entity parameter detected in the user input. For example, this might be “large black olives.” The script uses that parameter as a key to look up the price and return it in a response to the user. Dialogflow then displays the response.

Here is a sample of what gets returned to the user after the webhook has been invoked:

Webhook example query
Webhook example query