Answered

JS API error handling

  • 21 July 2023
  • 3 replies
  • 203 views

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.

icon

Best answer by Eden 27 July 2023, 01:25

View original

3 replies

Userlevel 3
Badge

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 "https://api-iam.eu.intercom.io/messenger/web/home
* are successful, or false if not
*/
window.Intercom(‘booted’)


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 **/ });

Reply