REST Resource: conversations.messages

資源:訊息

服務專員和使用者之間對話中的訊息。

JSON 表示法
{
  "name": string,
  "messageId": string,
  "representative": {
    object (Representative)
  },
  "suggestions": [
    {
      object (Suggestion)
    }
  ],
  "fallback": string,
  "containsRichText": boolean,

  // Union field content can be only one of the following:
  "text": string,
  "image": {
    object (Image)
  },
  "richCard": {
    object (RichCard)
  }
  // End of list of possible types for union field content.
}
欄位
name

string

訊息名稱,由 Business Messages 設定。解析為「conversations/{conversationId}/messages/{messageId}」,其中 {conversationId} 是對話的專屬 ID,{messageId} 是訊息的專屬 ID。

messageId

string

必要欄位。訊息的專屬 ID,由服務專員指派。如果訊息嘗試使用與上一封郵件相同的 messageId,則訊息的正確傳送作業可能會受到影響。

representative

object (Representative)

傳送訊息的代表人 (真人或聊天機器人) 的詳細資料。

suggestions[]

object (Suggestion)

相關訊息結束後,以建議方塊清單的形式顯示建議回覆清單。最多 13 項建議。

只有在對話中的相關訊息是對話中的最新訊息 (包括服務專員和使用者訊息) 時,系統才會顯示方塊。使用者可以輕觸建議的回覆,將文字回覆傳送給服務專員。

fallback

string

選用設定。使用者裝置不支援訊息類型或內容時顯示的備用文字。長度上限為 3,072 個半形字元。

containsRichText

boolean

選用設定。如果為 true,表示訊息包含 RTF 格式。如果訊息包含無效的格式,Business Messages 就會傳回錯誤。

聯集欄位 content。訊息的內容。content 只能是下列其中一項:
text

string

簡訊。長度上限為 3,072 個半形字元。

image

object (Image)

圖片訊息。

richCard

object (RichCard)

複合式資訊卡訊息。

映像檔

圖片。

JSON 表示法
{

  // Union field content can be only one of the following:
  "contentInfo": {
    object (ContentInfo)
  }
  // End of list of possible types for union field content.
}
欄位
聯集欄位 content。圖片內容。content 只能是下列其中一項:
contentInfo

object (ContentInfo)

圖片的相關資訊,包括圖片網址和縮圖的網址。

ContentInfo

包含內容資訊的訊息。

JSON 表示法
{
  "fileUrl": string,
  "thumbnailUrl": string,
  "forceRefresh": boolean,
  "altText": string
}
欄位
fileUrl

string

檔案可公開存取的網址。在平台擷取檔案時,平台會從 HTTP 標頭的內容類型欄位判斷檔案的 MIME 類型。從網址發出的 HTTP 回應中,content-type 欄位必須存在且正確。

大小上限為 5 MB。

支援的內容類型:image/jpeg、image/jpg、image/png、image/webp

thumbnailUrl

string

選用設定。縮圖可公開存取的網址。

如未提供縮圖網址,平台會在使用者下載檔案前,顯示空白的預留位置縮圖。

大小上限為 25 KB。

支援的內容類型:image/jpeg、image/jpg、image/png、image/webp

forceRefresh

boolean

如果設定這項政策,即使平台已快取檔案 (和/或縮圖) 的副本,平台仍會從指定網址擷取檔案和縮圖。

altText

string

說明媒體詳細資料的文字,用於無障礙用途。

RichCard

獨立的複合式資訊卡或由服務專員傳送給使用者的複合式資訊卡輪轉介面。

JSON 表示法
{

  // Union field card can be only one of the following:
  "standaloneCard": {
    object (StandaloneCard)
  },
  "carouselCard": {
    object (CarouselCard)
  }
  // End of list of possible types for union field card.
}
欄位
聯集欄位 card。可能的複合式資訊卡類型。card 只能是下列其中一項:
standaloneCard

object (StandaloneCard)

獨立卡片。

carouselCard

object (CarouselCard)

資訊卡輪轉介面。

StandaloneCard

獨立卡片。

JSON 表示法
{
  "cardContent": {
    object (CardContent)
  }
}
欄位
cardContent

object (CardContent)

資訊卡內容。

CardContent

資訊卡內容。

JSON 表示法
{
  "title": string,
  "description": string,
  "media": {
    object (Media)
  },
  "suggestions": [
    {
      object (Suggestion)
    }
  ]
}
欄位
title

string

選用設定。資訊卡的標題。長度上限為 200 個半形字元。

description

string

選用設定。卡片說明。長度上限為 2,000 個半形字元。

media

object (Media)

選用設定。要加入資訊卡中的媒體。

suggestions[]

object (Suggestion)

選用設定。可加入資訊卡的建議清單。最多只能有 4 項建議。

媒體

互動式多媒體中的媒體檔案。

JSON 表示法
{
  "height": enum (Height),

  // Union field content can be only one of the following:
  "contentInfo": {
    object (ContentInfo)
  }
  // End of list of possible types for union field content.
}
欄位
height

enum (Height)

複合式資訊卡中的媒體高度。

聯集欄位 content。媒體內容:content 只能是下列其中一項:
contentInfo

object (ContentInfo)

檔案相關資訊,包括檔案網址與縮圖網址。

身高

媒體高度

列舉
HEIGHT_UNSPECIFIED 未指定。
SHORT 112 DP。
MEDIUM 168 DP。
TALL 264 DP。如果資訊卡寬度設為 SMALL,則不適用於複合式資訊卡輪轉介面。

建議

方塊清單中的建議。

JSON 表示法
{

  // Union field option can be only one of the following:
  "reply": {
    object (SuggestedReply)
  },
  "action": {
    object (SuggestedAction)
  },
  "liveAgentRequest": {
    object (LiveAgentRequest)
  },
  "authenticationRequest": {
    object (AuthenticationRequest)
  }
  // End of list of possible types for union field option.
}
欄位
聯集欄位 option。建議的回覆。option 只能是下列其中一項:
reply

object (SuggestedReply)

建議使用者以指定文字回覆的建議。

action

object (SuggestedAction)

此為建議動作,會在裝置上啟動原生動作。

liveAgentRequest

object (LiveAgentRequest)

要求真人服務專員加入對話。

authenticationRequest

object (AuthenticationRequest)

啟動驗證流程的要求。

SuggestedReply

輕觸後,將文字回覆傳送給服務專員。

JSON 表示法
{
  "text": string,
  "postbackData": string
}
欄位
text

string

建議回覆中顯示的文字,在使用者輕觸該文字時傳送給服務專員。長度上限為 25 個半形字元。

postbackData

string

使用者輕觸建議回覆時,代理程式會收到的字串。長度上限為 2,048 個半形字元。

SuggestedAction

使用者輕觸後,會在裝置上啟動相應的原生動作。

JSON 表示法
{
  "text": string,
  "postbackData": string,

  // Union field action can be only one of the following:
  "openUrlAction": {
    object (OpenUrlAction)
  },
  "dialAction": {
    object (DialAction)
  }
  // End of list of possible types for union field action.
}
欄位
text

string

建議動作中顯示的文字。長度上限為 25 個半形字元。

postbackData

string

使用者輕觸建議動作時,代理程式會收到的字串。長度上限為 2,048 個半形字元。

聯集欄位 action。使用者輕觸建議操作時,在裝置上啟動的原生動作。action 只能是下列其中一項:
openUrlAction

object (OpenUrlAction)

開啟指定網址。

dialAction

object (DialAction)

開啟使用者的預設撥號應用程式。

OpenUrlAction

開啟指定網址。

JSON 表示法
{
  "url": string
}
欄位
url

string

網址

DialAction

開啟使用者的預設撥號應用程式,並已填入指定的電話號碼。

JSON 表示法
{
  "phoneNumber": string
}
欄位
phoneNumber

string

必要欄位。指定的電話號碼,採用 RFC 3966 格式。例如「+1-201-555-0123」。

LiveAgentRequest

這個類型沒有任何欄位。

輕觸後,請傳送要求給真人服務專員加入對話。

AuthenticationRequest

要求驗證對話。

JSON 表示法
{

  // Union field authentication_type can be only one of the following:
  "oauth": {
    object (Oauth)
  }
  // End of list of possible types for union field authentication_type.
}
欄位
聯集欄位 authentication_type。驗證類型。authentication_type 只能是下列其中一項:
oauth

object (Oauth)

透過 OAuth 進行驗證的詳細資料。

OAuth

透過 OAuth 進行驗證的詳細資料。

JSON 表示法
{
  "clientId": string,
  "codeChallenge": string,
  "scopes": [
    string
  ],
  "codeChallengeMethod": string
}
欄位
clientId

string

必要欄位。要求授權的應用程式 ID

codeChallenge

string

必要欄位。用來交換存取權杖的程式碼驗證問題

scopes[]

string

必要欄位。指定要求範圍的陣列。

codeChallengeMethod

string

選用設定。用於產生程式碼驗證問題的程式碼驗證方法。如果省略這個參數,伺服器會假設 plain

CarouselCard

資訊卡輪轉介面。

JSON 表示法
{
  "cardWidth": enum (CardWidth),
  "cardContents": [
    {
      object (CardContent)
    }
  ]
}
欄位
cardWidth

enum (CardWidth)

輪轉介面中的資訊卡寬度。

cardContents[]

object (CardContent)

輪轉介面中每張資訊卡的內容清單。輪轉介面最多可有 2 張資訊卡和 10 張資訊卡。

CardWidth

輪轉介面中的資訊卡寬度。

列舉
CARD_WIDTH_UNSPECIFIED 未指定
SMALL 136 DP。無法加入高度媒體。
MEDIUM 280 DP。

方法

create

從服務專員傳送訊息給使用者。

updateReceipt

將服務專員訊息的收據傳送給使用者。