Build
Events and errors
Everything the window tells your page, and every error code you may see.
The window tells your page what is happening with small events. Listen with iungo.on(type, handler). Every handler receives one object with the payload shown below.
const iungo = window.iungoClient()
const stop = iungo.on('call:ended', ({ callId, reason, durationSeconds }) => {
analytics.track('iungo_call_ended', { callId, reason, durationSeconds })
})
// later, to stop listening:
stop()Events
| Event | Payload | When |
|---|---|---|
screen | { name } | The visible screen changed. name is signup (sign-up or log-in), topup, precall, call or result. |
auth:signed-in | { userId, isNewUser } | The visitor signed up or logged in. userId is iungo’s id for them. |
auth:signed-out | none | The visitor signed out. |
balance:changed | { sufficient } | Whether their wallet covers a call. The amount is never shared. |
payment:started | none | A top-up began. |
payment:completed | none | The top-up finished and the wallet was credited. |
payment:failed | { code } | The top-up did not complete. PAYMENT_FAILED, PAYMENT_CANCELLED or PAYMENT_PENDING_TIMEOUT. |
call:ringing | { callId, talentId } | The call was placed and is ringing for the host. |
call:started | { callId, talentId } | The host answered and the call connected. |
call:ended | { callId, talentId, reason, durationSeconds } | The call is over. durationSeconds is what iungo billed. |
closed | { reason } | The window is gone. See the reasons below. |
error | { code, message, retryable } | Something went wrong. See the error codes below. |
callId is iungo's id for the call, and talentId is the host's iungo id.
call:ended reasons
| reason | Meaning |
|---|---|
user_ended | The visitor ended the call, or cancelled it while it was ringing. |
talent_ended | The host ended the call. |
declined | The host declined it. |
missed | Nobody answered. |
balance_exhausted | The visitor’s balance ran out during the call. |
failed | The call could not connect. |
closed reasons
| reason | Meaning |
|---|---|
host | Closed from your page's side: your code called close(), or the visitor used the close button or Escape on the modal. (Here “host” means the page that embeds the window.) |
user | The visitor left from inside the window, for example by choosing “I’m under 18”. |
completed | The visitor finished the flow and pressed Done. |
A typical first call
The exact order can vary, but a new visitor who tops up and calls usually produces:
screen { name: 'signup' }
auth:signed-in { userId: '…', isNewUser: true }
balance:changed { sufficient: false }
screen { name: 'topup' }
payment:started
payment:completed
screen { name: 'precall' }
screen { name: 'call' }
call:ringing { callId: '…', talentId: '…' }
call:started { callId: '…', talentId: '…' }
call:ended { callId: '…', talentId: '…', reason: 'user_ended', durationSeconds: 184 }
screen { name: 'result' }
closed { reason: 'completed' }Errors
Errors arrive as error events and as rejections of the methods that open the window. Both carry the same three fields: code, message and retryable. Branch on code, never on message, which can change.
| code | Meaning | What to do |
|---|---|---|
EMBED_TIMEOUT | The window did not load in time. | Check the key and that this address is registered for it. See Troubleshooting. |
CLIENT_UPDATE_REQUIRED | This SDK version is too old for the window. | Move to a newer SDK file. |
TALENT_UNAVAILABLE | The host cannot take calls right now (they are busy, or have switched website calls off). The window already tells the visitor. | Nothing needed. You can hide your button for a while if you like. |
POPUP_BLOCKED | The browser blocked the payment window. | Ask the visitor to allow pop-ups, then retry. |
CALL_FAILED | The call could not connect. Retryable. | The visitor can try again. |
NETWORK | A network problem. | Retry. |
INTERNAL | An unexpected problem. | Retry. If it keeps happening, contact support with the time it happened. |
Other codes are reserved for future use. Handle any code you do not recognise by falling back to the retryable flag and the message.
Something missing or unclear? Tell us.

