JS API error handling

  • 21 July 2023
  • 3 replies

The JS API has no documented methods for capturing and handling errors. Is there an undocumented callback that can be used to capture and gracefully handle errors? If not, why not? Both the Android and iOS SDKs have error handling but there is zero documented error handling for the JS API. This makes the API far less useful.

All assistance appreciated.


Best answer by Eden 27 July 2023, 01:25

View original

3 replies

Userlevel 3

Hey @Tom Tupper 👋 Eden from the support engineer team here.


We don't have specific documentation that outlines JS error handling, however this article here outlines some potential situations where errors may arise and how to troubleshoot them. 


We typically take a look at the browser console to see errors that come up when troubleshooting, however having error handing for the JS API is a great feature request! 

I’m in a similar situation as @Tom Tupper

We want to gracefully handle errors thrown by the chat and currently there is no way to do this.

An example use case would be:
1. If the Intercom chat fails to load
2. Show a fallback message telling users to communicate via email

Currently, there is no way to know if the Intercom chat loaded correctly nor listen to chat errors.

Ideally, we’d be able to use something like:

window.Intercom(‘onError’, () => { // Do something when Intercom fails to load })

or at least check the status of Intercom

* Return true when calls to "
* are successful, or false if not

We also have identity verification set up for this project, so there are a lot of moving pieces working together. It’s too optimistic to think that Intercom will never fail to load.

i too would appreciate a callback or any other mechanism to guard against situations in which intercom failed to load entirely.

Intercom('show', function(err) { /** handle 403 or other error **/ });