最近開發一個 呼叫中心中間件,也可以讓用戶不懂呼叫系統完成復雜的呼叫業務。
模塊里面我集成了 WebSocket RESTFul API 服務器端
ws://192.168.0.250:8092/appid=xxxx&appkey=xxxxx×tamp=時間戳&sign=xxxxxxxxxx
簽名規則 sign=md5(appid+appkey+timestamp+"callback") 不含"+"
心跳規則:
客戶端發送 {"Request": {type":"HEART_BEAT", "timestamp": "時間戳" } }
服務器返回 {"Response": {type":"HEART_BEAT","timestamp": "時間戳" } }
回撥呼叫
dispcaller 呼叫主叫顯示的號碼
dispcallee 呼叫被叫顯示的號碼
caller 主叫號碼
callee 被叫號碼
callid 呼叫ID 必須唯一 32位或64位
record 是否錄音 true|false
timelong 通話時長
userdata 自定義數據
{ "Request": { "dial": {"dispcaller":"9001","dispcallee":"9000", "caller": "9000", "callee": "9001", "callid": "12345657586960", "record": "true", "timelong":"1000" ,"userdata":"test"} } }
#話單返回
callid 呼叫提交的ID
caller_id_number 主叫
dispcaller 呼叫主叫顯示的號碼
dispcallee 呼叫被叫顯示的號碼
destination_number 被叫號碼
start_stamp 呼叫開始
answer_stamp 呼叫應答
end_stamp 呼叫結束
recordfile 錄音文件路徑
duration 通話時長
billsec 計費時長
hangup_cause 掛機原因
完整返回:
{"Response": {"appid": "111111","cdr": { "context":"callbak", "caller_id_number":"9001","dispcaller":"9001",,"dispcallee":"9000","destination_number":"9000","start_stamp":"2019-06-11 17:52:07", "answer_stamp":"2019-06-11 17:52:10","end_stamp":"2019-06-11 17:52:19","channel_name":"sofia/internal/9000@192.168.0.137:5060","bridge_channel":"sofia/internal/9001@192.168.0.137:5060","duration":"12","billsec":"9","hangup_cause":"NORMAL_CLEARING","callid":"12345657586960","recordfile":"","userdata":"test"}}}
#呼叫狀態異步返回
{"Response": {"appid": "12345678","callstate": {"callbacka_active":"主叫是否接通",state":"EARLY|DIALING|RING_WAIT|ACTIVE","callid": "呼叫ID","timestamp":"時間戳","uuid" : "服務端通話ID" }}}
{"Response": {"appid": "111111","callstate": {"callbacka_active":"false","state":"RINGING","callid": "12345657586960","timestamp":"1560246727","uuid":"1defac04-8727-49b2-b19d-86b60fca7e0d" }}}
{"Response": {"appid": "111111","callstate": {"callbacka_active":"false","state":"ACTIVE","callid": "12345657586960","timestamp":"1560246730","uuid":"1defac04-8727-49b2-b19d-86b60fca7e0d" }}}
{"Response": {"appid": "111111","callstate": {"callbacka_active":"true","state":"RING_WAIT","callid": "12345657586960","timestamp":"1560246730","uuid":"1defac04-8727-49b2-b19d-86b60fca7e0d" }}}
{"Response": {"appid": "111111","callstate": {"callbacka_active":"true","state":"ACTIVE","callid": "12345657586960","timestamp":"1560246732","uuid":"1defac04-8727-49b2-b19d-86b60fca7e0d" }}}
#呼叫控制
uuid cti呼叫狀態返回主叫的 通話UUID
1、掛斷當前通話
{ "Request": { "hangup": { "uuid": "cc70b4b6-b041-49bf-adc5-ffd51e0ef780"} } }
2、監聽某個通話
{ "Request": { "monitor": { "uuid": "ad6ac4ea-0f33-4108-85e2-1586a71a939d","caller":"顯示的主叫號碼","callee":"監聽者的號碼"} } }
3、通話轉接
{ "Request": { "transfer": { "uuid": "903aee0b-1bc1-45a3-92b0-2c615c21aaa9","caller":"顯示的主叫號碼","callee":"要轉移號碼"} } }
4、被叫通話保持
state true 開啟 false 關閉
{ "Request": { "hold": { "uuid": "55e27e6d-88ab-4b3e-93f7-d049dd6eba21","state":"true"} } }
http api 中繼管理
提交方式:POST
提交數據 Body raw 類型字段
簽名規則 sign=md5(appid+appkey+timestamp+"api") 不含"+"
RESTFul API
ip:8092/api/v1/gatewayAdd 增加中繼
appid
appkey
timestamp
sign
name 中繼名稱必須唯一
enable 是否啟用
ip 對方IP 地址
port 對方端口
bypass_media 媒體繞過服務器 默認false 否則不能錄音
register IP對接:false SIP注冊:true goip注冊:in 呼叫本地SIP:local
username SIP注冊用戶名
auth-username IMS認證用戶名
userpwd SIP注冊用戶密碼
prefix 撥號前綴
prefix_replace 撥號替換規則
limit_caller 強制主叫號碼
from-domain IMS 對接域地址
limit_count 並發限制
ip:8092/api/v1/gatewayDel 刪除中繼
appid
appkey
timestamp
sign
name 中繼名稱必須唯一
ip:8092/api/v1/gatewayGet 獲取中繼
appid
appkey
timestamp
sign
limit 返回的行數
offset 開始的行數
http api SIP用戶管理
提交方式:POST
提交數據 Body raw 類型字段
http://192.168.0.250:8092/api/v1/sipuserAdd 增加SIP用戶
appid
appkey
timestamp
sign
accountcode SIP賬號
secret SIP密碼
calltyp 呼叫類別 in:呼入 out:呼出 all:呼入呼出
record 是否錄音
http://192.168.0.250:8092/api/v1/sipuserDel 刪除SIP用戶
appid
appkey
timestamp
sign
accountcode SIP賬號
http://192.168.0.250:8092/api/v1/sipuserGet 獲取SIP用戶
appid
appkey
timestamp
sign
limit 返回的行數
offset 開始的行數