vue 项目接入智齿外呼系统

1,215 阅读1分钟

智齿在线调试页面

www.sobot.com/paas/callCe…

sdk接入及智齿基础服务:智齿呼叫中心第三方对接插件

在index.html接入sdk

<script src="https://www.sobot.com/paas/callCenterClient/plugin/jquery.min.js"></script>
<script src="https://www.sobot.com/paas/callCenterClient/plugin/jquery.json-2.4.min.js"></script>
<script src="https://www.sobot.com/paas/callCenterClient/plugin/verto-min.js"></script>
<script src="https://www.sobot.com/paas/callCenterClient/plugin/callCenter.js"></script>

外呼函数封装

/*
 * @Description: 智齿外呼系统封装
 */

export default class CallService {
  constructor (params) {
    this.config = {
      client_id: '3a1f02866f3*****3',
      client_secret: '227ee***5174',
      companyId: 'c69b**255',
      appId: '3a1f02866f**c3',
      callWay: '2',
      agentId: null,
      groupId: null,
      voipAccount: null,
      displayNumber: null
      // agentId: 'e60a64fb16**7223',
      // groupId: 'c69b7d53**0fd710db6255_4',
      // voipAccount: '137530001'
    }
    this.config = Object.assign(this.config, params)
  }
  // 智齿-初始化参数
  ininServ (cb) {
    const params = this.config
    window.zcVertoServ.ininServ(params, cb || null)
  }

  // 智齿-获取token
  getToken (cb) {
    window.zcVertoServ.getToken(cb)
  }

  // 智齿-客服登录
  agentLogin (cb) {
    const params = {
      displayNumber: '17188****623',
      isRecordStereo: false,
      // agentState:坐席上班后的状态,0-上班后置于忙碌;如不传递则默认为上班后置于空闲;
      agentState: 0
    }
    window.zcVertoServ.agentLogin(params, cb || null)
  }

  // 客服退出
  agentLoginout () {
    window.zcVertoServ.agentLoginout((res) => {
      console.log(res)
    })
  }

  // 智齿-客服外呼
  agentCallOut (destinationNumber) {
    const params = {
      displayNumber: this.displayNumber || '17188339623',
      destinationNumber: destinationNumber
    }
    window.zcVertoServ.agentCallOut(params, res => {
      console.log(res)
    })
  }

  // 智齿系统初始化
  initialization () {
    this.ininServ((res) => {
      // console.log('ininServ', res)
    })
    setTimeout(() => {
      this.getToken((res) => {
        // console.log('getToken', res)
      })
    }, 2000)
    // this.agentLoginout()
    setTimeout(() => {
      this.agentLoginout()
    }, 3000)
    setTimeout(() => {
      this.agentLogin((res) => {
        console.log('agentLogin', res)
      })
    }, 6000)
  }
}

业务逻辑调用

// 生成智齿服务实例
const callService = new CallService()
// 智齿服务初始化
this.$eventBus.$on('call-init', event => {
// event.data
callService.initialization()
})
// 智齿服务-拨号
this.$eventBus.$on('call-dial', event => {
callService.agentCallOut()
})
// 智齿服务-退出登录
this.$eventBus.$on('call-logout', event => {
callService.agentCallOut()
})

跨域转发comm

webpack devserver配置

proxyTable: {
      '/comm': {
        target: 'https://www.sobot.com/',  //目标接口域名
        changeOrigin: true,  //是否跨域
        pathRewrite: {
          '^/comm': '/comm'  //重写接口
        },
        ws: true    
      }
    }

智齿nginx comm转发配置

location /comm/ {
        proxy_pass http://www.sobot.com;
        proxy_set_header Host 'www.sobot.com';
}