Appearance
批量添加号码(同步接口)
批量添加号码(兼容2.0任务批量增加号码)
接口信息
- 接口:
/agent-api/user/{user_id}/task/{task_id}/number - 请求方式:
POST
路由参数
| 参数 | 类型 | 示例 | 说明 | 必填 |
|---|---|---|---|---|
| user_id | string | 4d99d91c-f5d9-49da-88da-758977cc58a9 | 用户id | 是 |
| task_id | string | b15b7392-a83f-4e0e-9570-31dd2ec8f85c | 任务id | 是 |
请求说明
- 此接口表示同步接口
- 写入任务的号码会先写入公海中,所以此接口会先导入CRM公海,然后再导入对应任务中
- components中的id为组件的id,value为对应的值,id的值可以去创建公海模板的接口中获取
- 话术常用的变量(联系人、公司)在参数ignore_crm=true的情况下,也支持导入到任务中
- 每次最多导入100条数据
- 默认不可导入重复号码(如果业务场景需要可以看下自动拼接后缀开关请求参数)
请求参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| ignore_crm | bool | TRUE | 号码是否进入客户公海(true代表不进入客户公海,false代表进入客户公海,默认不传则进入客户公海) | 否 |
| skip_error | bool | TRUE | 该值表示是否跳过验证错误 (true表示在验证数据出现错误时跳过错误号码,继续添加,false表示出现错误验证会终止请求,返回错误信息。默认为false) | 否 |
| number_add_suffix | bool | FALSE | 号码自动添加后缀 后缀内容:下划线+随机小写字母和数字 注意:系统数据自带后缀的情况下,不建议开启该自动添加后缀 | 否 |
| encryption | bool | FALSE | 是否加密号码和公司(开启接口加密后有效) | 否 |
| data | array | 参考以下示例 | 数据 | 是 |
| data.*.name | string | 联系人 1 | 联系人名称 | 否 |
| data.*.phone | string | 13012121211 | 号码 可开启加密 | 是 |
| data.*.email | string | 12345@qq.com | 邮箱 | 否 |
| data.*.company | string | xxx 公司 | 公司 可开启加密 | 否 |
| data.*.sex | int | 0 | 姓名 (0:未知,1:男,2:女) | 否 |
| data.*.sort | int | 0 | 排序 | 是 |
| data.*.source_id | int | 0 | 信息来源 ID | 否 |
| data.*.industry_id | int | 0 | 信息行业 ID | 否 |
| data.*.grade_id | int | 0 | 客户等级 ID | 否 |
| data.*.components | array | [] | 组件数据 (使用自定义组件数据前提 ignore_crm=false) | 否 |
| data.*.extra | string | 0c51fc89-f6cf-405b-bb36-2c06900c3b5e | 额外数据,可用于标识第三方数据,可以不携带 (使用该参数需要 ignore_crm=false) | 否 |
| data.*.sub_user_id | string | 91f9254f-ca58-49af-be34-8370d7549d73 | 子账户 id(传递此参数则是对子账户操作) | 否 |
| data.*.control_select_robot | string | 男 | AI对话标识(如果任务配置了按变量值选择话术组,会通过该字段匹配) | 否 |
请求示例
cURL
curl -X POST "https://ai.api.longlonglong.cn/agent-api/user/4d99d91c-f5d9-49da-88da-758977cc58a9/task/b15b7392-a83f-4e0e-9570-31dd2ec8f85c/number" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"ignore_crm": true,
"encryption": false,
"skip_error": true,
"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
}
]
}'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/number"
payload := map[string]interface{}{
"ignore_crm": true,
"encryption": false,
"skip_error": true,
"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,
},
},
}
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/number";
const data = {
ignore_crm: true,
encryption: false,
skip_error: true,
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
}
]
};
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/number";
String jsonInputString = "{\"ignore_crm\":true,\"encryption\":false,\"skip_error\":true,\"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}]}";
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/number";
$data = [
"ignore_crm" => true,
"encryption" => false,
"skip_error" => true,
"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
]
]
];
$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/number"
payload = {
"ignore_crm": True,
"encryption": False,
"skip_error": True,
"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
}
]
}
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/number";
std::string json_data = R"({"ignore_crm":true,"encryption":false,"skip_error":true,"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}]})";
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;
}请求数据案例
1.0话术携带变量传参示例
(除了小模型2.0 使用2.0话术传参格式(custom_vars) 其他的话术都用1.0话术传参(components))
json
{
"ignore_crm": true,
"encryption": false,
"skip_error": true,
"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": "小牛"
}
]
}
]
}2.0话术携带变量传参示例
(除了小模型2.0 使用2.0话术传参格式(custom_vars) 其他的话术都用1.0话术传参(components))
json
{
"skip_error": true,
"ignore_crm": true,
"data": [
{
"name": "cqf",
"phone": "17710726421",
"email": "1320848017@qq.com",
"company": "公司",
"sex": 1,
"sort": 0,
"custom_vars": [
{
"name": "自定义变量1",
"text": "10086"
}
],
"control_select_robot": "男"
}
]
}返回示例
json
{
"code": 200,
"status": "success",
"message": "号码导入任务成功",
"data": {
"taskNumberCount": 1,
"crmCustomerCount": 1,
"fail_datas": [
{
"fail_data": "911***8179",
"fail_cause": "格式不正确。"
}
]
}
}字段说明
| 字段 | 说明 |
|---|---|
| taskNumberCount | 成功写入任务的号码数量 |
| crmCustomerCount | 成功写入CRM公海的号码数量 |
| control_select_robot | AI对话标识(如果任务配置了按变量值选择话术组,会通过该字段匹配) |