Add Webhook to Chatbot to Retrieve Tracking Info
- How to set a default webhook endpoint
- How to call a webhook during a conversation
- How to display the response
- You have created the chatbot for letting customers request information on their packages, as described in Create a Chatbot that Lets Customers Track Packages.
In the previous tutorial, you created a chatbot to detect the intent of customers who want to track a package and to get the needed information.
In this tutorial, you will modify the chatbot so it calls an API to retrieve information on the package, based on a tracking number, and displays that information to the customer.
- Step 1
At the top right, click Settings.
Click Versions, and then click the arrow to the right of
In the Bot Builder field, enter the endpoint to our application on SAP Business Technology Platform:
This endpoint contains a Python demo script that makes all kinds of API calls, including retrieving package information from UPS. It is described in this blog.
- Step 2
Go back to the Build tab, and click the track-parcel skill.
Go to Actions.
Click Add New Message Group (at the bottom).
Click Add Condition.
After If, click in the field and select @Yes, and then click Save.
Click Connect External Service | Call Webhook
For the URL, enter
/track_parcel, and click Save.
Click Update Conversation | Edit Memory.
In the Unset memory field, and enter
yes(the value is case-sensitive). Click Add Fields, and enter
parcel-number. Finally, click Save.
We erase the parcel number because once the user tracked that parcel, it is unlikely they will want to track it again. This way, they can ask to track another parcel.
- Step 3
You can now test it by starting a conversation to trigger the
@track-parcelintent, supplying the tracking number (e.g.,
1Z12345E6205277936), and saying Yes, you want to track the package.
The API to retrieve package information is retrieved if which intent `is-present`? Write it as it appears in the Actions subtab.