Skip to content

呼叫时间组-保存

此接口【v1.2.31版本新增】 查看变更日志

请求信息

  • 接口: /agent-api/user/{user_id}/dial-time-group
  • 请求方式: POST

路由参数

参数类型示例解释必填
user_idstring5832d184-dd53-42a0-8ace-0bf8d660f4cc用户id

请求参数

参数类型示例解释必填
namestring周一周三拨打时间组名称
contentarray-呼叫时间配置
content[].weekint1星期(0-6, 0为周日)
content[].timesarray-具体时间段
content[].times[].begin_timestring08:00开始时间
content[].times[].end_timestring20:00结束时间
is_defaultboolfalse是否默认分组,一个终端用户只能有一个默认分组,方便任务选择
skip_holidaybooltrue是否跳过节假日

发送内容示例

json
{
    "name": "周一周三拨打",
    "content": [
        {
            "week": 1, //周一
            "times": [
                {
                    "begin_time": "08:00",
                    "end_time": "20:00"
                },
                {
                    "begin_time": "20:30",
                    "end_time": "22:00"
                }
            ]
        },
        {
            "week": 3, //周三
            "times": [
                {
                    "begin_time": "08:00",
                    "end_time": "12:00"
                },
                {
                    "begin_time": "20:30",
                    "end_time": "22:00"
                }
            ]
        }
    ],
    "is_default": false, //默认分组 一个终端用户只能有一个默认分组,方便任务选择
    "skip_holiday": true //跳过节假日
}

请求示例

cURL
curl -X POST "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "name": "周一周三拨打",
    "content": [
        {
            "week": 1, //周一
            "times": [
                { "begin_time": "08:00", "end_time": "20:00" },
                { "begin_time": "20:30", "end_time": "22:00" }
            ]
        },
        {
            "week": 3, //周三
            "times": [
                { "begin_time": "08:00", "end_time": "12:00" },
                { "begin_time": "20:30", "end_time": "22:00" }
            ]
        }
    ],
    "is_default": false, //默认分组 一个终端用户只能有一个默认分组,方便任务选择
    "skip_holiday": true //跳过节假日
}'
Go
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    url := "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group"
    payload := strings.NewReader(`{
        "name": "周一周三拨打",
        "content": [
            {
                "week": 1, //周一
                "times": [
                    { "begin_time": "08:00", "end_time": "20:00" },
                    { "begin_time": "20:30", "end_time": "22:00" }
                ]
            },
            {
                "week": 3, //周三
                "times": [
                    { "begin_time": "08:00", "end_time": "12:00" },
                    { "begin_time": "20:30", "end_time": "22:00" }
                ]
            }
        ],
        "is_default": false, //默认分组 一个终端用户只能有一个默认分组,方便任务选择
        "skip_holiday": true //跳过节假日
    }`)

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

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
JavaScript
const axios = require('axios');

axios.post('https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group', {
    "name": "周一周三拨打",
    "content": [
        {
            "week": 1, //周一
            "times": [
                { "begin_time": "08:00", "end_time": "20:00" },
                { "begin_time": "20:30", "end_time": "22:00" }
            ]
        },
        {
            "week": 3, //周三
            "times": [
                { "begin_time": "08:00", "end_time": "12:00" },
                { "begin_time": "20:30", "end_time": "22:00" }
            ]
        }
    ],
    "is_default": false, //默认分组 一个终端用户只能有一个默认分组,方便任务选择
    "skip_holiday": true //跳过节假日
}, {
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_TOKEN'
    }
})
.then(response => {
    console.log(response.data);
})
.catch(error => {
    console.error('Error:', error);
});
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String url = "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group";
        String payload = """
            {
                "name": "周一周三拨打",
                "content": [
                    {
                        "week": 1, //周一
                        "times": [
                            { "begin_time": "08:00", "end_time": "20:00" },
                            { "begin_time": "20:30", "end_time": "22:00" }
                        ]
                    },
                    {
                        "week": 3, //周三
                        "times": [
                            { "begin_time": "08:00", "end_time": "12:00" },
                            { "begin_time": "20:30", "end_time": "22:00" }
                        ]
                    }
                ],
                "is_default": false, //默认分组 一个终端用户只能有一个默认分组,方便任务选择
                "skip_holiday": true //跳过节假日
            }
            """;

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Content-Type", "application/json")
                .header("Authorization", "Bearer YOUR_TOKEN")
                .POST(HttpRequest.BodyPublishers.ofString(payload))
                .build();

        HttpClient client = HttpClient.newHttpClient();
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

        System.out.println(response.body());
    }
}
PHP
<?php

$url = 'https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group';
$payload = json_encode([
    'name' => '周一周三拨打',
    'content' => [
        [
            'week' => 1, //周一
            'times' => [
                ['begin_time' => '08:00', 'end_time' => '20:00'],
                ['begin_time' => '20:30', 'end_time' => '22:00']
            ]
        ],
        [
            'week' => 3, //周三
            'times' => [
                ['begin_time' => '08:00', 'end_time' => '12:00'],
                ['begin_time' => '20:30', 'end_time' => '22:00']
            ]
        ]
    ],
    'is_default' => false, //默认分组 一个终端用户只能有一个默认分组,方便任务选择
    'skip_holiday' => true //跳过节假日
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
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/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group'
payload = {
    "name": "周一周三拨打",
    "content": [
        {
            "week": 1,  # 周一
            "times": [
                {"begin_time": "08:00", "end_time": "20:00"},
                {"begin_time": "20:30", "end_time": "22:00"}
            ]
        },
        {
            "week": 3,  # 周三
            "times": [
                {"begin_time": "08:00", "end_time": "12:00"},
                {"begin_time": "20:30", "end_time": "22:00"}
            ]
        }
    ],
    "is_default": False,  # 默认分组 一个终端用户只能有一个默认分组,方便任务选择
    "skip_holiday": True  # 跳过节假日
}

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

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

size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl;
    CURLcode res;
    std::string readBuffer;

    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group");
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");

        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_HTTPHEADER, headers);

        std::string payload = R"({
            "name": "周一周三拨打",
            "content": [
                {
                    "week": 1, //周一
                    "times": [
                        { "begin_time": "08:00", "end_time": "20:00" },
                        { "begin_time": "20:30", "end_time": "22:00" }
                    ]
                },
                {
                    "week": 3, //周三
                    "times": [
                        { "begin_time": "08:00", "end_time": "12:00" },
                        { "begin_time": "20:30", "end_time": "22:00" }
                    ]
                }
            ],
            "is_default": false, //默认分组 一个终端用户只能有一个默认分组,方便任务选择
            "skip_holiday": true //跳过节假日
        })";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload.c_str());

        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

        res = curl_easy_perform(curl);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);

        std::cout << readBuffer << std::endl;
    }
    return 0;
}

返回参数

json
{
    "code": 200,
    "status": "success",
    "message": "创建呼叫时间组成功",
    "data": {
        "name": "周一周三拨打",
        "content": [
            {
                "week": 1,
                "times": [
                    {
                        "begin_time": "08:00",
                        "end_time": "20:00"
                    },
                    {
                        "begin_time": "20:30",
                        "end_time": "22:00"
                    }
                ]
            },
            {
                "week": 3,
                "times": [
                    {
                        "begin_time": "08:00",
                        "end_time": "12:00"
                    },
                    {
                        "begin_time": "20:30",
                        "end_time": "22:00"
                    }
                ]
            }
        ],
        "is_default": true,
        "skip_holiday": true,
        "user_id": "4d99d91c-f5d9-49da-88da-758977cc58a9",
        "updated_at": "2022-01-18 14:43:22",
        "created_at": "2022-01-18 14:43:22",
        "id": 1521
    }
}

基于 MIT 许可发布