SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Let Customers Ask Chatbot for Shipping Price

Create an intent for requesting the price of shipping a package, use the carousel for selecting a package size, call an API to retrieve a Google map, retrieve memory data and put in the message.

Overview

🎓 beginner 30 min. SAP Conversational AiBeginnerArtificial IntelligenceMachine LearningSAP Business Technology Platform

You will learn

  • How to create a restricted entity
  • How to enrich data in an entity
  • How to call an webhook to retrieve a Google map
  • How to retrieve data from memory, and to reset the memory
Unknown U Unknown November 4, 2022
Created by September 22, 2021
Contributors

Prerequisites

Prerequisites

Steps

Intro

You will add features to your chatbot to answer customer questions about pricing a package, require customers to include a size and location, to validate the location, show a Google map when a location is validated, and to display a message with data from the memory.


Step 1 Create entity for parcel size

When a customer indicates they want to price a package, you have to know the size of the package. So our bot must be able to extract the parcel size from the conversation.

So create an entity for the parcel size. But in this case, create a restricted entity – which only recognizes a fixed set of valid values.

  1. Go to Train | Entities.

    • Click Create.

    • Enter parcel-size for the name.

    • Specify Restricted entity.

    • Click Create.

      Create parcel-size
      Create parcel-size

      You now have a second entity.

      parcel-size
      parcel-size

  2. Enter the valid values for this entity.

    And instead of you entering each size separately, we have supplied the sizes in a CSV file. Do the following:

    • Download the CSV file, which contains a fixed set of sizes expressed in various ways.
    • Click the new entity.
    • Click Import a CSV File.
    • Click Browse and select your file.
    • Click Upload.

    Refresh the page, if necessary.

    Entity list
    Entity list

  3. You will want to return a shipping price based on the size. So “enrich” the entity’s data, setting a price value that the bot will add into memory when the entity is detected.

    • Go to Enrichments, and then select Map Enrichments (you may need to confirm by clicking Validate).

      Go to Enrichments
      Go to Enrichments

    • Click Add New Pair, enter name and null (the default value), and then press Enter.

      Add pair
      Add pair

    • Click again Add New Pair, enter price and null, and then press Enter.

    • Add 4 enrichment groups. For each, click Add New Group, specify a name ( >10kg, 3-10kg, 1-3kg or 0-1kg ), and then click Save.

      For each group, click the pencil icon, select the corresponding entity values for the group, and set the values for the fields name and price.

      Values must be in JSON format, so name must be enclosed in quotes.

      The groups should look like the following:

      Enrichments
      Enrichments

What’s going on?

When a customer enters a size, the bot detects this as the #parcel-size entity. It then sees what group the entity value is part of, and then adds the additional fields in the memory, which can then be used in subsequent conversation.

Try it out.

Go to the Test panel on the right, and enter small. You can see it was detected as an entity #parcel-size.

Link text e.g., Destination screen
Link text e.g., Destination screen

Change to the JSON view, and you can see that the enrichments were added, based on the value of the entity.

Link text e.g., Destination screen
Link text e.g., Destination screen

Step 2 Add intent for requesting shipping price
+
Step 3 Build skill for requesting shipping quote
+
Step 4 Add requirements to skill
+
Step 5 Call API to show Google map
+
Step 6 Display confirmation
+
Step 7 Display results
+
Step 8 Test the bot
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 8
1. Create entity for parcel size 2. Add intent for requesting shipping price 3. Build skill for requesting shipping quote 4. Add requirements to skill 5. Call API to show Google map 6. Display confirmation 7. Display results 8. Test the bot

Learn more →