濮阳杆衣贸易有限公司

主頁 > 呼叫外包 > 行業(yè)新聞 > API對接實戰(zhàn):外呼接口及通話記錄推送

API對接實戰(zhàn):外呼接口及通話記錄推送

POST TIME:2021-09-06 15:49

在白碼低代碼開發(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)簽:唐山 武威 湖州 吉林 酒泉



收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
嘉荫县| 客服| 缙云县| 大悟县| 武隆县| 丘北县| 门头沟区| 民丰县| 平度市| 祁门县| 织金县| 巴林左旗| 图片| 会同县| 五莲县| 涿州市| 宣城市| 苗栗县| 寻乌县| 宣威市| 土默特右旗| 云浮市| 公安县| 望谟县| 水城县| 南木林县| 台北市| 平顺县| 兴安盟| 淮滨县| 嵊州市| 西平县| 奉新县| 广州市| 永宁县| 南投县| 江孜县| 平南县| 平安县| 枣阳市| 洮南市|