Skip to Content

Add Webhook to Chatbot to Retrieve Tracking Info

Add a webhook call in the package-tracking chatbot to retrieve information for a specific tracking number, using SAP Conversational AI.
You will learn
  • How to set a default webhook endpoint
  • How to call a webhook during a conversation
  • How to display the response
thecodesterDaniel WroblewskiFebruary 13, 2022
Created by
thecodester
September 22, 2021
Contributors
thecodester

Prerequisites

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
    1. Open your shippingbot bot.

    2. At the top right, click Settings.

      Endpoint
    3. Click Versions, and then click the arrow to the right of v1.

      Versions
    4. In the Bot Builder field, enter the endpoint to our application on SAP Business Technology Platform: https://sapupschatbot.cfapps.eu10.hana.ondemand.com

    5. Click Save.

    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.

    Log in to complete tutorial
  • Step 2
    1. Go back to the Build tab, and click the track-parcel skill.

    2. Go to Actions.

    3. Click Add New Message Group (at the bottom).

      Add group
    4. Click Add Condition.

      After If, click in the field and select @Yes, and then click Save.

      Click Connect External Service | Call Webhook

      Add webhook

      For the URL, enter /track_parcel, and click Save.

      Service path

      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.

      Unset memory

      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.

    Log in to complete tutorial
  • Step 3

    You can now test it by starting a conversation to trigger the @track-parcel intent, supplying the tracking number (e.g., 1Z12345E6205277936), and saying Yes, you want to track the package.

    Conversation with API

    The API to retrieve package information is retrieved if which intent `is-present`? Write it as it appears in the Actions subtab.

    Log in to complete tutorial
Back to top