Initial values for conversation with Javascript SDK

  • 7 February 2024
  • 5 replies


I would like to know if it is feasible to initialize conversation attributes when using the javascript SDK.

I'm working on integrating the Intercom JavaScript SDK into an e-commerce platform. Our goal is to embed the Intercom messenger on the order confirmation page, so customers can inquire about their recent purchase without re-entering their order ID.

We have tried to initialize custom parameters using

Intercom(‘update’, {...})

However, this seems to only have an effect for People Attributes and not Conversation Attributes. We need to pass the order ID into the conversation context, as our support flow heavily relies on this information. Since a customer may have multiple orders, setting the order ID as a People attribute isn't a viable solution.

Are there methods within the Intercom SDK to initialize conversation attributes directly, or a workaround that could suit this use case? We're open to alternative approaches if there's a more effective way to achieve this user experience. Any insights or suggestions would be greatly appreciated.


Best answer by bernice 12 February 2024, 15:51

View original

5 replies

Userlevel 3
Badge +3

Hey there,  @Vassilis Lahanas 👋 You’re correct - only People attributes can be updated via the JavaScript API. You have the option of using the REST API to update Custom Conversation data attributes here, you could achieve this via the Update a Conversation endpoint, see more in our Developer Documentation here 📌

Another option for you here would be to use a Custom Action in this case - the example found in this article from the Intercom Help Center is pretty similar to your use case here! We have plenty of other articles and resources on how to setup and get your Custom Action running here, particularly this article on implementing your new Custom Action into a Workflow 📌 Hope this helps 🚀

Thank you @bernice! Indeed custom action is something that we are already using, but in order to trigger the action, we need to “feed” it with an order id (and some other fields). This is exactly what we are trying to figure out how to do. The available options seem to be:

1. Use SDK to set people attributes (won’t play well with customers having multiple orders)
2. Ask user to provide it (bad UX, since the user is already inside an order confirmation page)

So I am trying to figure out if there is a 3rd option, ideally setting conversation attributes programmatically. 

Userlevel 3
Badge +3

Thanks for the further info of your goal what you’re hoping to achieve here, @Vassilis Lahanas 🙂 It would require some developer work on your end, but an option here would be to implement a webhook to run when a customer opens up a Conversation on a certain URL related to their order - the conversation.user.created webhook topic may come in handy for you here. You then could use the REST API to update your custom Conversation data attribute here, you could achieve this via the Update a Conversation endpoint.

Thanks once again @bernice!

Your suggestion sounds feasible, as long as the payload that we would receive in the webhook (Conversation object) could include something that would let us identify which order it refers to. But if we had this piece of information, the webhook would not be needed anyway. It is a bit of a chicken and egg problem :)

Do you have something particular in mind? 


Userlevel 4
Badge +5

@Vassilis Lahanas , are you trying to access the User’s order while they are in a workflow? If so, as long as you know who the user is, you can run a custom action in the workflow that looks up that User’s orders and delivers them to them in the Workflow. 

The custom action would use the user information to make an API call to your orders database. That can then return the most recent order number (or the last 5 order numbers) and send them back to the user as buttons for them to choose from. They can click the button with the order # that they need details on. That, in turn can make a custom action call to get the details of the specific order and deliver that to the User.

This article discusses how to use custom action and custom objects in workflows to set up such a system.