npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wizai/agent-sip-sdk

v0.2.0

Published

Manages SIP clients and agent status, simplifying calls and events.

Readme

AgentSipSDK

AgentSipSDK 是一个用于管理 SIP 客户端和坐席状态的 JavaScript 类。它封装了 SIP 和 API 调用,以便更轻松地处理坐席状态、来电、外呼和事件监听等功能。

安装

通过 NPM/YARN/PNPM 安装

npm install @wizai/agent-sip-sdk
yarn add @wizai/agent-sip-sdk
pnpm add @wizai/agent-sip-sdk

通过 <script> 标签引入

你可以从 CDN 引入 AgentSipSDK,例如:

<script src="https://cdn.example.com/agent-sip-sdk/latest/umd.js"></script>

使用方法

初始化

通过 NPM/YARN/PNPM 安装的方式

import AgentSipSDK from '@wizai/agent-sip-sdk';

const options = {
  id: '123',
  getSystemToken: () => Promise.resolve('xxx'),
  baseUrl: '', // 可选,默认是空,接口基础地址
  retryCount: 0  // 可选,默认是0
}
const ASK = new AgentSipSDK(options);

通过 <script> 标签引入的方式

<script>
const options = {
  id: '123',
  getSystemToken: () => Promise.resolve('xxx'),
  baseUrl: '', // 可选,默认是空,接口基础地址
  retryCount: 0  // 可选,默认是0
}
const ASK = new AgentSipSDK(options);
</script>

获取坐席状态列表

ASK.getAgentStatusList().then(({code, data}) => {
    console.log(code);
}).catch(() => {
    console.log('失败');
})

获取坐席状态

ASK.getAgentStatus().then(({code, data}) => {
    console.log(code);
}).catch(() => {
    console.log('失败');
})

切换坐席状态 (上/下线)

ASK.switchAgentStatus({
  status: 1, // 1: 上线,0: 下线
  subStatus: 'Online', // 子状态 Online | Offline | 自定义
}).then(({code}) => {
    console.log(code);
}).catch(err => {
    console.log('坐席上/下线失败', err);
});

外呼

/**
 *
 * @param {string} phoneNumber
 * @memberof AgentSipSDK
 */
ASK.outboundCall('123456789').then(({code}) => {
    console.log(code);
}).catch(err => {
    console.log('外呼失败', err)
})

话后处理(ACW)

ASK.finshACW().then(({code}) => {
    console.log(code);
}).catch(err => {
    console.log('外呼失败', err)
})

其他功能

  • 挂断: agentSipClient.hangup()
  • 接听: agentSipClient.answer()
  • 忽略: agentSipClient.ignore()
  • 静音: agentSipClient.mute()
  • 取消静音: agentSipClient.unmute()

事件监听

初始化事件

const fn = ({code}) => {
    console.log(code);
}

// 初始化结果事件监听
ASK.attachInitEvent('failed', fn);

// 移除事件监听
ASK.removeInitEvent('failed', fn);

坐席事件

const fn = ({code}) => {
    console.log(code);
}

// 坐席事件监听
ASK.attachAgentEvent('online', fn);

// 移除事件监听
ASK.removeAgentEvent('online', fn);

来电事件

const fn = ({code, data}) => {
    // data 通话详情信息
    console.log('来电啦');
}
// 来电呼入事件监听
ASK.attachAnswerEvent(fn);

// 移除事件监听
ASK.removeAnswerEvent(fn);

新消息事件

const fn = ({code, data}) => {
    // data 详情信息
    console.log('来电啦');
}
// 新消息事件监听
ASK.attachNewMessageEvent(fn);

// 移除事件监听
ASK.removeNewMessageEvent(fn);

会话事件

  • success: 通话接听成功
  • failed: 通话接听失败/拒接
  • ended:通话结束
const fn = () => {
    
}

// 通话事件监听
ASK.attchSessionEvent('success', fn);

// 移除事件监听
ASK.removeSessionEvent('success', fn);

自动接听事件

const fn = ({code, data}) => {
    // data 通话详情信息
    console.log('自动接听啦');
}
// 自动接听事件监听
ASK.attachAutoAnswerEvent(fn);

// 移除事件监听
ASK.removeAutoAnswerEvent(fn);

API 参考

方法

  • getAgentStatusList(): 获取坐席状态列表。
  • getAgentStatus(): 获取当前坐席状态。
  • switchAgentStatus(data): 切换坐席状态。
  • outboundCall(phoneNumber): 发起外呼。
  • hangup(): 挂断。
  • answer(): 接听。
  • ignore(): 拒接。
  • mute(): 静音。
  • unmute(): 取消静音。
  • processAfterCall(data): ACW。
  • attachInitEvent(type, listener): 添加初始化事件监听器。
  • removeInitEvent(type, listener): 移除初始化事件监听器。
  • attachAgentEvent(type, listener): 添加坐席事件监听器。
  • removeAgentEvent(type, listener): 移除坐席事件监听器。
  • attachAnswerEvent(listener): 添加来电事件监听器。
  • removeAnswerEvent(listener): 移除来电事件监听器。
  • attachNewMessageEvent(listener): 添加新消息事件监听器。
  • removeNewMessageEvent(listener): 移除新消息事件监听器。
  • attchSessionEvent(type, listener): 添加会话事件监听器。
  • removeSessionEvent(type, listener): 移除会话事件监听器。
  • attachAutoAnswerEvent(listener): 添加自动接听事件监听器。
  • removeAutoAnswerEvent(listener): 移除自动接听事件监听器。

注意事项

  • 确保所有 API 调用成功返回,否则可能会导致坐席状态不一致。

贡献

欢迎提出问题和提交 PR,以帮助改进此类。

许可证

MIT


感谢使用 AgentSipSDK!希望它能对你的项目有所帮助。