Skip to content

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.

javascript
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

EventPayloadWhen
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-outnoneThe visitor signed out.
balance:changed{ sufficient }Whether their wallet covers a call. The amount is never shared.
payment:startednoneA top-up began.
payment:completednoneThe 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

reasonMeaning
user_endedThe visitor ended the call, or cancelled it while it was ringing.
talent_endedThe host ended the call.
declinedThe host declined it.
missedNobody answered.
balance_exhaustedThe visitor’s balance ran out during the call.
failedThe call could not connect.

closed reasons

reasonMeaning
hostClosed 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.)
userThe visitor left from inside the window, for example by choosing “I’m under 18”.
completedThe 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:

text
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.

codeMeaningWhat to do
EMBED_TIMEOUTThe window did not load in time.Check the key and that this address is registered for it. See Troubleshooting.
CLIENT_UPDATE_REQUIREDThis SDK version is too old for the window.Move to a newer SDK file.
TALENT_UNAVAILABLEThe 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_BLOCKEDThe browser blocked the payment window.Ask the visitor to allow pop-ups, then retry.
CALL_FAILEDThe call could not connect. Retryable.The visitor can try again.
NETWORKA network problem.Retry.
INTERNALAn 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.