Skip to content

呼叫时间组-保存

此接口【v1.2.31版本新增】

接口信息

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

路由参数

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

请求参数

参数类型示例解释必填
namestring周末拨打组时间组名称
contentarray[{"week": 0,"times": [{"begin_time": "09:00","end_time": "13:00"}]}]外呼时间段
is_defaultbooleanFALSE是否为默认时间组
skip_holidaybooleanTRUE是否跳过节假日
sub_user_idstringdc53e7e7-3a68-40ae-adfe-63fc00e401d3子账户 id

请求示例

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 (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    url := "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group"

    payload := map[string]interface{}{
        "name": "周一周三拨打",
        "content": []map[string]interface{}{
            {
                "week": 1,
                "times": []map[string]string{
                    {"begin_time": "08:00", "end_time": "20:00"},
                    {"begin_time": "20:30", "end_time": "22:00"},
                },
            },
            {
                "week": 3,
                "times": []map[string]string{
                    {"begin_time": "08:00", "end_time": "12:00"},
                    {"begin_time": "20:30", "end_time": "22:00"},
                },
            },
        },
        "is_default":   false,
        "skip_holiday": true,
    }

    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, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

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

const 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: false,
    skip_holiday: true
};

axios.post('https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group', data, {
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_TOKEN'
    }
})
.then(response => {
    console.log(response.data);
})
.catch(error => {
    console.error(error);
});
Java
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

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 jsonInputString = "{"
            + "\"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"
            + "}";

        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

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => 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
    ]),
    CURLOPT_HTTPHEADER => [
        "Content-Type: application/json",
        "Authorization: Bearer YOUR_TOKEN"
    ],
]);

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

echo $response;
Python
import requests
import json

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, 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/5832d184-dd53-42a0-8ace-0bf8d660f4cc/dial-time-group";
        std::string jsonPayload = 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
        })";

        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_POSTFIELDS, jsonPayload.c_str());
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

        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
{
    "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 许可发布