+7 (499) 271-31-54 обратный звонок
КУПИТЬ

Интеграция CommuniGate Pro Contact Center с Zoho CRM

Модуль CG/PL реализует поиск контактов в базе Zoho по телефонному номеру, а также запись информации о звонке в данные контакта.

// ================================================== //
//   Contact Center integration with Zoho CRM         //
//                   Version 2.0.2d                   //
// ================================================== //

function ccZohoCRM() {
  var qParam = EmailUserPart(SIPURItoEmail(RemoteURI())) || "";
  var authToken = "";
  var module = "Contacts";
  var selectColumns = module + "(First Name,Last Name,Email,Description)";
  var scope = "crmapi";
  var url = "https://crm.zoho.com/crm/private/json/" + module + "/searchRecords";
  var params = NewDictionary();
  params.method = "POST";
  params.timeout = 2;
  params.body = NewDictionary();
  params.body.authtoken = authToken;
  params.body.scope = scope;
  params.body.criteria = "(phone:" + qParam + ")";
  params.body.selectColumns = selectColumns;
  var result = HTTPCall(url,params);
  if(IsDictionary(result) && result.responseCode < 400 && IsData(result.body)) {
  var resultJSON;
  if(IsString(result.charset)) {
    resultJSON = Convert(result.body,result.charset);
  } else {
    resultJSON = result.body;
  }
  var data = JSONToObject(resultJSON);
  if(IsDictionary(data)) {
    if(IsDictionary(data.response)) {
      if(IsDictionary(data.response.result)) {
        if(IsDictionary(data.response.result.(module))) {
          var crm = NewArray();
          if(data.response.result.(module).row) {
            var row = NewArray();
            if(IsDictionary(data.response.result.(module).row)) {
              AddElement(row, data.response.result.(module).row);
            } elif(IsArray(data.response.result.(module).row)) {
              row = data.response.result.(module).row;
            }
            for(var i = 0; i < Length(row); i += 1) {
              if(IsArray(row[i].FL)) {
                var obj = NewDictionary();
                var fN;
                var lN;
                for(var j = 0; j < Length(row[i].FL); j += 1) {
                  if(IsDictionary(row[i].FL[j])) {
                    if(row[i].FL[j].val == "CONTACTID") {
                      obj.id = row[i].FL[j].content;
                      obj.url = "https://crm.zoho.com/crm/EntityInfo.do?module=" + module +
                        "&id=" + obj.id;
                      } elif(row[i].FL[j].val == "Email") {
                        obj.email = row[i].FL[j].content;
                      } elif(row[i].FL[j].val == "Description") {
                        obj.desc = row[i].FL[j].content;
                      } elif(row[i].FL[j].val == "First Name") {
                        fN = row[i].FL[j].content;
                      } elif(row[i].FL[j].val == "Last Name") {
                        lN = row[i].FL[j].content;
                      }
                    }
                  }
                  obj.name = "";
                  if(fN) {
                    obj.name += fN;
                  }
                  if(lN) {
                    if(obj.name != "") {
                      obj.name += " " + lN;
                    } else {
                      obj.name = lN;
                    }
                  }
                  AddElement(crm,obj);
                }
              }
              return crm;
            }
          }
        }
      }
    }
  }
  return null;
}

procedure updateContact(id, params) {
  var authToken = "";
  var module = "Contacts";
  var url = "https://crm.zoho.com/crm/private/xml/" + module + "/updateRecords";
  var scope = "crmapi";
  var p = NewDictionary();
  p.method = "POST";
  p.timeout = 2;
  p.body = NewDictionary();
  p.body.authtoken = authToken;
  p.body.scope = scope;
  p.body.id = id;
  p.body.xmlData = "<" + module + "><row no=\"1\"><FL val=\"Description\">" + ObjectToJSON(params) + "</FL></row></" + module + ">";
  var result = HTTPCall(url,p);
}

Для получения более подробной информации пишите на support@communigate.com





Яндекс.Метрика
Заказ звонка
Ваш телефон: +7