Contact Center AI 平台 (CCAI Platform) 为 SMS 渠道提供出站 SMS 端点。
出站短信
| 参数 | 必需 | 数据类型 | 定义 | |
|---|---|---|---|---|
| chat_type | TRUE | 字符串 | 要创建的 Chat 类型。“Messaging (API)”和“SMS”(已弃用)目前可用 | 消息传递 (API) |
| end_user_number | TRUE | 字符串 | 要发送短信的号码 | `{end_user_number}` |
| outbound_number | TRUE | 字符串 | 用于发送短信的出站手机号码 | `{outbound_number}` |
| 消息 | 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 关联的最终用户创建出站 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"
}
响应:创建包含 ticket_id 的出站 SMS 对话
{
"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
}
响应:创建出站 SMS 对话并使用 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
创建出站短信对话并将其分配给客服人员电子邮件地址
此示例演示了如何创建出站 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",
"agentEmail": "john.doe@foo.com"
}
响应:创建出站 SMS 对话并使用 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
错误:未启用短信
此示例演示了启动出站 SMS 但未启用 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"
}
响应:错误:未启用短信
{
"message": "SMS is not enabled"
}
状态代码:400
错误:未启用出站短信
此示例演示了以下失败场景:系统启动了 SMS 会话,但由于未启用 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"
}
回答:错误:未启用出站短信
{
"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
错误:必须提供消息
此示例演示了这样一种失败情形:在 requires 中未提供消息,但该消息是必需的。
请求
标头:
| 键 | 值 | 说明 |
|---|---|---|
| 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