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

必需。消息的唯一标识符,由代理分配。如果某条消息尝试与上一条消息使用同一个 messageId,则消息的正确传送可能会受到影响。

representative

object (Representative)

发送消息的代表(人类或聊天机器人)的详细信息。

suggestions[]

object (Suggestion)

建议回复的列表,在关联的消息之后显示为建议内容信息卡的列表。最多 13 条建议。

条状标签仅在关联消息是对话中的最新消息(包括代理消息和用户消息)时显示。用户可以点按建议的回复,将短信回复发送给客服人员。

fallback

string

(可选)在用户的设备不支持消息类型或内容时显示的后备文字。最多 3072 个字符。

containsRichText

boolean

(可选)如果为 true,则表示消息包含富文本。如果消息包含无效的格式,Business Messages 将返回错误。

联合字段 content。消息的内容。content 只能是下列其中一项:
text

string

短信。最多 3072 个字符。

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)

有关图片的信息,包括图片的网址和缩略图的网址。

内容信息

包含内容信息的消息。

JSON 表示法
{
  "fileUrl": string,
  "thumbnailUrl": string,
  "forceRefresh": boolean,
  "altText": string
}
字段
fileUrl

string

文件的可公开访问网址。平台在提取文件时,会根据 HTTP 标头中的内容类型字段确定文件的 MIME 类型。内容类型的 HTTP 响应中必须有准确的内容类型字段。

不超过 5 MB。

支持的内容类型:图片/jpeg、图片/jpg、图片/png、图片/webp

thumbnailUrl

string

(可选)可公开访问的缩略图网址。

如果您不提供缩略图网址,平台会显示空白的占位符缩略图,直到用户的设备下载文件为止。

不超过 25 KB。

支持的内容类型:图片/jpeg、图片/jpg、图片/png、图片/webp

forceRefresh

boolean

如果设置了此属性,平台会从指定的网址中提取文件和缩略图,即使平台已经缓存了文件(和/或缩略图)也是如此。

altText

string

描述媒体详细信息的文本,用于实现无障碍功能。

复合信息卡

从相应代理发送给用户的独立复合信息卡或复合信息卡轮播界面。

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)

卡片轮播界面。

独立卡片

独立卡片。

JSON 表示法
{
  "cardContent": {
    object (CardContent)
  }
}
字段
cardContent

object (CardContent)

卡片内容。

CardContent

卡片内容。

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

string

(可选)卡片的标题。最多 200 个字符。

description

string

(可选)卡片的说明。最多 2000 个字符。

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)

启动身份验证流程的请求。

建议的回复

点按后,系统会将文本回复发回给代理。

JSON 表示法
{
  "text": string,
  "postbackData": string
}
字段
text

string

显示在建议回复中并在用户点按后发送给代理的文本。最多 25 个字符。

postbackData

string

在用户点按建议的回复时代理收到的字符串。最多 2048 个字符。

建议操作

点按后,会启动设备上的相应原生操作。

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

用户点按建议操作时代理收到的字符串。最多 2048 个字符。

联合字段 action。用户点按建议操作时在设备上发起的原生操作。action 只能是下列其中一项:
openUrlAction

object (OpenUrlAction)

打开指定的网址。

dialAction

object (DialAction)

打开用户的默认拨号器应用。

OpenUrl 操作

打开指定的网址。

JSON 表示法
{
  "url": string
}
字段
url

string

网址

拨号操作

打开用户填写了指定电话号码的默认拨号器应用。

JSON 表示法
{
  "phoneNumber": string
}
字段
phoneNumber

string

必需。指定的电话号码,采用 RFC 3966 格式。例如“+1-201-555-0123”。

LiveAgent 请求

点按后,系统会请求人工客服加入对话。

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

轮播卡片

卡片轮播界面。

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

enum (CardWidth)

轮播界面中的卡片宽度。

cardContents[]

object (CardContent)

轮播中每张卡片的内容列表。一个轮播界面最多可包含 2 张卡片和 10 张卡片。

卡片宽度

轮播界面中的卡片宽度。

枚举
CARD_WIDTH_UNSPECIFIED 未指定
SMALL 136 DP。不能包含高媒体。
MEDIUM 280 DP。

方法

create

从代理向用户发送消息。

updateReceipt

向用户发送代理发送的消息收据。