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