簡訊端點

Contact Center AI 平台 (CCAI 平台) 提供簡訊管道的 Outbound SMS 端點。

傳送簡訊

參數 必填 資料類型 定義
chat_type TRUE 字串 要建立的即時通訊類型。目前可使用「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 建立外寄 SMS 訊息對話

本範例說明如何建立傳送給與工單 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 的外送簡訊對話
{
  "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

建立外送 SMS 訊息對話,並使用代理程式 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 的外送 SMS 即時通訊

這個範例說明如何建立外送簡訊,而不將其與工單 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 的外送 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

錯誤:必須提供 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"
}

回應:Error : end_user_number is required

{
    "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"
}
回應:Error : outbound_number is required
{
    "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"
}
回應:錯誤:外撥號碼無效
{
    "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"
}
回應:Error : outbound_number is not found
{
    "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"
}
回應:Error : message is required
{
    "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