Skip to content

对话接口

注意

需要先开通

请求域名

域名与其他有区别,是对应的客户端域名 ai.call.longlonglong.cn

接口信息

  • 接口: /saas/api/customer_service/tenant/{tenant_id}
  • 请求方式: POST

请求头

  • Content-Type: application/json
  • X-Requested-With: XMLHttpRequest
  • Authorization: Bearer {token}(需要在每次调用时在 Headers 里带上生成的 Token)

获取 Token 查看 AI 客户联络->开发指引->查看认证 token

代码块:

Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...

格式:Bearer + 空格 + Token

请求参数

字段名类型示例解释必填
talk_idstringbCdeffd6-C84D-dB14-11De-3afA7f738159对话 id(随机生成保证同一个对话不变即可)
user_idstringbCdeffd6-C84D-dB14-11De-3afA7f738159用户 id
messagestring测试内容
notifystringenter类型 enter 开始 message 中间阶段 leave 结束
group_idinteger1话术 id
directivestring""invalid 杂音 no_answer 无回应填写时 message 为""即可

请求示例

cURL
curl -X POST "https://ai.call.longlonglong.cn/saas/api/customer_service/tenant/5433b412-07d5-44e6-9fa4-deb65e43bc93" \
  -H "Content-Type: application/json" \
  -H "X-Requested-With: XMLHttpRequest" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "talk_id": "bCdeffd6-C84D-dB14-11De-3afA7f738159",
    "user_id": "bCdeffd6-C84D-dB14-11De-3afA7f738159",
    "message": "测试",
    "notify": "enter",
    "directive": "",
    "group_id": 1
}'
Go
package main

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

func main() {
    url := "https://ai.call.longlonglong.cn/saas/api/customer_service/tenant/5433b412-07d5-44e6-9fa4-deb65e43bc93"

    payload := map[string]interface{}{
        "talk_id":   "bCdeffd6-C84D-dB14-11De-3afA7f738159",
        "user_id":   "bCdeffd6-C84D-dB14-11De-3afA7f738159",
        "message":   "测试",
        "notify":    "enter",
        "directive": "",
        "group_id":  1,
    }

    jsonData, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("X-Requested-With", "XMLHttpRequest")
    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 tenantId = "5433b412-07d5-44e6-9fa4-deb65e43bc93";
const url = `https://ai.call.longlonglong.cn/saas/api/customer_service/tenant/${tenantId}`;

const data = {
    talk_id: "bCdeffd6-C84D-dB14-11De-3afA7f738159",
    user_id: "bCdeffd6-C84D-dB14-11De-3afA7f738159",
    message: "测试",
    notify: "enter",
    directive: "",
    group_id: 1
};

fetch(url, {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "X-Requested-With": "XMLHttpRequest",
        "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.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.call.longlonglong.cn/saas/api/customer_service/tenant/5433b412-07d5-44e6-9fa4-deb65e43bc93";
        String json = """
            {
                "talk_id": "bCdeffd6-C84D-dB14-11De-3afA7f738159",
                "user_id": "bCdeffd6-C84D-dB14-11De-3afA7f738159",
                "message": "测试",
                "notify": "enter",
                "directive": "",
                "group_id": 1
            }
            """;

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

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

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

$tenantId = "5433b412-07d5-44e6-9fa4-deb65e43bc93";
$url = "https://ai.call.longlonglong.cn/saas/api/customer_service/tenant/{$tenantId}";

$data = [
    'talk_id' => 'bCdeffd6-C84D-dB14-11De-3afA7f738159',
    'user_id' => 'bCdeffd6-C84D-dB14-11De-3afA7f738159',
    'message' => '测试',
    'notify' => 'enter',
    'directive' => '',
    'group_id' => 1
];

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

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

echo $response;
Python
import requests

tenant_id = "5433b412-07d5-44e6-9fa4-deb65e43bc93"
url = f"https://ai.call.longlonglong.cn/saas/api/customer_service/tenant/{tenant_id}"

data = {
    "talk_id": "bCdeffd6-C84D-dB14-11De-3afA7f738159",
    "user_id": "bCdeffd6-C84D-dB14-11De-3afA7f738159",
    "message": "测试",
    "notify": "enter",
    "directive": "",
    "group_id": 1
}

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

response = requests.post(url, json=data, headers=headers)
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) {
        std::string json_data = R"({
            "talk_id": "bCdeffd6-C84D-dB14-11De-3afA7f738159",
            "user_id": "bCdeffd6-C84D-dB14-11De-3afA7f738159",
            "message": "测试",
            "notify": "enter",
            "directive": "",
            "group_id": 1
        })";

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

        curl_easy_setopt(curl, CURLOPT_URL, "https://ai.call.longlonglong.cn/saas/api/customer_service/tenant/5433b412-07d5-44e6-9fa4-deb65e43bc93");
        curl_easy_setopt(curl, CURLOPT_POST, 1L);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data.c_str());
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        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);

        if(res != CURLE_OK)
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        else
            std::cout << readBuffer << std::endl;
    }
    return 0;
}

返回示例

json
{
    "code": 200,
    "status": "success",
    "message": "成功",
    "data": {
        "label_id": "93d91274-2e3d-45ba-bf71-d7c20944dfe7",
        "label_name": "测试",
        "group_id": 9322,
        "wait": 5000,
        "score": 5,
        "after_action": {
            "outbound_label_id": "93d91274-2e3d-45ba-bf71-d7c20944dfe7",
            "block": 1,
            "action": 1,
            "value": null,
            "created_at": "2023-02-06 14:58:43",
            "updated_at": "2023-08-24 17:58:07"
        },
        "after_action_str": "播放后等待应答",
        "group": {
            "wait_broadcast": 1
        },
        "contents": [
            {
                "translate_text": "测试测试测试测试测试测试测试测试测试测试"
            },
            {
                "translate_text": "33",
                "digital_human_contents": [
                    {
                        "file_url": "https://telrobot.obs.cn-southwest-2.myhuaweicloud.com:443/customer-service/label/92b1517d-a00d-456a-9ba4-bbd674391a2a/2308/%E6%96%B9%E5%A4%A7%E5%90%8C-%E5%90%AC%28%E6%A0%87%E6%B8%85%29Part001~1.mp4?AWSAccessKeyId=EWFUEKMADNJGBAOPAO1N&Expires=1692871702&Signature=PuDnlsY9xGni7%2BQP%2Bz71vnZdSp8%3D",
                        "file_type": 1
                    },
                    {
                        "file_url": "https://telrobot.obs.cn-southwest-2.myhuaweicloud.com:443/customer-service/label/92b1517d-a00d-456a-9ba4-bbd674391a2a/2308/%E6%96%B9%E5%A4%A7%E5%90%8C-%E5%90%AC%28%E6%A0%87%E6%B8%85%29Part016.mp4?AWSAccessKeyId=EWFUEKMADNJGBAOPAO1N&Expires=1692871702&Signature=qcFb/8fyoLWd3lV4Mx/G7Ou7TXA%3D",
                        "file_type": 1
                    },
                    {
                        "file_url": "https://telrobot.obs.cn-southwest-2.myhuaweicloud.com:443/customer-service/label/92b1517d-a00d-456a-9ba4-bbd674391a2a/2308/%E6%96%B9%E5%A4%A7%E5%90%8C-%E5%90%AC%28%E6%A0%87%E6%B8%85%29Part019.mp4?AWSAccessKeyId=EWFUEKMADNJGBAOPAO1N&Expires=1692871702&Signature=L7gk3Ak7SeR4UOExv8Nsbfgyo28%3D",
                        "file_type": 1
                    }
                ]
            },
            {
                "translate_text": "2",
                "digital_human_contents": [
                    {
                        "file_url": "https://telrobot.obs.cn-southwest-2.myhuaweicloud.com:443/customer-service/label/92b1517d-a00d-456a-9ba4-bbd674391a2a/2308/%E6%96%B9%E5%A4%A7%E5%90%8C-%E5%90%AC%28%E6%A0%87%E6%B8%85%29Part010.mp4?AWSAccessKeyId=EWFUEKMADNJGBAOPAO1N&Expires=1692871702&Signature=9na/mckGH2WwbvkhATHJ1yNPQr8%3D",
                        "file_type": 1
                    }
                ]
            },
            {
                "translate_text": "3",
                "digital_human_contents": [
                    {
                        "file_url": "https://telrobot.obs.cn-southwest-2.myhuaweicloud.com:443/customer-service/label/92b1517d-a00d-456a-9ba4-bbd674391a2a/2308/%E6%96%B9%E5%A4%A7%E5%90%8C-%E5%90%AC%28%E6%A0%87%E6%B8%85%29Part005.mp4?AWSAccessKeyId=EWFUEKMADNJGBAOPAO1N&Expires=1692871702&Signature=3nUXMwAOylC5At85OFVljfqVnOA%3D",
                        "file_type": 1
                    }
                ]
            }
        ],
        "children_name": [
            "测试子话术"
        ]
    }
}

结束时返回

不勾选循环的话术 结束时

json
{
    "code": 200,
    "status": "success",
    "message": "成功",
    "data": [
        {
            "data": {
                "end": true
            }
        }
    ]
}
  • {tenant_id} 获取

tenant_id 获取

基于 MIT 许可发布