Skip to content

批量添加号码(异步接口)

批量添加号码(兼容2.0任务批量增加号码)

接口信息

  • 接口: /agent-api/user/{user_id}/task/{task_id}/async_number
  • 请求方式: POST

路由参数

参数说明
user_idstring
task_idstring

请求说明

  • 此接口表示异步接口
  • 写入任务的号码会先写入公海中,所以此接口会先导入CRM公海,然后再导入对应任务中
  • components中的id为组件的id,value为对应的值,id的值可以去创建公海模板的接口中获取
  • 话术常用的变量(联系人、公司)在参数ignore_crm=true的情况下,也支持导入到任务中
  • 每次最多导入200条数据
  • 不可导入重复号码

请求参数

参数类型示例解释必填
namestring联系人 1联系人名称
phonestring13012121211号码 可开启加密
emailstring12345@qq.com邮箱
companystringxxx 公司公司 可开启加密
sexint0姓名 (0:未知,1:男,2:女)
sortint0排序
source_idint0信息来源 ID
industry_idint0信息行业 ID
grade_idint0客户等级 ID
ignore_crmboolTRUE号码是否进入客户公海(true 代表不进入客户公海,false 代表进入客户公海,默认不传则进入客户公海)
number_add_suffixboolFALSE号码自动添加后缀 注意:系统数据自带后缀的情况下,不建议开启该自动添加
dataarray参考以下示例数据
data.*.componentsarray[]组件数据 (使用自定义组件数据前提 ignore_crm=false)
data.*.extrastring0c51fc89-f6cf-405b-bb36-2c06900c3b5e额外数据,可用于标识第三方数据,可以不携带
data.*.sub_user_idstring91f9254f-ca58-49af-be34-8370d7549d73子账户 id(传递此参数则是对子账户操作)
data.*.encryptionboolFALSE是否加密号码和公司(开启接口加密后有效)
data.*.control_select_robotstringAI 对话标识(如果任务配置了按变量值选择话术组,会通过该字段匹配)

请求示例

cURL
curl -X POST "https://ai.api.longlonglong.cn/agent-api/user/4d99d91c-f5d9-49da-88da-758977cc58a9/task/b15b7392-a83f-4e0e-9570-31dd2ec8f85c/async_number" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "ignore_crm": true,
    "encryption": false,
    "number_add_suffix": false,
    "data": [
      {
        "name": "联系人1",
        "phone": "13012121211",
        "email": "12345@qq.com",
        "company": "xxx公司",
        "sex": 0,
        "sort": 0,
        "source_id": 1,
        "industry_id": 2,
        "grade_id": 1,
        "extra": "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
        "components": [
          {
            "id": "2a87347c-6dd5-4e22-97fe-9b8001dbcd17",
            "value": "小牛"
          }
        ],
        "control_select_robot": "男"
      }
    ]
  }'
Go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    url := "https://ai.api.longlonglong.cn/agent-api/user/4d99d91c-f5d9-49da-88da-758977cc58a9/task/b15b7392-a83f-4e0e-9570-31dd2ec8f85c/async_number"

    payload := map[string]interface{}{
        "ignore_crm":        true,
        "encryption":        false,
        "number_add_suffix": false,
        "data": []map[string]interface{}{
            {
                "name":      "联系人1",
                "phone":     "13012121211",
                "email":     "12345@qq.com",
                "company":   "xxx公司",
                "sex":       0,
                "sort":      0,
                "source_id":  1,
                "industry_id": 2,
                "grade_id":   1,
                "extra":      "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
                "components": []map[string]string{
                    {
                        "id":    "2a87347c-6dd5-4e22-97fe-9b8001dbcd17",
                        "value": "小牛",
                    },
                },
                "control_select_robot": "男",
            },
        },
    }

    jsonData, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer YOUR_TOKEN")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
JavaScript
const url = "https://ai.api.longlonglong.cn/agent-api/user/4d99d91c-f5d9-49da-88da-758977cc58a9/task/b15b7392-a83f-4e0e-9570-31dd2ec8f85c/async_number";

const data = {
  ignore_crm: true,
  encryption: false,
  number_add_suffix: false,
  data: [
    {
      name: "联系人1",
      phone: "13012121211",
      email: "12345@qq.com",
      company: "xxx公司",
      sex: 0,
      sort: 0,
      source_id: 1,
      industry_id: 2,
      grade_id: 1,
      extra: "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
      components: [
        {
          id: "2a87347c-6dd5-4e22-97fe-9b8001dbcd17",
          value: "小牛"
        }
      ],
      control_select_robot: "男"
    }
  ]
};

fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
  },
  body: JSON.stringify(data)
})
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.error("Error:", error));
Java
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.io.OutputStream;

public class Main {
    public static void main(String[] args) throws Exception {
        String url = "https://ai.api.longlonglong.cn/agent-api/user/4d99d91c-f5d9-49da-88da-758977cc58a9/task/b15b7392-a83f-4e0e-9570-31dd2ec8f85c/async_number";
        String jsonInputString = "{\"ignore_crm\":true,\"encryption\":false,\"number_add_suffix\":false,\"data\":[{\"name\":\"联系人1\",\"phone\":\"13012121211\",\"email\":\"12345@qq.com\",\"company\":\"xxx公司\",\"sex\":0,\"sort\":0,\"source_id\":1,\"industry_id\":2,\"grade_id\":1,\"extra\":\"0c51fc89-f6cf-405b-bb36-2c06900c3b5e\",\"components\":[{\"id\":\"2a87347c-6dd5-4e22-97fe-9b8001dbcd17\",\"value\":\"小牛\"}],\"control_select_robot\":\"\"}]}";

        URL obj = new URL(url);
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/json");
        con.setRequestProperty("Authorization", "Bearer YOUR_TOKEN");
        con.setDoOutput(true);

        try (OutputStream os = con.getOutputStream()) {
            byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
            os.write(input, 0, input.length);
        }

        System.out.println("Response Code: " + con.getResponseCode());
    }
}
PHP
<?php

$url = "https://ai.api.longlonglong.cn/agent-api/user/4d99d91c-f5d9-49da-88da-758977cc58a9/task/b15b7392-a83f-4e0e-9570-31dd2ec8f85c/async_number";

$data = [
    "ignore_crm" => true,
    "encryption" => false,
    "number_add_suffix" => false,
    "data" => [
        [
            "name" => "联系人1",
            "phone" => "13012121211",
            "email" => "12345@qq.com",
            "company" => "xxx公司",
            "sex" => 0,
            "sort" => 0,
            "source_id" => 1,
            "industry_id" => 2,
            "grade_id" => 1,
            "extra" => "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
            "components" => [
                [
                    "id" => "2a87347c-6dd5-4e22-97fe-9b8001dbcd17",
                    "value" => "小牛"
                ]
            ],
            "control_select_robot" => "男"
        ]
    ]
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_TOKEN"
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
Python
import requests

url = "https://ai.api.longlonglong.cn/agent-api/user/4d99d91c-f5d9-49da-88da-758977cc58a9/task/b15b7392-a83f-4e0e-9570-31dd2ec8f85c/async_number"

payload = {
    "ignore_crm": True,
    "encryption": False,
    "number_add_suffix": False,
    "data": [
        {
            "name": "联系人1",
            "phone": "13012121211",
            "email": "12345@qq.com",
            "company": "xxx公司",
            "sex": 0,
            "sort": 0,
            "source_id": 1,
            "industry_id": 2,
            "grade_id": 1,
            "extra": "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
            "components": [
                {
                    "id": "2a87347c-6dd5-4e22-97fe-9b8001dbcd17",
                    "value": "小牛"
                }
            ],
            "control_select_robot": "男"
        }
    ]
}

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
C++
#include <iostream>
#include <string>
#include <curl/curl.h>

int main() {
    CURL* curl;
    CURLcode res;

    curl = curl_easy_init();
    if (curl) {
        std::string url = "https://ai.api.longlonglong.cn/agent-api/user/4d99d91c-f5d9-49da-88da-758977cc58a9/task/b15b7392-a83f-4e0e-9570-31dd2ec8f85c/async_number";
        std::string json_data = R"({"ignore_crm":true,"encryption":false,"number_add_suffix":false,"data":[{"name":"联系人1","phone":"13012121211","email":"12345@qq.com","company":"xxx公司","sex":0,"sort":0,"source_id":1,"industry_id":2,"grade_id":1,"extra":"0c51fc89-f6cf-405b-bb36-2c06900c3b5e","components":[{"id":"2a87347c-6dd5-4e22-97fe-9b8001dbcd17","value":"小牛"}],"control_select_robot":"男"}]})";

        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/json");
        headers = curl_slist_append(headers, "Authorization: Bearer YOUR_TOKEN");

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_POST, 1L);
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data.c_str());

        res = curl_easy_perform(curl);

        if (res != CURLE_OK) {
            std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
        }

        curl_easy_cleanup(curl);
    }

    return 0;
}

请求数据案例

json
{
    "ignore_crm": true,
    "encryption": false,
    "sub_user_id": "91f9254f-ca58-49af-be34-8370d7549d73",
    "number_add_suffix": false,
    "data": [
        {
            "name": "联系人1",
            "phone": "13012121211",
            "email": "12345@qq.com",
            "company": "xxx公司",
            "sex": 0,
            "sort": 0,
            "source_id": 1,
            "industry_id": 2,
            "grade_id": 1,
            "extra": "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
            "components": [
                {
                    "id": "2a87347c-6dd5-4e22-97fe-9b8001dbcd17",
                    "value": "小牛"
                }
            ],
            "control_select_robot": "男"
        }
    ]
}

返回结果

json
{
    "code": 200,
    "status": "success",
    "message": "号码导入任务信息请在回调中查收",
    "data": {
        "unique_id": "f2c7aa27-55be-4b96-835b-18cf38edd29e"
    }
}

字段说明

字段说明
unique_id本次回调的批次号,可使用查看回调数据去查询
control_select_robotAI对话标识(如果任务配置了按变量值选择话术组,会通过该字段匹配)

基于 MIT 许可发布