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

phone-sdk

v0.2.6

Published

云呼系统sdk

Readme

话务条接入文档

前言

phone-sdk是基于话务条供应商的skd做封装,用于抹平各个供应商sdk之间使用上的差异。 暴露给业务系统统一的调用方式,后续需要接入新的供应商时无需调整系统代码即可完成接入工作。 sdk分为方法和事件两部分,方法提供客户端主动调用服务的能力,事件作为服务端通知客户端的信号,由于底层sdk的限制, 目前sdk的方法暂不提供成功或失败的回调,调用结果服务端会以事件的形式另行通知。同时,由于多个供应商在底层提供的sdk在方法及 事件的细粒度上不一致,phone-sdk会在内部通过代理做一次统一,不过不用担心,对于未代理的api,phone-sdk会原样保留底层sdk的功能,业务系统 可以根据自身需求做对应调整

业务系统可以根据自身需求选择使用sdk(推荐)或者单独使用api

sdk引入

phone-sdk基于vue开发,并通过

{
    "peerDependencies": {
        "vue": "version"
    }
}

申明对vue的依赖,所以业务项目中需要安装vue 1.安装

npm install phone-sdk --save

2.使用

<template>
    <div>
        <phone-bar  :vendor-type="vendorType"
                 :user="user"
                 :password="password"
                 :url="url"
                 @ring = "ring"
                 ></phone-bar>
    </div>
</template>
<script>

</script>

2.使用main.js

<script>
    import phoneBar from 'phone-sdk'
    import 'phone-sdk/lib/phone-sdk.umd.1.js'
    import 'phone-sdk/lib/phone-sdk.umd.4.js'
    import 'phone-sdk/lib/phone-sdk.css'
    // 注册组件库
    Vue.use(phoneBar)
</script>

phone-bar提供的话务条的完整功能,同时也会暴露出必要的方法和事件供开发者处理特殊使用。

api引入

2.使用

import Agent, { VENDOR_TYPE } from './api/src/index'

phoneAgent.connect(userName, password, service)

仅对供应商的api做了一层代理及接口统一,使用这种方法开发,需要开发者自行开发界面及维护功能状态,如在通话中,不能进行置忙,拨打电话等功能


方法

connect:连接服务器

页面初始化时用吃方法与服务器建立联系 参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | userCode | String | 登录账号 | | password | String | 登录密码 | | url | String | 服务器地址 | 通过onConnect事件确认初始化结果

const userCode = 'userCode'
const password = 'password'
const url = 'url'
agent.connect(userCode, password, url)

checkIn:签入

坐席连签入CTI服务器,连接服务器成功后方可使用该方法。(一般让用户手动签入) 参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | groupIds | String | 签入座席组id,多个组用符号 , 分割(三地需要该参数) | 调用

agent.checkIn(groupIds)

checkOut:签出

座席在注册到CTI服务器的状态并处于空闲时才可调用此方法 参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | - | 调用

agent.checkOut()

dialout:拨号

参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | phoneNumber | String | 需要拨打的号码 | 通过phone-agent调用该方法可以拨打电话,但不做任何校验 通过phone-bar调用,方法内部会对状态做校验,如已经在通话过程中,将会调用失败 调用

agent.dialout(phoneNum)

DTMF:拨号

参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | group | String | 需要拨打的DTMF码 | 调用

agent.transGroupDTMF(group)

hangup:挂机

调用挂机成功后,坐席结束当前通话,可在通话,三方通话及监听情况下使用

参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | - |


pause:暂停

将对应座席置忙暂停接听来电,系统将停止分配来电给该座席 参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | agentId | String | 需要暂停服务的坐席工号^agentId,不传表示将自己暂停服务 | 调用

agent.pause(agent)

restore:恢复

参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | agentId | String | 需要恢复服务的坐席工号,不传表示将自己恢复服务,在暂状态下方可使用此方法 |

调用

agent.restore(agentId)

hold:保持通话

在座席通话的过程中,保持当前通话,调用成功后客户将会进入听音乐状态。 参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | - |

调用

agent.hold()

retrieve:取消保持

当座席处于保持通话的情况下想继续通话,则调用此方法。 参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | -| 调用

agent.retrieve()

dialTrans:转接

将通话转接至第三方,当前座席退出通话 参数:

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | | |

listen:监听

班长可以使用该方法来监听坐席和客户之间的通话 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | agentId | String | 需要监听的分机号 | 调用

agent.listen(agentId)

logoutAgent:强制注销

joinTalk:插话

班长可以对正在通话的坐席使用插话功能,插画成功后,客户,坐席以及班长处于三方通话中 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | agentId | String | ... | 调用

agent.joinTalk(agentId)

disconnectCall:拆话

班长可以使用拆话功能,与客户进行通话,被拆话的坐席与客户中断通话 h 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | agentId | String | 被拆话的坐席的工号 |

由于,所以在

事件

onCheckIn: 签入

参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | checkInfo.result | Boolean | 签入是否成功 | | checkInfo.message | String | 签入失败原因 | 监听

agent.on('onCheckIn', checkInfo => {
    
})

onCheckOut: 签出

参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | checkInfo.result | Boolean | 签出是否成功 | | checkInfo.message | String | 签出失败原因 | 监听

agent.on('onCheckOut', checkInfo => {
    
})

onCallInRing: 来电响铃

参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | ringInfo.phoneNumber | String | 来电号码 | | ringInfo.area | String | 来电区号 | | ringInfo.agentId | String | 收到响铃分机号 | 监听

agent.on('onCallInRing', ringInfo => {
    
})

onCallOutRing: 呼出响铃

参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | 监听

agent.on('onCallInRing', res => {
    
})

onThreePartCallInRing: 三方通话响铃

参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | 监听

agent.on('onThreePartCallInRing', () => {
    
})

onThreePartCallOutRing: 三方通话呼出响铃

参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | 监听

agent.on('onThreePartCallOutRing', () => {
    
})

onCallout: 电话拨打成功

参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | 监听

agent.on('onCallout', () => {
    
})

onInCall: 电话接通

参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | 监听

agent.on('onInCall', () => {
    
})

onCallOutRing: 呼出响铃

参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | 监听

agent.on('onCallInRing', res => {
    
})

onCallIn: 来电接通

坐席接通电话之后收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | - | 监听

agent.on('onCallIn', callInfo => {
    
})

onCallOut: 呼出接通

坐席呼出电话之后,客户接通后收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | - | 监听

agent.on('onCallOut', callInfo => {
    
})

onIdle: 挂断电话

中断通话之后收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | - | 监听

agent.on('onIdle', callInfo => {
    
})

onDisconnect: 断开

中断通话之后收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | - | 监听

agent.on('onDisconnect', callInfo => {
    
})

onDialOver: 拨号结束(提示不成功原因)

中断通话之后收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | - | 监听

agent.on('onDialOver', message => {
    
})

onThreePart: 三方通话接通

中断通话之后收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | 无 | - | - | 监听

agent.on('onThreePart', message => {
    
})

onPause: 暂停服务通知

调用pause后会收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | pauseInfo.result | Boolean | 暂停服务结果,true表示已暂停 | | pauseInfo.message | String | 暂停服务结果描述 | 监听

agent.on('onPause', pauseInfo => {
    
})

onRestore: 恢复

调用restore后会收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | restoreInfo.result | Boolean | 恢复服务结果,true表示已恢复服务 | | restoreInfo.message | String | 恢复服务结果描述 | 监听

agent.on('onRestore', restoreInfo => {
    
})

onHold: 保持

调用hold方法后会收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | holdInfo.result | Boolean | 保持通话结果,true表示保持通话成功 | | holdInfo.message | String | 保持通话结果描述 |

监听

agent.on('onHold', holdInfo => {
    
})

onRetrieve: 取消保持

调用hold方法后会收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- |

监听

agent.on('onRetrieve', () => {
    
})

onGetOrgAgtgrps: 获取组(用于转接)

调用hold方法后会收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | groups | Array | 获取组 |

监听

agent.on('onGetOrgAgtgrps', groups => {
            let list = [] //转接组的DTMF。
        this.allTransGroupList = list.concat(groups)
 })

onGetAgtGroups: 获取组(用于签入)

调用hold方法后会收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | groups | Array | 获取组 |

监听

agent.on('onGetAgtGroups',groups => {

 })

onAllAgtInfo: 获取坐席列表

调用hold方法后会收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | groups | Array | 获取组 |

监听

 agent.on('onAllAgtInfo', groups => {
                  
    })

onGetAgentRights: 获取坐席权限

调用hold方法后会收到此事件 参数

| 参数名 | 类型 | 描述 | | :--- | :--- | :--- | | rights | Array | 获取组 |

监听

agent.on('onGetAgentRights', rights => {
    
})