Using Custom Objects in bots
Create fully flexible and powerful support experiences in your Custom Bots and Resolution Bot with Custom Objects.
Beth-Ann Sher avatar
Written by Beth-Ann Sher
Updated over a week ago

With the added flexibility of storing data in Custom Objects, your customers can automatically be shown information such as recent orders they’ve made, and they’ll be able to select from this object data and even take actions on it such as canceling an order.

1. Create a Custom Object

First, head over to Custom object data in your settings and create a new Custom Object with any fields you require - like price, rating, etc.

2. Create references to people and conversations

Next, head over to your Conversation data in your settings and create a new reference from conversation to your object - in this example, we called our object Order. Here, turn on the "Allow referencing multiple Orders" toggle as one conversation can have multiple orders that it references. Learn more about setting up references with Custom Objects

Then, go to People data and create a new reference to your Orders object. Here also, turn on the "Allow referencing multiple Orders" toggle as one person can have multiple orders that they placed.

3. Set up a Custom Action

The next step is to set up your Custom Action that will fetch the data and store it into the Order object.

When setting up your action, select the references we created in step 2 in the Update references from People or Conversations to Order section of the Response set up:

4. Set up your Custom Bot

Head over to Custom bots and create a new Custom bot with an welcome button and a path that allows the user to see their orders.

In this path, click on the + button, scroll down and choose "Custom action (using API)" :

From the dropdown, choose your Custom Action and then add a fail path to give users some context in case your Custom Action fails to complete:

Then, click on the + button again and this time, choose "Buttons from Custom Objects":

Adding buttons from Custom Objects will allow present you with the "Select data..." and "Save selection to..." drop downs as well as the "None of the above" path :

Click on "Select data..." and a in the modal, pick:

  • From - the object you want to display buttons for, in our case Order object

  • Where - reference attribute to conversation or people, in our case it's "Orders in conversation for Conversation from context". This will display each instance of the object associated with the current conversation

  • What the button should show - for this example, we want to display the name of a product that has been ordered

Next, click on "Save selection to..." and then "Link Conversation to Order":

This will bring you back to Conversation data where you should create a new reference to the Order object that will store the selected selection from your Custom Bot:

Important: Make sure that "Allow referencing multiple Orders" toggle is turned off as this reference will only store a single (selected) object from the Custom bot.

Now go back to your bot (you will have to refresh the bot editor page so make sure to save any changes) and pick the newly created reference attribute:

5. Display data from Custom Object to your user

When the user selects an order, this will save their selection to the Selected order reference and you can display data from that object directly in your bot messages.

To do that, add a new path from the "Select data..." button (Order > Name in this example). Then, you can click on the attribute selector {..} button and choose the appropriate attribute you want to show:

Tip: If you have multiple Custom Object references, you can make sure to pick the correct one by looking at the heading in the attribute selector - for example above, we're picking Conversation > Selected order (order) reference:

And that's it for the bot set up! Set your bot live and you're good to go 🎉

Viewing Custom Object instance data in the Inbox

Once your users start interacting with your bot, you'll want to see what orders did the Custom Action return for their request and what order did they pick.

You can do that by looking the conversation details sidebar. In this example. all fetched orders for the conversation will appear under the "Orders for Conversation" reference attribute and the selected order is stored under "Selected Order":

You can read more about Custom object data in the Inbox here.


Need more help? Get support from our Community Forum
Find answers and get help from Intercom Support and Community Experts

Did this answer your question?