Entity reference field

When defining CMS Entity, sometimes you might need to link an Item in an Entity to an Item of another Entity. Let's assume that we have a chatbot for a laptop store. This store sells laptops from some providers such as Dell, Apple, Asus, etc. Each provider owns different product lines of laptops. For example, Apple has Macbook Air 2017, Macbook Air 2018, Macbook Pro 2018, etc.

Create CMS Entity Reference

We have 2 Entities:

  • Provider (illustrating the list of providers: Dell, Apple, Asus) includes the Name field which displays the name of a provider.
  • Laptop (illustrating the list of laptops: Macbook Air 2017, Macbook Air 2018, Macbook Pro 2018, Dell XPS 13) includes Name, Provider. Each item of the Laptop entity belongs to an item of Provider entity:
    • Name displays the name of a Laptop (default field).
    • The Data type of this field is Entities Reference and this field is referred to the Provider entity.
    • Besides, you can also add the field of Photo, Price to provide detailed information for the product.

Select the item for association from within the Item Detail form like the picture below once you have set up the Reference relationship between any 2 Entities:

Understanding the relationship between Entities will make your bot:

  • Clear, clean, and time-saving.
  • More flexible: Blocks are automatically updated once you make any change to the data in these Entities.

Use CMS Reference in Block

Follow these steps to accomplish the use of CMS Reference in Block:

1. Select CMS for Quick Reply to make a list of items of the Provider entity.

2. Enable Expect User Response to Save the response for this block. When the chat user chooses one of the Quick Reply buttons, an item of Provider entity which is corresponding to will be saved.

3. Utilize the CMS Reference to filter appropriate items based on the Provider field (which is referred to the Provider entity).

4. Use Horizontal List block to list items from Laptop entity.

5. Filter suitable Laptop items based on the response of the previous block.

Result: When you select Apple, the laptop product line of this brand will be shown. Similarly, if you select Dell, only Dell laptops are listed.

Update items in CMS

Whenever you update the item lists of the Provider entity and Laptop entity, the blocks in the Canvas will automatically update corresponding Quick Responses buttons or in the Horizontal block. You don't need to make a change or add any other blocks in Bot Builder.

For example, we try adding one more item (Microsoft) into the entity Provider in CMS. Meanwhile, add one more item (Surface Pro) which is linked to Microsoft Entity into the Laptop entity. These recent changes will automatically be updated in the Bot Builder.

If you have any concerns, please feel free to leave a comment below or contact us through support@botstar.com. For more details on how we have helped our customers grow their business, you can view our use cases, blogs or join our BotStar community to learn and share new things 😊

Did you find it helpful?   Yes   No