短信端点

Contact Center AI 平台 (CCAI Platform) 为短信渠道提供出站短信端点。

出站短信

参数 必需 数据类型 定义
chat_type TRUE 字符串 要创建的 Chat 类型。目前可使用“Messaging (API)”和“SMS”(已废弃) Messaging (API)
end_user_number TRUE 字符串 要向其发送短信的号码 `{end_user_number}`
outbound_number TRUE 字符串 用于发送短信的出站手机号码 `{outbound_number}`
message TRUE 字符串 要发送给消费者的短信 `{message}`
ticket_id FALSE 字符串 将与会话关联的 CRM 工单 ID `{ticket_id}`

端点

Method: POST
Type: RAW
URL: https://{{subdomain}}.{{domain}}/apps/api/v1/sms

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}

请求和响应示例

以下部分提供了向端点发出的请求示例。

使用工单 ID 创建出站短信聊天

此示例演示了如何向与工单 ID 关联的最终用户创建出站短信。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:使用 ticket_id 创建出站短信聊天
{
  "id": 114,
  "lang": "en",
  "chat_type": "Messaging (SMS)",
  "status": "selecting",
  "created_at": "2021-10-04T17:20:51.000Z",
  "queued_at": null,
  "assigned_at": null,
  "ends_at": null,
  "wait_duration": 0,
  "chat_duration": 0,
  "rating": null,
  "has_feedback": false,
  "out_ticket_id": null,
  "out_ticket_url": null,
  "verified": false,
  "disconnected_by": "disconnected_by_unknown",
  "fail_reason": null,
  "selected_menu": null,
  "menu_path": null,
  "agent_info": null,
  "end_user": {
    "id": 87,
    "identifier": null,
    "out_contact_id": null
  },
  "photos": [],
  "videos": [],
  "transfers": [],
  "participants": [
    {
      "id": 205,
      "type": "end_user",
      "status": "connected",
      "chat_id": 114,
      "user_id": null,
      "end_user_id": 87,
      "chat_duration": null,
      "connected_at": "2021-10-04T17:20:51.000Z",
      "ended_at": null,
      "fail_reason": "nothing"
    }
  ],
  "offer_type": null,
  "offer_events": [],
  "answer_type": "manual",
  "outbound_number": "+16285550199"
}

状态代码 200

创建出站短信聊天并使用智能体 ID 将其分配给智能体

此示例演示了如何创建根据提供的智能体 ID 分配给智能体的出站短信。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "agentId": 1
}
响应:创建出站短信聊天并使用 agentId 将其分配给智能体
{
    "id": 114,
    "lang": "en",
    "chat_type": "Messaging (SMS)",
    "status": "assigned",
    "created_at": "2021-10-04T17:20:51.000Z",
    "queued_at": null,
    "assigned_at": "2021-10-04T17:20:53.000Z",
    "ends_at": null,
    "wait_duration": 0,
    "chat_duration": 0,
    "rating": null,
    "has_feedback": false,
    "out_ticket_id": null,
    "out_ticket_url": null,
    "verified": false,
    "disconnected_by": "disconnected_by_unknown",
    "fail_reason": null,
    "selected_menu": null,
    "menu_path": null,
    "agent_info": {
        "id": 1,
        "agent_number": 9,
        "email": "john.doe@foo.com",
        "name": "John Doe",
        "first_name": "John",
        "last_name": "Doe",
        "avatar_url": "https://foobar.com/johndoe"
    },
    "end_user": {
        "id": 87,
        "identifier": null,
        "out_contact_id": null
    },
    "photos": [],
    "videos": [],
    "transfers": [],
    "participants": [
        {
            "id": 205,
            "type": "end_user",
            "status": "connected",
            "chat_id": 114,
            "user_id": null,
            "end_user_id": 87,
            "chat_duration": null,
            "connected_at": "2021-10-04T17:20:51.000Z",
            "ended_at": null,
            "fail_reason": "nothing"
        },
        {
            "id": 206,
            "type": "agent",
            "status": "connected",
            "chat_id": 114,
            "user_id": 1,
            "end_user_id": null,
            "chat_duration": null,
            "connected_at": "2021-10-04T17:20:53.000Z",
            "ended_at": null,
            "fail_reason": "nothing"
        }
    ],
    "offer_type": null,
    "offer_events": [],
    "answer_type": "manual",
    "outbound_number": "+16285550199"
}

状态代码 200

创建出站短信聊天并将其分配给智能体电子邮件地址

此示例演示了如何创建出站短信聊天会话,并根据提供的智能体电子邮件地址将其与智能体关联。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "agentEmail": "john.doe@foo.com"
}
响应:创建出站短信聊天并使用 agentId 将其分配给智能体
{
    "id": 114,
    "lang": "en",
    "chat_type": "Messaging (SMS)",
    "status": "assigned",
    "created_at": "2021-10-04T17:20:51.000Z",
    "queued_at": null,
    "assigned_at": "2021-10-04T17:20:53.000Z",
    "ends_at": null,
    "wait_duration": 0,
    "chat_duration": 0,
    "rating": null,
    "has_feedback": false,
    "out_ticket_id": null,
    "out_ticket_url": null,
    "verified": false,
    "disconnected_by": "disconnected_by_unknown",
    "fail_reason": null,
    "selected_menu": null,
    "menu_path": null,
    "agent_info": null,
    "end_user": {
        "id": 87,
        "identifier": null,
        "out_contact_id": null
    },
    "photos": [],
    "videos": [],
    "transfers": [],
    "participants": [
        {
            "id": 205,
            "type": "end_user",
            "status": "connected",
            "chat_id": 114,
            "user_id": null,
            "end_user_id": 87,
            "chat_duration": null,
            "connected_at": "2021-10-04T17:20:51.000Z",
            "ended_at": null,
            "fail_reason": "nothing"
        },
        {
            "id": 206,
            "type": "agent",
            "status": "connected",
            "chat_id": 114,
            "user_id": 1,
            "end_user_id": null,
            "chat_duration": null,
            "connected_at": "2021-10-04T17:20:53.000Z",
            "ended_at": null,
            "fail_reason": "nothing"
        }
    ],
    "offer_type": null,
    "offer_events": [],
    "answer_type": "manual",
    "outbound_number": "+16285550199"
}

状态代码 200

创建出站短信聊天,但不使用工单 ID

此示例演示了如何创建出站短信,但不将其与工单 ID 关联。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:创建出站短信聊天,但不使用 ticket_id
{
  "id": 114,
  "lang": "en",
  "chat_type": "Messaging (SMS)",
  "status": "selecting",
  "created_at": "2021-10-04T17:20:51.000Z",
  "queued_at": null,
  "assigned_at": null,
  "ends_at": null,
  "wait_duration": 0,
  "chat_duration": 0,
  "rating": null,
  "has_feedback": false,
  "out_ticket_id": null,
  "out_ticket_url": null,
  "verified": false,
  "disconnected_by": "disconnected_by_unknown",
  "fail_reason": null,
  "selected_menu": null,
  "menu_path": null,
  "agent_info": null,
  "end_user": {
    "id": 87,
    "identifier": null,
    "out_contact_id": null
  },
  "photos": [],
  "videos": [],
  "transfers": [],
  "participants": [
    {
      "id": 205,
      "type": "end_user",
      "status": "connected",
      "chat_id": 114,
      "user_id": null,
      "end_user_id": 87,
      "chat_duration": null,
      "connected_at": "2021-10-04T17:20:51.000Z",
      "ended_at": null,
      "fail_reason": "nothing"
    }
  ],
  "offer_type": null,
  "offer_events": [],
  "answer_type": "manual",
  "outbound_number": "+16285550199"
}

状态代码 200

错误:需要提供 chat_type

此示例演示了未提供“chat_type”但它是必需项时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:错误:需要提供 chat_type
{
    "message": "chat_type needs to be provided"
}

状态代码 400

错误:需要提供有效的聊天类型

此示例演示了需要提供聊天类型但缺少聊天类型时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "In-app",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:错误:需要提供有效的聊天类型
{
    "message": "valid chat type needs to be provided"
}

状态代码 400

错误:未启用短信

此示例演示了启动出站短信但未启用短信时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}

响应:错误:未启用短信

{
    "message": "SMS is not enabled"
}

状态代码 400

错误:未启用出站短信

此示例演示了启动短信会话但因未启用短信渠道而失败时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}

响应:错误:未启用出站短信

{
    "message": "Outbound SMS is not enabled"
}

状态代码 400

错误:必须提供最终用户号码

此示例演示了未提供最终用户号码但它是必需项时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}

响应:错误:必须提供 end_user_number

{
    "message": "end_user_number is required"
}

状态代码 400

错误:最终用户号码无效

此示例演示了提供的最终用户号码无效时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "12345",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}

响应:错误:end_user_number 无效

{
    "message": "end_user_number is invalid"
}

状态代码 400

错误:不允许使用非美国手机号码

此示例演示了提供的号码不是美国手机号码且被禁止使用时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+82 000-000-0000",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:错误:不允许使用非美国手机号码
{
    "message": "Non-US phone number not allowed"
}

状态代码 400

错误:必须提供出站号码

此示例演示了未提供出站号码但它是必需项时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:错误:必须提供 outbound_number
{
    "message": "outbound_number is required"
}

状态代码 400

错误:出站号码无效

此示例演示了提供的出站号码无效时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "12345",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:错误:outbound_number 无效
{
    "message": "outbound_number is invalid"
}

状态代码 400

错误:找不到 outbound_number

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:错误:找不到 outbound_number
{
    "message": "outbound_number is not found"
}

状态代码 400

错误:必须提供消息

此示例演示了未在必需项中提供消息但它是必需项时的失败场景。

请求

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:错误:必须提供消息
{
    "message": "message is required"
}

状态代码 400

错误:出站短信失败。消费者已处于活跃的短信会话中。

标头

说明
Content-Type application/json

正文

{
    "chat_type": "Messaging (SMS)",
    "end_user_number": "+1 415-555-0100",
    "outbound_number": "+1 628-555-0199",
    "message": "lorem ipsum",
    "ticket_id": "5006x00000XXxxxXXX"
}
响应:错误:出站短信失败。消费者已处于活跃的短信会话中。
{
    "message": "Outbound SMS failed. Consumer is already in an active SMS session."
}

状态代码 400