The dialer session
ProjectBlueDialer is one calling session for one line. Create it with a tokenProvider, call start(), and keep it alive for as long as the user can place or receive calls.
On this page
Options
tokenProvider() => Promise<TokenResponse | ErrorBody | string>RequiredrefreshLeadSecondsnumberdefault: 60loggerconsole-like | nulldefault: console (warn/error only)edgestring | string[]playIncomingRingtonebooleandefault: trueWriting the tokenProvider
It runs whenever the SDK needs a token: at start(), about a minute before the current token expires, and before a token has been used for its tenth call. It must call your server, never the mint directly.
Return the mint body unchanged. To report a refusal, throw mintErrorFromResponse(res.status, body) — it returns null on a 2xx and the matching typed error otherwise, so the three-line pattern in the rail is the whole thing. If you would rather return the error body, add status to it first; without it the SDK reports 402 for a cap refusal and 400 for everything else.
Methods
start()Promise<void>call(to)Promise<DialerCall>to must be E.164 with the leading +; spaces, dashes and parentheses are stripped, but a country code is never guessed. One call at a time — a second call() while one is active throws invalid_state.refreshToken()Promise<void>destroy()Promise<void>isReady()booleanGetters
allowanceDialerAllowance | nullstart().inboundEnabledbooleanactiveCallDialerCall | nullEvents
Subscribe with dialer.on(event, handler); off and once work the same way.
ready{ inboundEnabled }allowanceDialerAllowancecapReachedDialerCapReachedErrorincomingDialerCalltokenRefreshFailedDialerErrorerrorDialerErrordestroyed—Token refresh, in detail
You never manage tokens directly, but knowing the schedule explains what your server will see. The session refreshes 60 seconds before expiry by default, immediately before the call that would exceed maxCallsPerToken, and whenever the voice service reports the token invalid. A failed refresh emits tokenRefreshFailed and retries after 5, 15, then 45 seconds; the current token keeps working until it expires.
A cap_reached refusal is different: the session emits capReached, stops retrying, and wakes itself one second after periodEnd. A call that is already up is never cut off — caps apply at mint time only.