2024 年 7 月 31 日をもって、Google ビジネス メッセージはご利用いただけなくなります。詳しくは
こちらをご覧ください。
Hello World
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
メッセージとイベントの送受信は通信のコア側面
エージェントとユーザーの間の
やり取りですエージェントがユーザーにメッセージ、イベント、リクエストを送信する
ユーザーが作成したメッセージとイベントを受信する
JSON 形式で入力できます
サンプルデータを使用して会話のフローの例を以下に示します。
メッセージ、イベント、リクエストは、有用で有意義なインタラクションを生み出します。
この例では、ユーザーが会話を開始し、「Hello,
I'm World!」と表示されている場合、エージェントは「Hello, World」と応答します。

- ユーザーがエージェントとの会話を開始します。
ユーザーが回答の入力を開始すると、メッセージに入力イベントが送信されます。
できます。
{
"agent": "brands/1111/agents/2222",
"conversationId": "3333",
"customAgentId": "hello-world-bot",
"requestId": "1234567890",
"userStatus": {
"isTyping": "true",
"createTime": "2020-10-02T15:01:23.045123456Z",
},
"sendTime": "2020-10-02T15:01:24.045123456Z",
}
ユーザーが「Hello, I'm World!」を送信したとき受け取ります
{
"agent": "brands/1111/agents/2222",
"conversationId": "3333",
"customAgentId": "hello-world-bot",
"requestId": "123123123",
"message": {
"messageId": "4444",
"name": "conversations/12345/messages/67890",
"text": "Hello! I'm World!",
"createTime": "2020-10-02T15:05:23.045123456Z",
},
"context": {
"entryPoint": "PLACESHEET",
"userInfo": {
"displayName": "Michael",
"userDeviceLocale": "en",
},
"resolvedLocale": "en",
}
"sendTime": "2020-10-02T15:05:24.045123456Z",
}
エージェントが「Hello, World」を送信します。受け取ります
curl -X POST "https://businessmessages.googleapis.com/v1/conversations/3333/messages" \
-H "Content-Type: application/json" \
-H "`oauth2l header --json path/to/service/account/key.json businessmessages`" \
-d "{
'messageId': '5555',
'text': 'Hello, World',
'representative': {
'avatarImage': 'https://hello.world/avatar.jpg',
'displayName': 'Hello World Agent',
'representativeType': 'BOT'
}
}"
メールが配信されると、ユーザーのデバイスから配信確認メッセージが届きます。
{
"agent": "brands/1111/agents/2222",
"conversationId": "3333",
"customAgentId": "hello-world-bot",
"receipts" : {
"receipts": [
{
"message": "conversations/3333/messages/5555",
"receiptType": "DELIVERED",
}
],
"createTime": "2020-10-02T16:01:23.045123456Z",
},
"sendTime": "2020-10-02T16:01:24.045123456Z",
}
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-09-12 UTC。
[null,null,["最終更新日 2024-09-12 UTC。"],[[["\u003cp\u003eAgents and users communicate by sending and receiving messages and events through the Business Messages API and webhooks.\u003c/p\u003e\n"],["\u003cp\u003eUser interactions, such as typing and sending messages, are sent to the agent as JSON payloads containing relevant information like user details and message content.\u003c/p\u003e\n"],["\u003cp\u003eAgents can respond to users with messages containing text and optional representative details like display name and avatar.\u003c/p\u003e\n"],["\u003cp\u003eThe platform provides delivery receipts to the agent, confirming the delivery status of messages sent to the user.\u003c/p\u003e\n"]]],[],null,["# Hello, World\n\nSending and receiving messages and events are the core aspects of communication\nbetween an agent and a user. Agents send messages, events, and requests to users\nthrough the Business Messages API but receive user-created messages and events\nat their webhooks as JSON.\n\nBelow is an example conversation flow that uses sample data to illustrate how\nmessages, events, and requests can create useful and meaningful interactions.\n\nIn this example, the user starts a conversation and sends the message \"Hello,\nI'm World!\", then the agent responds with \"Hello, World\".\n\n1. The user begins the conversation with the agent.\n2. Once the user begins typing a response, they send a typing event to the\n agent.\n\n {\n \"agent\": \"brands/1111/agents/2222\",\n \"conversationId\": \"3333\",\n \"customAgentId\": \"hello-world-bot\",\n \"requestId\": \"1234567890\",\n \"userStatus\": {\n \"isTyping\": \"true\",\n \"createTime\": \"2020-10-02T15:01:23.045123456Z\",\n },\n \"sendTime\": \"2020-10-02T15:01:24.045123456Z\",\n }\n\n3. The user sends \"Hello, I'm World!\" as a message.\n\n {\n \"agent\": \"brands/1111/agents/2222\",\n \"conversationId\": \"3333\",\n \"customAgentId\": \"hello-world-bot\",\n \"requestId\": \"123123123\",\n \"message\": {\n \"messageId\": \"4444\",\n \"name\": \"conversations/12345/messages/67890\",\n \"text\": \"Hello! I'm World!\",\n \"createTime\": \"2020-10-02T15:05:23.045123456Z\",\n },\n \"context\": {\n \"entryPoint\": \"PLACESHEET\",\n \"userInfo\": {\n \"displayName\": \"Michael\",\n \"userDeviceLocale\": \"en\",\n },\n \"resolvedLocale\": \"en\",\n }\n \"sendTime\": \"2020-10-02T15:05:24.045123456Z\",\n }\n\n4. The agent sends \"Hello, World\" as a message.\n\n curl -X POST \"https://businessmessages.googleapis.com/v1/conversations/3333/messages\" \\\n -H \"Content-Type: application/json\" \\\n -H \"`oauth2l header --json path/to/service/account/key.json businessmessages`\" \\\n -d \"{\n 'messageId': '5555',\n 'text': 'Hello, World',\n 'representative': {\n 'avatarImage': 'https://hello.world/avatar.jpg',\n 'displayName': 'Hello World Agent',\n 'representativeType': 'BOT'\n }\n }\"\n\n5. Upon message delivery, the user's device returns a delivery receipt.\n\n {\n \"agent\": \"brands/1111/agents/2222\",\n \"conversationId\": \"3333\",\n \"customAgentId\": \"hello-world-bot\",\n \"receipts\" : {\n \"receipts\": [\n {\n \"message\": \"conversations/3333/messages/5555\",\n \"receiptType\": \"DELIVERED\",\n }\n ],\n \"createTime\": \"2020-10-02T16:01:23.045123456Z\",\n },\n \"sendTime\": \"2020-10-02T16:01:24.045123456Z\",\n }"]]