For vue2 projects, use @94ai/common-ui
LLMs.md

nf-softphone ​

Integrates the shared 94AI online web softphone microfrontend through qiankun or wujie. Features include outgoing and incoming calls, transfer to an agent, answering, ignoring, hanging up, breaks, network diagnostics, muting, real-time volume tracking, agent sign-in/sign-out, chat text retrieval, and agent monitoring log reporting. Action dispatch and callback notifications integrate the common softphone capabilities currently available. NfSoftphone is an SFC for MVVM applications. Use the default nfSoftphone instance for a single phone, or construct multiple instances with new nfSoftphoneManager(). The name property isolates the microfrontend applications.

Exports ​

ts
import NfSoftphone, { nfSoftphone, nfSoftphoneManager, createSoftphoneSign, createSoftphoneAccessToken, createSoftphoneToken, installSoftphoneCryptoJS, SOFTPHONE_CRYPTO_JS_CDN_URL, waitForSoftphoneRender } from '@94ai-plus/nf-softphone'
import type {
  SoftphoneAccessToken,
  SoftphoneAccessTokenResult,
  SoftphoneAccessTokenOptions,
  SoftphoneTokenOptions,
  SoftphoneEnv,
  SoftphoneMode,
  SoftphoneSignDone,
  SoftphonePayload,
  SoftphoneMessageType,
  SoftphoneEnvironment,
  SoftphoneSign,
  SoftphoneCryptoJS,
  SoftphoneSignOptions,
  SoftphoneState,
  SoftphoneShared,
  SoftphoneConnection,
  SoftphoneMountConfig,
  SoftphoneRuntime,
  SoftphoneProps,
  SoftphoneCallbacks,
  SoftphoneOptions,
  NfSoftphoneComponent
} from '@94ai-plus/nf-softphone'
import '@94ai-plus/nf-softphone/style.css'

Debug signatures ​

ts
import { createSoftphoneSign } from '@94ai-plus/nf-softphone'

const appKey = 'xxx'
const appSecret = 'xxx'
const signedAt = Date.now()
const nextSign = await createSoftphoneSign(appKey, signedAt, appSecret, {
  // env: 'sg',
  // cryptoJsUrl: '',
})
Signature optionsCryptoJS script URL
env: 'sg'https://seat.teleai.com/CryptoJS.js
Default/dev/test/gray/prodhttps://seat.94ai.com/CryptoJS.js
cryptoJsUrlCustom script URL; overrides the default URL selected by env
ts
import { installSoftphoneCryptoJS } from '@94ai-plus/nf-softphone'

const appKey = 'xxx'
const timestamp = Date.now()
const appSecret = 'xxx'

const CryptoJS = await installSoftphoneCryptoJS({
  // env: 'sg',
  // cryptoJsUrl: '',
})
// CryptoJS === window.CryptoJS // Expose window.CryptoJS for signature debugging
const sha1 = CryptoJS.HmacSHA1(appKey + timestamp, appSecret)
sign.value = CryptoJS.enc.Base64.stringify(sha1)

General integration ​

Examples pass lang="en" to the phone bar. Other documentation languages use zh, ja, es, id, th, tl, or pt. Switching the documentation language destroys and remounts the example with the new language; it is not a seamless language change during a call. Loading and phone content share one area: an opaque loading layer covers rendering content until detection completes, then reveals it at once. The mount container stays measurable, with no fixed delay.

Online examples render an unconnected preview phone bar by default without embedded secrets. Enter test appKey, appSecret, and agentTag values in the editor to generate credentials and load the live phone bar.

Async setup ​

The loading slot appears while the microfrontend loads. Its default “Loading...” text follows the component-library locale. It disappears only after visible phone-bar content renders and browser paint frames complete, not merely after mounting; it does not wait for agent sign-in. qiankun containers and Wujie Shadow DOM / accessible same-origin iframes are supported. Loading failures or no visible content within 30 seconds after mounting show the error slot. Retrying shows loading again.

Loading example…
Async setup requires a parent <Suspense>. Generate production signatures on your backend; do not keep secrets in frontend code. Shows an unconnected preview by default; fill in appKey, appSecret, and agentTag to load.

Async onMounted ​

Disable automatic startup and obtain the signature asynchronously after mounting. Use nextTick() to synchronize the signature and timestamp to child props before calling initSoftphone(). Component unmount automatically destroys the phone, and a late signature response will not initialize it again. The component ref’s initSoftphone() waits for rendering detection to finish.

Loading example…
Without async setup, use :auto-start="false". Generate production signatures on your backend; do not keep secrets in frontend code. Shows an unconnected preview by default; fill in appKey, appSecret, and agentTag to load.

Overseas environment ​

Domestic and overseas accounts are separate. To use the overseas environment, set env="sg", sg-open="1", sg-domain="1", sg-base="1", and sg-gateway="1". Pass { env: 'sg' } when generating the signature as well.

Loading example…
Overseas environment. Generate production signatures on your backend; do not keep secrets in frontend code. Shows an unconnected preview by default; fill in appKey, appSecret, and agentTag to load.

accessToken authorization ​

Use accessToken instead of sign to authorize and load the phone bar. This example obtains an overseas token with createSoftphoneAccessToken(appKey, appSecret, { env: 'sg' }). It renders an unconnected preview bar by default; enter test appKey, appSecret, and agentTag values in the editor to fetch a token and load the live phone bar. Initial loading and renewal both call this helper, without loading the softphone SDK.

Loading example…
accessToken authorization: fetch credentials after mounting, start manually, and renew through createSoftphoneAccessToken. In production, generate accessToken on your backend and keep secrets out of frontend code. Shows an unconnected preview by default; fill in appKey, appSecret, and agentTag to load.

Custom runtime ​

This example uses an offline simulated runtime to demonstrate action dispatch and callback notifications. It neither loads a real microfrontend nor places calls. runtime replaces the built-in qiankun / wujie loader. For a real phone bar, remove :runtime="runtime" and provide valid agent information and a signature. The runtime customizes loading, communication, and unmounting.

Loading example…
Intercept dispatched actions and invoke notification callbacks manually

Library integration (factory) ​

loading starts when signature retrieval begins. phone.ready only signals that the microfrontend mounted; then call waitForSoftphoneRender(host) and wait for visible phone-bar content before ending loading. It shares detection logic with NfSoftphone, defaults to a 30-second timeout, accepts a custom timeout in milliseconds as its second argument, and returns { ready, cancel }. Call cancel() on unmount to stop detection if the page disappears before the phone renders. Calling it after completion has no further effect. Do not hide the container with v-if / v-show during loading, or mounting and visible-content detection cannot work.

Loading example…
Manager integration. Generate production signatures on your backend; do not keep secrets in frontend code. Shows an unconnected preview by default; fill in appKey, appSecret, and agentTag to load.

Library integration (singleton) ​

For multiple phones, use the constructor with unique name, ancestorOrigin, and destinationOrigin values. The singleton mounts only one phone bar. Ordinary prop updates synchronize shared configuration. Destroy the instance before changing mode, URL, environment, name, or communication namespaces.

Loading example…
Singleton integration. Generate production signatures on your backend; do not keep secrets in frontend code. Shows an unconnected preview by default; fill in appKey, appSecret, and agentTag to load.

Credential helpers ​

Use these helpers for local integration debugging. Production secrets and credential generation belong on your backend.

APIResult
createSoftphoneAccessToken(appKey, appSecret, options?)Returns an OpenAPI access token and the millisecond timestamp used for its request.
createSoftphoneToken(appKey, appSecret, options)Returns an agent-system token string, distinct from OpenAPI accessToken.

Both helpers accept env, cryptoJsUrl, and signal for cancellation; requests time out after 15 seconds. createSoftphoneAccessToken also accepts openGatewayUrl and accessTokenTimestamp. createSoftphoneToken accepts agentId / agentTag, openGatewayUrl, and openBaseUrl; agentId takes priority, while agentTag triggers an agent-ID lookup. Use env: 'sg' overseas; other environments default to domestic gateways.

envopenGatewayUrlopenBaseUrl
default / dev / test / gray / prodhttps://seat.94ai.com/openapigatewayhttps://seat.94ai.com/openapi
sghttps://seat.teleai.com/teleaiopenapigatewayhttps://seat.teleai.com/teleaiopenapi
ts
import { createSoftphoneAccessToken, createSoftphoneToken } from '@94ai-plus/nf-softphone'

const credentials = await createSoftphoneAccessToken(appKey, appSecret, { env: 'sg' })
const token = await createSoftphoneToken(appKey, appSecret, { env: 'sg', agentId })
const tokenByTag = await createSoftphoneToken(appKey, appSecret, { env: 'sg', agentTag })

Props ​

Prop / optionTypeDefault / meaning
mode'qiankun' | 'wujie'qiankun
env / envMapSoftphoneEnv / Partial<Record<SoftphoneEnv, SoftphoneEnvironment>>Defaults to prod; supports dev / test / sg / gray / prod
urlstringOptional HTTP(S) microfrontend entry override; query parameters are preserved
namestringThe component generates a unique name; the manager defaults to nf-microphone
originstringThe previous-source identifier of an action notification, used to isolate communication namespaces when multiple qiankun / wujie instances share one bus. For manually triggered instance actions, filter self-notifications and accept only notifications from the phone on the shared bus. Defaults to ai-softphone. The legacy iframe approach isolates DOM / communication through different iframe contentWindow objects and may omit this option; this package only provides qiankun / wujie integration, not the legacy iframe mode.
ancestorOriginstringThe original-source identifier of an action notification, used for multi-instance namespace isolation. Only respond to phone notifications caused by this instance’s manual actions; filter notifications caused by other instances on the shared bus. The manager defaults to nf-softphone; the Vue component derives a unique namespace from name when not explicitly configured.
destinationOriginstringThe designated responding-source identifier for multi-instance namespace isolation. When notifications across instances share the same origin and ancestorOrigin (for example, remote applications using ai-softphone), only the designated instance responds. The manager defaults to *, a wildcard destination identifier; the Vue component derives a namespace from name unless explicitly configured.
agentId / agentTag / appKey / appSecretstringBusiness credentials; prefer backend-issued signatures and do not retain appSecret in frontend code
sign / timestampstring/string or numberUse Vue v-model:sign / v-model:timestamp for two-way binding
accessToken / accessTokenTimestampstring / string / numberServer-issued access token and optional timestamp, forwarded through shared.getUserInfo(). Supports v-model:accessToken / v-model:accessTokenTimestamp. The softphone-access-token-overdued event receives done({ accessToken, accessTokenTimestamp }); managers use softphoneAccessTokenOverduedCallBack. shared.setUserInfo() and renewal emit the corresponding update:* events.
extStatusstringDefaults to 1 for online; other values indicate a break. Control this externally to keep state transitions consistent
callShow / transferToLaborShow / restShow / networkDetectShow / muteShow / logShow / timingShow / signShow'0' | '1'Defaults to 1; 0 hides the corresponding outgoing-call, transfer-to-agent, break, network-diagnostics, mute, call-history, accumulated-status-time, or sign-in/sign-out control
langstringDefaults to zh; supports id, es, ja, en, zh, pt, th, tl
extensionInfoobjectExtension information including status, wsRegisterAddress, wsProtocol, and accountCode
extPassword / extensionNumber / wsRegisterAddress / wsProtocolstringExtension configuration
isOembooleanEnable the OEM theme; defaults to true
numberKeyBoardbooleanEnable the number keypad; defaults to true
accessMode'mobile' or 'pc'Mobile / PC mode; defaults to pc
sipHeadersstring[]Additional custom SIP communication headers; unset by default
openstringopenapi / normal mode: 0 selects normal and 1 selects open. Legacy docs listed 0; the current manager defaults to 1 and passes it to the remote app through shared configuration.
sgGatewaystringGateway API URL / request prefix: 0 selects domestic production, 1 overseas production; a domain / HTTP(S) URL supplies a custom gateway API. Unset by default. Legacy behavior followed env when omitted; the current implementation uses domestic services when omitted and does not follow env. Overseas integrations must explicitly pass 1 or a custom URL.
sgBasestringBase API URL / request prefix: 0 selects domestic production, 1 overseas production; a domain / HTTP(S) URL supplies a custom base API. Unset by default. Legacy behavior followed env when omitted; the current implementation uses domestic services when omitted and does not follow env. Overseas integrations must explicitly pass 1 or a custom URL.
sgOpenstringOverseas softphone proxy selection: 0 domestic production, 1 overseas production; omission uses domestic production. A domain / HTTP(S) URL supplies a custom hosting proxy. Unset by default.
sgDomainstringSelect the overseas proxy path for domestic or overseas phones: 0 domestic production, 1 overseas production; omission uses domestic production. Unset by default; currently selects openapi / sgopenapi respectively.
countryIdnumber0 indicates domestic operation by default; nonzero values use English hangup audio
getOfflineInfofunctionCustom offline detection. Agent sign-in synchronization may lag by 0–3 seconds; use this to determine precisely whether sign-in completed. Optional callback exposed to the remote app through shared; unset by default.
changeALittleRestfunctionCustom break action. Optional callback exposed to the remote app through shared; unset by default.
quickCallWinfunctionCustom quick-call action. Optional callback exposed to the remote app through shared; unset by default.
autoStartbooleanComponent only; defaults to true, loading the microfrontend on mount. With :auto-start="false", loading starts only after manually calling initSoftphone().
runtimeSoftphoneRuntimeOptional host runtime injection, replacing built-in microfrontend loading and communication; useful for offline demos
elstring or HTMLElementManager only; a valid mount container is required

Tip

origin=ai-softphone && ancestorOrigin=ai-softphone && destinationOrigin=* means that a notification caused by interaction within a phone-bar instance is dispatched for every instance to respond.

origin=ai-softphone && ancestorOrigin=nf-softphone && destinationOrigin=xxx means that a notification resulting from a manually triggered action by the instance identified as nf-softphone is dispatched to the instance identified as xxx.

Events ​

Component eventLibrary callback
softphone-connectsoftphoneConnectCallBack
softphone-call-refreshsoftphoneCallRefreshCallBack
softphone-seats-status-changesoftphoneSeatStatusChangeCallBack
softphone-acceptsoftphoneAcceptCallBack
softphone-ignoresoftphoneIgnoreCallBack
softphone-hangupsoftphoneHangupCallBack
softphone-session-state-changesoftphoneSessionStateChangeCallBack
softphone-incomingsoftphoneIncomingCallBack
softphone-send-dtmfsoftphoneSendDtmfCallBack
softphone-connect-registeredsoftphoneConnectRegisteredCallBack
softphone-auto-ignore-callbacksoftphoneAutoIgnoreCallback
softphone-sign-overduedsoftphoneSignOverduedCallBack
softphone-access-token-overduedsoftphoneAccessTokenOverduedCallBack

Tip

Regular notifications preserve the remote payload reference. data.commonSoftphone exposes the remote instance when provided by the online phone API. softphone-sign-overdued receives a done({ sign, timestamp }) callback; stale callbacks after destruction do not send messages. shared.setUserInfo() and signature renewal synchronize update:sign / update:timestamp, even when the initial sign is empty. The component also emits ready(manager) and error(error); the class exposes the ready Promise / onError for initialization results.

Methods ​

MethodDescription
initSoftphone(options?)The manager returns itself; await ready before actions. The component method returns an initialization Promise
connect() / disconnect()Sign in / sign out
seatsStatusChange(boolean)Switch online / break state
accept() / ignore() / hangup()Preserve existing remote command aliases: dispatch connect / hangup / hangup respectively
sendDtmf(data?)Send transfer / DTMF command data
changeServerToRegister()Switch the registration server
updateOptions(options)Update the manager’s shared configuration
microCommunicat(type, data?, operationType?, ancestorOrigin?, destinationOrigin?)Advanced manager API to dispatch commands to a designated communication namespace
destroy() / destory()Asynchronous resource cleanup; the legacy spelling destory() remains a compatibility alias

Tip

The component ref exposes the manager and common actions. Do not reuse the same active name until destroy() completes. Correct the configuration and retry after initialization failures. The default slot adds content; the error slot receives { error }; use the loading slot for custom loading UI. phone.ready only means the microfrontend mounted; actual rendering detection completes through rendering.ready.

vue
<NfSoftphone v-bind="options">
  <template #loading>Loading phone, please wait...</template>
</NfSoftphone>