在白碼低代碼開(kāi)發(fā)平臺(tái)上對(duì)接七陌外呼接口,實(shí)現(xiàn)選擇客戶(hù)進(jìn)行外呼,并保存通話(huà)記錄的功能。
外呼接口實(shí)現(xiàn)
官方接口文檔:http://developer.7moor.com/v2docs/dialout/
1、對(duì)接數(shù)據(jù)查詢(xún)
向七陌商務(wù)索取到七陌用戶(hù)中心賬號(hào)密碼,在查詢(xún)頁(yè)面查詢(xún)到三個(gè)參數(shù)
let accountId = "T0********";//賬戶(hù)id
let apiSecret = "495b60****************5f0555af";//賬戶(hù)secret
let host = "https://openapis.7moor.com";//請(qǐng)求域名
查詢(xún)頁(yè)面:http://developer.7moor.com/data-query/
2、接口鑒權(quán)信息
時(shí)間戳
//時(shí)間
let date = new Date();
let YY = date.getFullYear();
let MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
let DD = (date.getDate() + 1 <= 10 ? '0' + date.getDate() : date.getDate());
let hh = (date.getHours() + 1 <= 10 ? '0' + date.getHours() : date.getHours());
let mm = date.getMinutes() + 1 <= 10 ? '0' + date.getMinutes() : date.getMinutes();
let ss = date.getSeconds() + 1 <= 10 ? '0' + date.getSeconds() : date.getSeconds();
let time = YY + MM + DD + hh + mm + ss;
包頭驗(yàn)證信息Authorization
//包頭驗(yàn)證信息 Authorization的值為 Base64編碼(賬戶(hù)Id +冒號(hào)+時(shí)間戳)
let buffer = $modules.lib.Buffer.from(accountId + ":" + time);
let authorization = buffer.toString("base64");
請(qǐng)求參數(shù)sig
//sig, 32位大寫(xiě)MD5加密 (帳號(hào)Id + 帳號(hào)APISecret +時(shí)間戳)
const crypto = $modules.crypto;
const hash = crypto.createHash('md5');
let sig = hash.update(accountId + apiSecret + time).digest('hex').toLocaleUpperCase();
3、外呼接口請(qǐng)求地址
//請(qǐng)求地址
let url = host + "/v20180426/call/dialout/" + accountId + "?sig=" + sig;
4、請(qǐng)求頭部
//請(qǐng)求頭部
let headers = {
"Content-Type": "application/json;charset=utf-8",
"Authorization": authorization,
}
5、請(qǐng)求體
相關(guān)參數(shù)參考官方文檔:http://developer.7moor.com/v2docs/dialout/
//請(qǐng)求體
let data = {
"FromExten": $input.FromExten,
"Exten": $input.Exten,
"ExtenType": typeMap[$input.ExtenType],
"ActionID": $input.ActionID,
"DialoutStrVar": $input.DialoutStrVar,
};
為了方便用戶(hù)端理解,extenType參數(shù)輸入增加map
//ExtenType map
let typeMap = {
"手機(jī)": "Local",
"軟電話(huà)": "sip",
"IP話(huà)機(jī)": "gateway",
}
6、發(fā)起外呼請(qǐng)求
//外呼
let call = await $modules.curl(url, {
method: "post",
dataType: "json",
headers,
data,
});
7、輸出請(qǐng)求結(jié)果
//輸出
//$output.sig = sig;
//$output.authorization = authorization;
$output.request = data;
$output.result = call.data;
$output.success = call.data.Succeed.toString();
$output.msg = call.data.Message;
坐席接聽(tīng)方式說(shuō)明:外呼時(shí)強(qiáng)制坐席使用該接聽(tīng)方式進(jìn)行外呼。Local為“手機(jī)”,”sip為“軟電話(huà)”需登錄企話(huà)寶,gateway為“語(yǔ)音網(wǎng)關(guān)”,需注冊(cè)綁定IP話(huà)機(jī)。
標(biāo)簽:唐山
武威
湖州
吉林
酒泉