คำแนะนำนี้อธิบายวิธีการต่างๆ ที่แอป Google Chat สามารถส่งได้ ข้อความ:
- ส่งข้อความ SMS และการ์ดแบบเรียลไทม์โดยตอบกลับผู้ใช้ การโต้ตอบ
- ส่ง SMS และข้อความการ์ดแบบไม่พร้อมกันโดยเรียกใช้เมธอด
create
ใน ทรัพยากรMessage
- เริ่มหรือตอบกลับชุดข้อความ
- ส่งและตั้งชื่อข้อความ
แหล่งข้อมูล Message
รายการ
แสดงถึง
ข้อความ
หรือ
การ์ด
ใน Google Chat คุณสามารถ
create
, get
, update
หรือ delete
ข้อความใน Google Chat API โดยการเรียกใช้
ที่สัมพันธ์กัน หากต้องการเรียนรู้เพิ่มเติมเกี่ยวกับข้อความ SMS และการ์ด โปรดดูที่
ภาพรวมข้อความ Google Chat
ขนาดสูงสุดของข้อความ (รวมถึงข้อความหรือการ์ดทั้งหมด) คือ 32,000 ไบต์ หากมีข้อความเกินขนาดนี้ หมายความว่าแอป Chat ของคุณ สามารถส่งหลายข้อความแทนได้
แทนที่จะเรียกใช้เมธอด create
ในทรัพยากร Message
ของ
Google Chat API เพื่อส่ง SMS หรือข้อความการ์ดแบบไม่พร้อมกัน
แอป Google Chat ยังสร้างข้อความเพื่อตอบกลับการโต้ตอบของผู้ใช้ได้ใน
แบบเรียลไทม์ การตอบกลับการโต้ตอบของผู้ใช้ไม่ต้องมีการตรวจสอบสิทธิ์และ
รองรับข้อความประเภทอื่นๆ รวมถึงกล่องโต้ตอบและลิงก์แบบอินเทอร์แอกทีฟ
ตัวอย่าง โปรดดูรายละเอียดที่หัวข้อ
รับและตอบกลับการโต้ตอบกับแอป Google Chat
ข้อกำหนดเบื้องต้น
Node.js
- แอป Google Chat วิธีสร้างแอปใน Chat โดยใช้บริการ HTTP โปรดดำเนินการให้เสร็จสมบูรณ์ Quickstart
- กำหนดค่าการให้สิทธิ์สำหรับแอป Chat ในการส่ง
ข้อความแบบอะซิงโครนัส ไม่ต้องมีการกำหนดค่าการให้สิทธิ์เพื่อส่ง
ข้อความแบบเรียลไทม์
- กำลังส่ง
SMS
สนับสนุนวิธีการให้สิทธิ์ทั้งสองวิธี:
- การตรวจสอบสิทธิ์ผู้ใช้
ด้วยการให้สิทธิ์
chat.messages.create
หรือchat.messages
- การตรวจสอบสิทธิ์แอป
ที่มีขอบเขตการให้สิทธิ์
chat.bot
- การตรวจสอบสิทธิ์ผู้ใช้
ด้วยการให้สิทธิ์
- กำลังส่ง
ข้อความในการ์ด
ต้องใช้
การตรวจสอบสิทธิ์แอป
ที่มีขอบเขตการให้สิทธิ์
chat.bot
- กำลังส่ง
SMS
สนับสนุนวิธีการให้สิทธิ์ทั้งสองวิธี:
Python
- แอป Google Chat วิธีสร้างแอปใน Chat โดยใช้บริการ HTTP โปรดดำเนินการให้เสร็จสมบูรณ์ Quickstart
- กำหนดค่าการให้สิทธิ์สำหรับแอป Chat ในการส่ง
ข้อความแบบอะซิงโครนัส ไม่ต้องมีการกำหนดค่าการให้สิทธิ์เพื่อส่ง
ข้อความแบบเรียลไทม์
- กำลังส่ง
SMS
สนับสนุนวิธีการให้สิทธิ์ทั้งสองวิธี:
- การตรวจสอบสิทธิ์ผู้ใช้
ด้วยการให้สิทธิ์
chat.messages.create
หรือchat.messages
- การตรวจสอบสิทธิ์แอป
ที่มีขอบเขตการให้สิทธิ์
chat.bot
- การตรวจสอบสิทธิ์ผู้ใช้
ด้วยการให้สิทธิ์
- กำลังส่ง
ข้อความในการ์ด
ต้องใช้
การตรวจสอบสิทธิ์แอป
ที่มีขอบเขตการให้สิทธิ์
chat.bot
- กำลังส่ง
SMS
สนับสนุนวิธีการให้สิทธิ์ทั้งสองวิธี:
Apps Script
- แอป Google Chat วิธีสร้างแอปใน Chat ใน Apps Script ให้กรอกข้อมูลนี้ Quickstart
- กำหนดค่าการให้สิทธิ์สำหรับแอป Chat ในการส่ง
ข้อความแบบอะซิงโครนัส ไม่ต้องมีการกำหนดค่าการให้สิทธิ์เพื่อส่ง
ข้อความแบบเรียลไทม์
- กำลังส่ง
SMS
สนับสนุนวิธีการให้สิทธิ์ทั้งสองวิธี:
- การตรวจสอบสิทธิ์ผู้ใช้
ด้วยการให้สิทธิ์
chat.messages.create
หรือchat.messages
- การตรวจสอบสิทธิ์แอป
ที่มีขอบเขตการให้สิทธิ์
chat.bot
- การตรวจสอบสิทธิ์ผู้ใช้
ด้วยการให้สิทธิ์
- กำลังส่ง
ข้อความในการ์ด
ต้องใช้
การตรวจสอบสิทธิ์แอป
ที่มีขอบเขตการให้สิทธิ์
chat.bot
- กำลังส่ง
SMS
สนับสนุนวิธีการให้สิทธิ์ทั้งสองวิธี:
ส่งข้อความ
ส่วนนี้จะอธิบายวิธีการส่งข้อความด้วย 2 วิธีต่อไปนี้
- ส่งข้อความแบบเรียลไทม์โดยตอบกลับการโต้ตอบของผู้ใช้
- ส่งข้อความด้วยการเรียกใช้ Google Chat API แบบไม่พร้อมกัน
ส่งข้อความแบบเรียลไทม์
ในตัวอย่างนี้ แอป Chat จะสร้างและส่งข้อความ เมื่อใดก็ตามที่มีการเพิ่มลงในพื้นที่ทำงาน ดูข้อมูลเกี่ยวกับแนวทางปฏิบัติแนะนำสำหรับ ผู้ใช้ที่เริ่มต้นใช้งาน โปรดดู ช่วยให้ผู้คนและพื้นที่ทำงานเริ่มต้นใช้งานการเริ่มต้นใช้งานที่มีประโยชน์
วิธีส่งข้อความเมื่อผู้ใช้เพิ่มแอป Chat
พื้นที่ทำงาน ในแอป Chat
ตอบสนองต่อ ADDED_TO_SPACE
เหตุการณ์การโต้ตอบ เพื่อตอบกลับ
ADDED_TO_SPACE
เหตุการณ์การโต้ตอบที่มี SMS ใช้รหัสต่อไปนี้
Node.js
/**
* Sends an onboarding message when the Chat app is added to a space.
*
* @param {Object} event The event object from Chat API.
* @return {Object} Response from the Chat app. An onboarding message that
* introduces the app and helps people get started with it.
*/
exports.onMessage = function onMessage(req, res) {
if (req.method === 'GET' || !req.body.message) {
res.send(
'Hello! This function is meant to be used in a Google Chat space.');
}
// Send an onboarding message when added to a Chat space
if (req.body.type === 'ADDED_TO_SPACE') {
res.json({
'text': 'Hi, Cymbal at your service. I help you manage your calendar
from Google Chat. Take a look at your schedule today by typing
`/checkCalendar`, or schedule a meeting with `/scheduleMeeting`. To
learn what else I can do, type `/help`.'
});
}
};
Apps Script
/**
* Sends an onboarding message when the Chat app is added to a space.
*
* @param {Object} event The event object from Chat API.
* @return {Object} Response from the Chat app. An onboarding message that
* introduces the app and helps people get started with it.
*/
function onAddToSpace(event) {
return {
'text': 'Hi, Cymbal at your service. I help you manage your calendar
from Google Chat. Take a look at your schedule today by typing
`/checkCalendar`, or schedule a meeting with `/scheduleMeeting`. To learn
what else I can do, type `/help`.'
}
}
ตัวอย่างโค้ดแสดงข้อความต่อไปนี้
ส่งข้อความแบบไม่พร้อมกัน
ส่วนต่อไปนี้จะอธิบายวิธีส่งข้อความแบบไม่พร้อมกันด้วย การตรวจสอบสิทธิ์แอปและการตรวจสอบสิทธิ์ผู้ใช้
หากต้องการส่ง SMS ให้ส่งข้อมูลต่อไปนี้ในคำขอ
- เมื่อใช้การตรวจสอบสิทธิ์แอป ให้ระบุขอบเขตการให้สิทธิ์
chat.bot
ด้วย การตรวจสอบสิทธิ์ผู้ใช้ ให้ระบุขอบเขตการให้สิทธิ์chat.messages.create
- เรียกใช้
create
วิธี ใน แหล่งข้อมูลMessage
ส่งข้อความที่มีการตรวจสอบสิทธิ์แอป
ต่อไปนี้คือวิธีการส่งข้อความด้วย การตรวจสอบสิทธิ์แอป:
Python
- ในไดเรกทอรีการทำงาน ให้สร้างไฟล์ชื่อ
chat_create_text_message_app.py
รวมรหัสต่อไปนี้ใน
chat_create_text_message_app.py
:from apiclient.discovery import build from google.oauth2 import service_account # Specify required scopes. SCOPES = ['https://www.googleapis.com/auth/chat.bot'] # Specify service account details. CREDENTIALS = service_account.Credentials.from_service_account_file( 'credentials.json', scopes=SCOPES) # Build the URI and authenticate with the service account. chat = build('chat', 'v1', credentials=CREDENTIALS) # Create a Chat message. result = chat.spaces().messages().create( # The space to create the message in. # # Replace SPACE with a space name. # Obtain the space name from the spaces resource of Chat API, # or from a space's URL. parent='spaces/SPACE', # The message to create. body={'text': 'Hello, world!'} ).execute() print(result)
ในโค้ด ให้แทนที่
SPACE
ด้วยชื่อพื้นที่ทำงาน ซึ่ง ที่คุณจะได้รับจากspaces.list()
วิธี ใน Chat API หรือจาก URL ของพื้นที่ทำงานในไดเรกทอรีการทำงาน ให้สร้างและเรียกใช้ตัวอย่างด้วยคำสั่งต่อไปนี้
python3 chat_create_text_message_app.py
Chat API จะแสดงผลอินสแตนซ์
Message
ซึ่งระบุรายละเอียดของข้อความที่ส่ง
ส่งข้อความที่มีการตรวจสอบสิทธิ์ผู้ใช้
ต่อไปนี้คือวิธีการส่งข้อความด้วย การตรวจสอบสิทธิ์ผู้ใช้:
Python
- ในไดเรกทอรีการทำงาน ให้สร้างไฟล์ชื่อ
chat_create_text_message_user.py
รวมรหัสต่อไปนี้ใน
chat_create_text_message_user.py
:import os.path from google.auth.transport.requests import Request from google.oauth2.credentials import Credentials from google_auth_oauthlib.flow import InstalledAppFlow from googleapiclient.discovery import build from googleapiclient.errors import HttpError # Define your app's authorization scopes. # When modifying these scopes, delete the file token.json, if it exists. SCOPES = ["https://www.googleapis.com/auth/chat.messages.create"] def main(): ''' Authenticates with Chat API via user credentials, then creates a text message in a Chat space. ''' # Start with no credentials. creds = None # Authenticate with Google Workspace # and get user authorization. flow = InstalledAppFlow.from_client_secrets_file( 'client_secrets.json', SCOPES) creds = flow.run_local_server() # Build a service endpoint for Chat API. chat = build('chat', 'v1', credentials=creds) # Use the service endpoint to call Chat API. result = chat.spaces().messages().create( # The space to create the message in. # # Replace SPACE with a space name. # Obtain the space name from the spaces resource of Chat API, # or from a space's URL. parent='spaces/SPACE', # The message to create. body={'text': 'Hello, world!'} ).execute() # Prints details about the created message. print(result) if __name__ == '__main__': main()
ในโค้ด ให้แทนที่
SPACE
ด้วยชื่อพื้นที่ทำงาน ซึ่ง ที่คุณจะได้รับจากspaces.list()
เมธอดใน Chat API หรือจาก URL ของพื้นที่ทำงานในไดเรกทอรีการทำงาน ให้สร้างและเรียกใช้ตัวอย่างด้วยคำสั่งต่อไปนี้
python3 chat_create_text_message_user.py
Chat API จะแสดงผลอินสแตนซ์
Message
ซึ่งระบุรายละเอียดของข้อความที่ส่ง
ส่งข้อความการ์ด
ส่วนนี้จะอธิบายวิธีส่งข้อความการ์ดได้ 2 วิธีดังนี้
- ส่งข้อความการ์ดแบบเรียลไทม์โดยตอบกลับการโต้ตอบของผู้ใช้
- ส่งข้อความการ์ดโดยเรียกใช้ Google Chat API แบบไม่พร้อมกัน
ส่งข้อความการ์ดแบบเรียลไทม์
แอปในแชทสามารถสร้างข้อความการ์ดเพื่อตอบผู้ใช้ได้ เช่น เมื่อผู้ใช้ส่งแอป Chat หรือเพิ่มแอป Chat ไปยังพื้นที่ทำงาน เพื่อดูข้อมูลเพิ่มเติม เกี่ยวกับการตอบสนองต่อการโต้ตอบของผู้ใช้ โปรดดูที่รับและตอบสนอง การโต้ตอบในแอปแชท กิจกรรม
ในตัวอย่างนี้ ผู้ใช้ส่งข้อความไปยังแอป Chat และแอป Chat ตอบสนองด้วยการส่งข้อความการ์ด ที่แสดงชื่อและรูปโปรไฟล์ของผู้ใช้
Node.js
Python
Apps Script
ตัวอย่างนี้ส่งข้อความการ์ดโดยการส่งคืน JSON ของการ์ด คุณยังสามารถใช้ บริการการ์ด Apps Script
ส่งข้อความการ์ดแบบไม่พร้อมกัน
หากต้องการส่ง ข้อความในการ์ด ส่งต่อสิ่งต่อไปนี้ในคำขอของคุณ
- เมื่อใช้การตรวจสอบสิทธิ์แอป ให้ระบุขอบเขตการให้สิทธิ์
chat.bot
เธอทำไม่ได้หรอก ส่งข้อความการ์ดที่มีการตรวจสอบสิทธิ์ผู้ใช้ - เรียกใช้
create
วิธี ใน แหล่งข้อมูลMessage
ตัวอย่างข้อความในการ์ดมีดังนี้
วิธีส่งข้อความการ์ดที่มีการตรวจสอบสิทธิ์แอปมีดังนี้
Python
- ในไดเรกทอรีการทำงาน ให้สร้างไฟล์ชื่อ
chat_create_card_message.py
รวมรหัสต่อไปนี้ใน
chat_create_card_message.py
:from apiclient.discovery import build from google.oauth2 import service_account # Specify required scopes. SCOPES = ['https://www.googleapis.com/auth/chat.bot'] # Specify service account details. CREDENTIALS = service_account.Credentials.from_service_account_file( 'credentials.json', scopes=SCOPES) # Build the URI and authenticate with the service account. chat = build('chat', 'v1', credentials=CREDENTIALS) # Create a Chat message. result = chat.spaces().messages().create( # The space to create the message in. # # Replace SPACE with a space name. # Obtain the space name from the spaces resource of Chat API, # or from a space's URL. parent='spaces/SPACE', # The message to create. body= { 'cardsV2': [{ 'cardId': 'createCardMessage', 'card': { 'header': { 'title': 'A card message!', 'subtitle': 'Created with the Chat API', 'imageUrl': 'https://developers.google.com/chat/images/chat-product-icon.png', 'imageType': 'CIRCLE' }, 'sections': [ { 'widgets': [ { 'buttonList': { 'buttons': [ { 'text': 'Read the docs!', 'onClick': { 'openLink': { 'url': 'https://developers.google.com/chat' } } } ] } } ] } ] } }] } ).execute() print(result)
ในโค้ด ให้แทนที่
SPACE
ด้วยชื่อพื้นที่ทำงาน ซึ่ง ที่คุณจะได้รับจากspaces.list
วิธี ใน Chat API หรือจาก URL ของพื้นที่ทำงานในไดเรกทอรีการทำงาน ให้สร้างและเรียกใช้ตัวอย่างด้วยคำสั่งต่อไปนี้
python3 chat_create_card_message.py
เริ่มหรือตอบกลับชุดข้อความ
หากต้องการเริ่มชุดข้อความ ให้ส่งข้อความแล้วออก
thread.name
ว่างเปล่า Google Chat จะป้อนข้อมูลนี้เมื่อสร้างชุดข้อความ หากต้องการ
กำหนดชื่อชุดข้อความเอง ระบุ
thread.threadKey
ด้วย
หากต้องการตอบกลับชุดข้อความ ให้ส่งข้อความที่ระบุชุดข้อความ
threadKey
หรือ name
หากชุดข้อความสร้างขึ้นโดยบุคคลหรือผู้อื่น
แอป Chat คุณต้องใช้ช่อง thread.name
หากไม่พบชุดข้อความที่ตรงกัน คุณจะระบุได้
ข้อความควรขึ้นชุดข้อความใหม่หรือโพสต์ไม่สำเร็จจากการตั้งค่า
messageReplyOption
ด้วย
หากเป็น messageReplyOption
ได้รับการตั้งค่าแล้ว คุณต้องตั้งค่าthread.name
หรือthread.threadKey
ด้วย
ต่อไปนี้เป็นวิธีเริ่มหรือตอบกลับชุดข้อความที่มีช่อง threadKey
กำหนดไว้เป็น
nameOfThread
:
Python
- ในไดเรกทอรีการทำงาน ให้สร้างไฟล์ชื่อ
chat_create_message_thread.py
รวมรหัสต่อไปนี้ใน
chat_create_message_thread.py
:from apiclient.discovery import build from google.oauth2 import service_account # Specify required scopes. SCOPES = ['https://www.googleapis.com/auth/chat.bot'] # Specify service account details. CREDENTIALS = service_account.Credentials.from_service_account_file( 'credentials.json', scopes=SCOPES) # Build the URI and authenticate with the service account. chat = build('chat', 'v1', credentials=CREDENTIALS) # Create a Chat message. result = chat.spaces().messages().create( # The space to create the message in. # # Replace SPACE with a space name. # Obtain the space name from the spaces resource of Chat API, # or from a space's URL. parent='spaces/SPACE', # Whether to start a thread or reply to an existing one. # # Required when threading is enabled in a space unless starting a # thread. Ignored in other space types. Threading is enabled when # space.spaceThreadingState is THREADED_MESSAGES. # # REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD replies to an existing thread # if one exists, otherwise it starts a new one. messageReplyOption='REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD', # The message body. body={ # The message to create. 'text': 'Start or reply to another message in a thread!', # The thread to start or reply to. 'thread': { 'threadKey': 'nameOfThread' } } ).execute() print(result)
ในโค้ด ให้แทนที่
SPACE
ด้วยชื่อพื้นที่ทำงาน ซึ่ง ที่คุณจะได้รับจากspaces.list
วิธี ใน Chat API หรือจาก URL ของพื้นที่ทำงานในไดเรกทอรีการทำงาน ให้สร้างและเรียกใช้ตัวอย่างด้วยคำสั่งต่อไปนี้
python3 chat_create_message_thread.py
Chat API จะแสดงผลอินสแตนซ์
Message
ซึ่งระบุรายละเอียดของข้อความที่ส่ง
ตั้งชื่อข้อความ
ส่วนนี้จะอธิบายวิธีตั้งชื่อข้อความโดยการตั้งค่ารหัสที่กำหนดเองสำหรับ
คุณใช้รหัสที่กำหนดเองเพื่อรับ อัปเดต หรือลบข้อความได้ รหัสที่กำหนดเอง
ช่วยให้คุณระบุข้อความได้โดยไม่ต้องจัดเก็บรหัสที่ระบบกำหนดจาก
ชื่อทรัพยากรของข้อความ (แสดงในช่อง name
) แหล่งข้อมูล
จะสร้างขึ้นในส่วน
เนื้อหาการตอบสนอง
เมื่อคุณสร้างข้อความ
ตัวอย่างเช่น ในการเรียกข้อความโดยใช้เมธอด get()
ให้ใช้เมธอด
ชื่อทรัพยากรเพื่อระบุข้อความที่จะเรียก ชื่อทรัพยากรคือ
มีรูปแบบเป็น spaces/{space}/messages/{message}
โดยที่ {message}
แสดงถึง
รหัสที่ระบบกำหนด หากคุณตั้งชื่อข้อความไว้ คุณสามารถแทนที่
ค่าของ {message}
ด้วยรหัสที่กำหนดเอง
หากต้องการตั้งชื่อข้อความ ให้ระบุรหัสที่กำหนดเองใน
messageId
เมื่อคุณสร้างข้อความ ฟิลด์ messageId
จะตั้งค่าค่าของฟิลด์
clientAssignedMessageId
ของทรัพยากร Message
คุณสามารถตั้งชื่อข้อความได้เฉพาะเมื่อสร้างข้อความเท่านั้น คุณไม่สามารถตั้งชื่อหรือ แก้ไขรหัสที่กำหนดเองสำหรับข้อความที่มีอยู่ รหัสที่กำหนดเองต้องเป็นไปตามข้อกำหนดต่อไปนี้ ข้อกำหนด
- ขึ้นต้นด้วย
client-
เช่นclient-custom-name
เป็นที่กําหนดเองที่ถูกต้อง รหัส แต่custom-name
ไม่ใช่รหัส - มีอักขระได้สูงสุด 63 ตัว และมีเฉพาะตัวพิมพ์เล็ก ตัวเลข และ ขีดกลาง
- ไม่ซ้ำกันภายในพื้นที่ทำงาน แอป Chat ไม่สามารถใช้ รหัสที่กำหนดเองเดียวกันสำหรับข้อความที่แตกต่างกัน
วิธีส่งข้อความด้วยรหัสที่กำหนดเองมีดังนี้
Python
- ในไดเรกทอรีการทำงาน ให้สร้างไฟล์ชื่อ
chat_create_named_message.py
รวมรหัสต่อไปนี้ใน
chat_create_named_message.py
:from apiclient.discovery import build from google.oauth2 import service_account # Specify required scopes. SCOPES = ['https://www.googleapis.com/auth/chat.bot'] # Specify service account details. CREDENTIALS = service_account.Credentials.from_service_account_file( 'credentials.json', scopes=SCOPES) # Build the URI and authenticate with the service account. chat = build('chat', 'v1', credentials=CREDENTIALS) # Create a Chat message with a custom name. result = chat.spaces().messages().create( # The space to create the message in. # # Replace SPACE with a space name. # Obtain the space name from the spaces resource of Chat API, # or from a space's URL. parent='spaces/SPACE', # Custom name for the message used to facilitate later operations. messageId='client-NAME', # The message to create. body={'text': 'Hello, world!'} ).execute() print(result)
ในโค้ด ให้แทนที่
SPACE
: รหัสพื้นที่ทำงานที่คุณต้องการ โพสต์ข้อความ ซึ่งคุณจะได้รับจากspaces.list
วิธี ใน Chat API หรือจาก URL ของพื้นที่ทำงานNAME
: ชื่อที่กำหนดเองของข้อความ
ในไดเรกทอรีการทำงาน ให้สร้างและเรียกใช้ตัวอย่างด้วยคำสั่งต่อไปนี้
python3 chat_create_named_message.py
Chat API จะแสดงผลอินสแตนซ์
Message
เพิ่มวิดเจ็ตแบบอินเทอร์แอกทีฟที่ด้านล่างของข้อความ
หรือเพิ่มข้อความต่อท้ายด้วยวิดเจ็ตอุปกรณ์เสริม วิดเจ็ตเสริมจะปรากฏขึ้นหลังข้อความหรือการ์ดในข้อความ คุณใช้ตัวเลือกเหล่านี้ได้ เพื่อแจ้งเตือนให้ผู้ใช้โต้ตอบกับข้อความของคุณด้วยวิธีการต่างๆ เช่น ดังต่อไปนี้
- ให้คะแนนความถูกต้องหรือความพึงพอใจของข้อความ
- รายงานปัญหาเกี่ยวกับข้อความหรือแอป Chat
- เปิดลิงก์ไปยังเนื้อหาที่เกี่ยวข้อง เช่น เอกสารประกอบ
- ปิดหรือเลื่อนการแจ้งเตือนข้อความที่คล้ายกันจากแอป Chat สำหรับระยะเวลาที่กำหนด
หากต้องการเพิ่มวิดเจ็ตอุปกรณ์เสริม ให้ใส่
accessoryWidgets[]
ในข้อความและระบุ
AccessoryWidgets
ที่คุณต้องการรวมไว้ด้วย ทุกคนในพื้นที่ทำงานต้องเห็นข้อความ
(คุณจะเพิ่มวิดเจ็ตอุปกรณ์เสริมในข้อความส่วนตัวไม่ได้)
รูปภาพต่อไปนี้แสดงแอปใน Chat ที่ต่อท้าย ข้อความที่มีวิดเจ็ตอุปกรณ์เสริมเพื่อให้ผู้ใช้ให้คะแนนประสบการณ์การใช้งาน ด้วยแอป Chat
ตัวอย่างโค้ดต่อไปนี้แสดง JSON สำหรับข้อความนี้ เมื่อผู้ใช้คลิก
ปุ่มใดปุ่มหนึ่ง การโต้ตอบจะทริกเกอร์ฟังก์ชันที่เกี่ยวข้อง (เช่น
doUpvote
) ที่ประมวลผลการจัดประเภท
"text": "Rate your experience with this Chat app.",
"accessoryWidgets": [
{
"buttonList": {
"buttons": [
{
"icon": {
"material_icon": {
"name": "thumb_up"
}
},
"color": {
"red": 0,
"blue": 255,
"green": 0
},
"onClick": {
"action": {
"function": "doUpvote",
}
}
},
{
"icon": {
"material_icon": {
"name": "thumb_down"
}
},
"color": {
"red": 0,
"blue": 255,
"green": 0
},
"onClick": {
"action": {
"function": "doDownvote",
}
}
}
]
}
}
]
ส่งข้อความแบบส่วนตัว
แอปแชทสามารถส่งข้อความ SMS และการ์ดแบบส่วนตัวเพื่อให้
ข้อความจะแสดงต่อผู้ใช้ 1 คนในพื้นที่ทำงาน ถ้าจะส่งข้อความแบบส่วนตัว
คุณระบุช่อง privateMessageViewer
ในข้อความ เฉพาะ
แอปแชทจะส่งข้อความส่วนตัวได้ เมื่อต้องการส่งข้อความส่วนตัว
แบบอะซิงโครนัส คุณต้องใช้การตรวจสอบสิทธิ์แอป
โปรดดูรายละเอียดที่หัวข้อส่งข้อความส่วนตัวไปยัง Google Chat ผู้ใช้
แก้ปัญหา
เมื่อแอป Google Chat หรือ card จะแสดงผลข้อผิดพลาด อินเทอร์เฟซ Chat แสดงข้อความว่า "เกิดข้อผิดพลาด" หรือ "ไม่สามารถดำเนินการตามคำขอของคุณ" บางครั้ง UI ของ Chat ไม่แสดงข้อความแสดงข้อผิดพลาดใดๆ แต่แอป Chat หรือ ทำให้เกิดผลลัพธ์ที่ไม่คาดคิด เช่น ข้อความในการ์ดอาจ ปรากฏขึ้น
แม้ว่าข้อความแสดงข้อผิดพลาดอาจไม่แสดงใน UI ของแชท มีข้อความแสดงข้อผิดพลาดและข้อมูลบันทึกที่สื่อความหมายเพื่อช่วยคุณแก้ไขข้อผิดพลาด เมื่อมีการเปิดข้อผิดพลาดในการบันทึกสำหรับแอป Chat หากต้องการความช่วยเหลือในการดู การแก้ไขข้อบกพร่องและการแก้ไขข้อผิดพลาด โปรดดู แก้ปัญหาข้อผิดพลาดของ Google Chat
หัวข้อที่เกี่ยวข้อง
- จัดรูปแบบข้อความ
- ดูรายละเอียดเกี่ยวกับข้อความ
- แสดงข้อความในพื้นที่ทำงาน
- อัปเดตข้อความ
- ลบข้อความ
- ระบุผู้ใช้ในข้อความใน Google Chat
- ส่งข้อความไปยัง Google Chat ด้วยเว็บฮุคขาเข้า