Skip to main content

I am using the @intercom/messenger-js-sdk SDK.

It successfully records new users.

The problem is that I cannot find how to set custom attributes for that user. I have the custom attribute `is_admin`.

 

Here are the approaches I’ve tried:

  1. Basic object
Intercom({
app_id: APP_ID,
api_base: process.env.NEXT_PUBLIC_INTERCOM_API_BASE_URL,
user_id: user.id,
email: user.email,
user_hash: hash,
is_admin: user.role.includes('admin'),
});
  1. Object with custom_attributes
Intercom({
app_id: APP_ID,
api_base: process.env.NEXT_PUBLIC_INTERCOM_API_BASE_URL,
user_id: user.id,
email: user.email,
user_hash: hash,
custom_attributes: {
is_admin: user.role.includes('admin'),
}
});
  1. Post instance update method
Intercom({
app_id: APP_ID,
api_base: process.env.NEXT_PUBLIC_INTERCOM_API_BASE_URL,
user_id: user.id,
email: user.email,
user_hash: hash,
});

update({
user_id: user.id,
email: user.email,
is_admin: user.role.includes('admin'),
});

None of these approaches work. `is_admin` is always unknown.

Please let me know the correct approach for uploading custom attributes via the SDK or point me towards the correct documentation (I’ve found all 3 of the above approaches in various parts of the documentation - none of which are working).

Thanks

Hey there ​@Fergus Farrell, Emily here from Support Engineering at Intercom 👋🏼
 

To set custom attributes for a user using the @intercom/messenger-js-sdk, you should use the updateUser method. Here's how you can set the is_admin attribute for a user:

Intercom.updateUser({
  customAttributes: {
    is_admin: true
  }
});


This will update the user's information with the is_admin custom attribute set to true. If the is_admin attribute is not recognized by Intercom, it should be created automatically upon updating the user with this attribute. It's important to note that you can send only the data you want to update; you do not need to send every attribute each time. Once updated, you can view these attributes in the Intercom dashboard under the "USER DATA" section in the Inbox's right-hand sidebar. If you continue to experience issues, ensure that you are using the correct syntax as per the SDK documentation and that the SDK is properly initialized and configured in your application. For more details on using the updateUser method with the Intercom SDK, you can refer to the Intercom documentation for React Native or the relevant SDK documentation for your platform.

Hopefully this helps! 💪🏼


Reply