메시지 보내 줘

이 가이드에서는 Google Chat 앱에서 메시지를 전송할 수 있는 다양한 방법을 설명합니다. 메시지:

  • 사용자에게 응답하여 실시간으로 문자 및 카드 메시지를 보내세요 상호작용하지 않습니다.
  • create 메서드를 호출하여 텍스트 및 카드 메시지를 비동기식으로 전송합니다. Message 리소스
  • 메시지 대화목록을 시작하거나 답장을 보냅니다.
  • 메시지를 보내고 이름을 지정합니다.

Message 리소스텍스트 또는 카드 메시지가 표시됩니다. 다음과 같은 작업을 할 수 있습니다. 다음을 호출하여 Google Chat API의 create, get, update 또는 delete 메시지 사용할 수 있습니다. 문자 및 카드 메시지에 대한 자세한 내용은 다음을 참고하세요. Google Chat 메시지 개요

최대 메시지 크기 (텍스트 또는 카드 포함)는 32,000바이트입니다. 메시지가 이 크기를 초과하면 채팅 앱에서 여러 개의 메시지를 보낼 수 있습니다.

다음의 Message 리소스에서 create 메서드를 호출하는 대신 Google Chat API를 사용하여 문자 또는 카드 메시지를 비동기식으로 전송 또한 Google Chat 앱은 사용자 상호작용에 응답하기 위해 있습니다. 사용자 상호작용에 대한 응답에는 인증이 필요하지 않으며 대화형 대화상자, 링크 등 다른 유형의 메시지 지원 미리 볼 수 있습니다 자세한 내용은 Google Chat 앱과의 상호작용을 수신하고 응답하세요.

기본 요건

Node.js

  • Google Workspace 액세스 권한이 있는 계정 Google Chat
  • Google Chat API가 사용 설정되고 구성된 Google Cloud 프로젝트 단계는 다음을 참조하세요. Google Chat 앱을 빌드합니다.
  • 채팅 앱에서 전송하도록 구성된 승인 비동기 메시지를 표시합니다. 전송하는 데 승인 구성이 필요하지 않습니다. 채팅 메시지를 실시간으로 전송합니다.
    • 문자 메시지 다음 두 가지 승인 방법을 모두 지원합니다. <ph type="x-smartling-placeholder">
        </ph>
      • 사용자 인증 chat.messages.create 또는 chat.messages 승인 범위를 제공합니다
      • 앱 인증 chat.bot 승인 범위로 제한됩니다.
    • 카드 메시지 요구사항 앱 인증 chat.bot 승인 범위를 사용합니다.

Python

  • Google Workspace 액세스 권한이 있는 계정 Google Chat
  • Python 3.6 이상
  • pip 패키지 관리 도구
  • Python용 최신 Google 클라이언트 라이브러리입니다. 이러한 앱을 설치하거나 업데이트하려면 다음 단계를 따르세요. 명령줄 인터페이스에서 다음 명령어를 실행합니다.

    pip3 install --upgrade google-api-python-client google-auth
    
  • Google Chat API가 사용 설정되고 구성된 Google Cloud 프로젝트 단계는 다음을 참조하세요. Google Chat 앱을 빌드합니다.
  • 채팅 앱에서 전송하도록 구성된 승인 비동기 메시지를 표시합니다. 전송하는 데 승인 구성이 필요하지 않습니다. 채팅 메시지를 실시간으로 전송합니다.

    • 문자 메시지 다음 두 가지 승인 방법을 모두 지원합니다. <ph type="x-smartling-placeholder">
        </ph>
      • 사용자 인증 chat.messages.create 또는 chat.messages 승인 범위를 제공합니다
      • 앱 인증 chat.bot 승인 범위로 제한됩니다.
    • 카드 메시지 요구사항 앱 인증 chat.bot 승인 범위를 사용합니다.

Apps Script

  • Google Workspace 액세스 권한이 있는 계정 Google Chat
  • 게시된 채팅 앱 새로운 채팅 앱, 팔로우하기 빠른 시작:
  • 채팅 앱에서 전송하도록 구성된 승인 비동기 메시지를 표시합니다. 전송하는 데 승인 구성이 필요하지 않습니다. 채팅 메시지를 실시간으로 전송합니다.
    • 문자 메시지 다음 두 가지 승인 방법을 모두 지원합니다. <ph type="x-smartling-placeholder">
        </ph>
      • 사용자 인증 chat.messages.create 또는 chat.messages 승인 범위를 제공합니다
      • 앱 인증 chat.bot 승인 범위로 제한됩니다.
    • 카드 메시지 요구사항 앱 인증 chat.bot 승인 범위를 사용합니다.

문자 메시지 보내기

이 섹션에서는 다음 두 가지 방법으로 문자 메시지를 보내는 방법을 설명합니다.

  • 사용자 상호작용에 응답하여 실시간으로 문자 메시지를 보낼 수 있습니다.
  • Google Chat API를 비동기식으로 호출하여 문자 메시지를 보냅니다.

실시간으로 문자 메시지 보내기

이 예시에서는 채팅 앱이 메시지가 표시됩니다. 온라인 여행 포털에 대한 자세한 내용은 유용한 온보딩으로 사용자와 스페이스를 시작하세요.

사용자가 채팅 앱을 추가할 때 문자 메시지를 보내기 위해 채팅 앱 스페이스에 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`.'
  }
}

코드 샘플은 다음 텍스트 메시지를 반환합니다.

온보딩 메시지 예시

비동기식으로 문자 메시지 보내기

다음 섹션에서는 앱 인증과 사용자 인증이 있습니다

문자 메시지를 보내려면 요청에 다음을 전달합니다.

  • 앱 인증의 경우 chat.bot 승인 범위를 지정합니다. 다음으로 바꿉니다. 사용자 인증의 경우 chat.messages.create 승인 범위를 지정합니다.
  • 먼저 create 메서드Message 리소스.

앱 인증이 포함된 문자 메시지 보내기

다음을 사용하여 문자 메시지를 보내는 방법은 다음과 같습니다. 앱 인증:

Python

  1. 작업 디렉터리에서 chat_create_text_message_app.py
  2. 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)
    
  3. 코드에서 SPACE을 공백 이름으로 바꿉니다. GCP 콘솔에서 spaces.list() 메서드 Chat API 또는 스페이스의 URL에서 가져올 수 있습니다.

  4. 작업 디렉터리에서 샘플을 빌드하고 실행합니다.

    python3 chat_create_text_message_app.py
    

Chat API는 Message 전송된 메시지를 자세히 설명합니다.

사용자 인증을 포함한 문자 메시지 전송

다음을 사용하여 문자 메시지를 보내는 방법은 다음과 같습니다. 사용자 인증:

Python

  1. 작업 디렉터리에서 chat_create_text_message_user.py
  2. 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()
    
  3. 코드에서 SPACE을 공백 이름으로 바꿉니다. GCP 콘솔에서 spaces.list() 메서드를 Chat API 또는 스페이스의 URL에서 가져올 수 있습니다.

  4. 작업 디렉터리에서 샘플을 빌드하고 실행합니다.

    python3 chat_create_text_message_user.py
    

Chat API는 Message 전송된 메시지를 자세히 설명합니다.

카드 메시지 보내기

이 섹션에서는 다음 두 가지 방법으로 카드 메시지를 보내는 방법을 설명합니다.

  • 사용자 상호작용에 응답하여 실시간으로 카드 메시지를 전송합니다.
  • Google Chat API를 비동기식으로 호출하여 카드 메시지를 전송합니다.

실시간으로 카드 메시지 전송

채팅 앱에서 카드 메시지를 만들어 사용자에게 응답할 수 있습니다. 예를 들어 사용자가 채팅 앱에 메시지를 보내거나 스페이스에 채팅 앱을 추가합니다. 자세히 알아보기 사용자 상호작용에 응답하는 방법은 사용자 상호작용에 대한 채팅 앱 상호작용 이벤트를 사용하세요.

이 예시에서는 사용자가 채팅 앱에 메시지를 보냅니다. 채팅 앱이 카드 메시지를 전송하여 응답합니다. 사용자 이름과 아바타 이미지를 표시합니다.

발신자의 표시 이름과 아바타가 표시된 카드로 응답하는 Chat 앱
이미지

Node.js

node/avatar-app/index.js
/**
 * Google Cloud Function that responds to messages sent from a
 * Google Chat room.
 *
 * @param {Object} req Request sent from Google Chat room
 * @param {Object} res Response to send back
 */
exports.helloChat = function helloChat(req, res) {
  if (req.method === 'GET' || !req.body.message) {
    res.send('Hello! This function is meant to be used in a Google Chat '  
      'Room.');
  }

  const sender = req.body.message.sender.displayName;
  const image = req.body.message.sender.avatarUrl;

  const data = createMessage(sender, image);

  res.send(data);
};

/**
 * Creates a card with two widgets.
 * @param {string} displayName the sender's display name
 * @param {string} imageUrl the URL for the sender's avatar
 * @return {Object} a card with the user's avatar.
 */
function createMessage(displayName, imageUrl) {
  const cardHeader = {
    title: `Hello ${displayName}!`,
  };

  const avatarWidget = {
    textParagraph: {text: 'Your avatar picture: '},
  };

  const avatarImageWidget = {
    image: {imageUrl},
  };

  const avatarSection = {
    widgets: [
      avatarWidget,
      avatarImageWidget,
    ],
  };

  return {
    text: 'Here\'s your avatar',
    cardsV2: [{
      cardId: 'avatarCard',
      card: {
        name: 'Avatar Card',
        header: cardHeader,
        sections: [avatarSection],
      }
    }],
  };
}

Python

python/avatar-app/main.py
from typing import Any, Mapping

import flask
import functions_framework


# Google Cloud Function that responds to messages sent in
# Google Chat.
#
# @param {Object} req Request sent from Google Chat.
# @param {Object} res Response to send back.
@functions_framework.http
def hello_chat(req: flask.Request) -> Mapping[str, Any]:
  if req.method == "GET":
    return "Hello! This function must be called from Google Chat."

  request_json = req.get_json(silent=True)

  display_name = request_json["message"]["sender"]["displayName"]
  avatar = request_json["message"]["sender"]["avatarUrl"]

  response = create_message(name=display_name, image_url=avatar)

  return response


# Creates a card with two widgets.
# @param {string} name the sender's display name.
# @param {string} image_url the URL for the sender's avatar.
# @return {Object} a card with the user's avatar.
def create_message(name: str, image_url: str) -> Mapping[str, Any]:
  avatar_image_widget = {"image": {"imageUrl": image_url}}
  avatar_text_widget = {"textParagraph": {"text": "Your avatar picture:"}}
  avatar_section = {"widgets": [avatar_text_widget, avatar_image_widget]}

  header = {"title": f"Hello {name}!"}

  cards = {
      "text": "Here's your avatar",
      "cardsV2": [
          {
              "cardId": "avatarCard",
              "card": {
                  "name": "Avatar Card",
                  "header": header,
                  "sections": [avatar_section],
              },
          }
      ]
  }

  return cards

Apps Script

이 예시에서는 카드 JSON과 함께 사용합니다. 또한 Apps Script 카드 서비스.

apps-script/avatar-app/hello-chat.gs
/**
 * Responds to a MESSAGE event in Google Chat.
 *
 * @param {Object} event the event object from Google Chat
 */
function onMessage(event) {
  const displayName = event.message.sender.displayName;
  const avatarUrl = event.message.sender.avatarUrl;

  return createMessage(displayName, avatarUrl);
}

/**
 * Creates a card with two widgets.
 * @param {string} displayName the sender's display name
 * @param {string} avatarUrl the URL for the sender's avatar
 * @return {Object} a card with the sender's avatar.
 */
function createMessage(displayName, avatarUrl) {
  const cardHeader = {
    title: `Hello ${displayName}!`
  };

  const avatarWidget = {
    textParagraph: {text: 'Your avatar picture: '}
  };

  const avatarImageWidget = {
    image: {imageUrl: avatarUrl}
  };

  const avatarSection = {
    widgets: [
      avatarWidget,
      avatarImageWidget
    ],
  };

  return {
    text: 'Here\'s your avatar',
    cardsV2: [{
      cardId: 'avatarCard',
      card: {
        name: 'Avatar Card',
        header: cardHeader,
        sections: [avatarSection],
      }
    }],
  };
}

비동기식으로 카드 메시지 전송

카드 메시지, 요청에 다음을 전달합니다.

  • 앱 인증의 경우 chat.bot 승인 범위를 지정합니다. 할 수 없습니다. 사용자 인증이 포함된 카드 메시지를 보냅니다.
  • 먼저 create 메서드Message 리소스.

다음은 카드 메시지의 예입니다.

Chat API를 통해 전송되는 카드 메시지입니다.

앱 인증을 통해 카드 메시지를 보내는 방법은 다음과 같습니다.

Python

  1. 작업 디렉터리에서 chat_create_card_message.py
  2. 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)
    
  3. 코드에서 SPACE을 공백 이름으로 바꿉니다. GCP 콘솔에서 spaces.list 메서드 Chat API 또는 스페이스의 URL에서 가져올 수 있습니다.

  4. 작업 디렉터리에서 샘플을 빌드하고 실행합니다.

    python3 chat_create_card_message.py
    

메시지 대화목록 시작 또는 답장

메시지 대화목록을 시작하려면 메시지를 보내고 thread.name 비어 있습니다. Google Chat에서 대화목록을 만들 때 이 입력란을 채웁니다. 원하는 경우 스레드의 이름을 맞춤설정하고 thread.threadKey 필드를 확인합니다.

메시지 대화목록에 답장하려면 대화목록의 threadKey 또는 name 필드 대화목록이 다른 사람 또는 다른 사람이 만든 경우 채팅 앱에서는 thread.name 필드를 사용해야 합니다.

일치하는 대화목록이 없으면 메시지가 새 대화목록을 시작하는지 아니면 게시 실패인지 여부를 지정합니다. messageReplyOption 필드를 확인합니다.

messageReplyOption인 경우 이 설정되면 thread.name 또는 thread.threadKey도 설정해야 합니다.

다음과 같이 정의된 threadKey 필드로 스레드를 시작하거나 스레드에 답장하는 방법은 다음과 같습니다. nameOfThread:

Python

  1. 작업 디렉터리에서 chat_create_message_thread.py
  2. 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)
    
  3. 코드에서 SPACE을 공백 이름으로 바꿉니다. GCP 콘솔에서 spaces.list 메서드 Chat API 또는 스페이스의 URL에서 가져올 수 있습니다.

  4. 작업 디렉터리에서 샘플을 빌드하고 실행합니다.

    python3 chat_create_message_thread.py
    

Chat API는 Message 전송된 메시지를 자세히 설명합니다.

메시지 이름 지정

이 섹션에서는 메시지가 표시됩니다. 맞춤 ID를 사용하여 메일을 가져오거나 업데이트하거나 삭제할 수 있습니다. 맞춤 ID 시스템 할당 ID를 저장하지 않고도 메시지를 지정할 수 있습니다. 메시지의 리소스 이름입니다 (name 필드에 표시됨). 리소스 생성된 포드의 이름은 응답 본문 설정할 수 있습니다.

예를 들어 get() 메서드를 사용하여 메시지를 검색하려면 다음을 사용합니다. 리소스 이름을 사용하여 검색할 메시지를 지정합니다. 리소스 이름은 spaces/{space}/messages/{message} 형식으로 표시되며, 여기서 {message}는 다음을 나타냅니다. 시스템에서 할당한 ID를 찾습니다. 메일 이름을 지정한 경우 {message}의 값을 커스텀 ID로 바꿉니다.

메일 이름을 지정하려면 맞춤 ID를 지정합니다. messageId 필드를 설정할 수 없습니다. messageId 필드는 clientAssignedMessageId Message 리소스의 필드입니다.

메시지를 만들 때만 메시지 이름을 지정할 수 있습니다. 이름을 지정하거나 기존 메일의 맞춤 ID를 수정할 수 있습니다. 커스텀 ID는 다음을 충족해야 합니다. 요구사항:

  • client-로 시작합니다. 예를 들어 client-custom-name는 유효한 커스텀입니다. ID이지만 custom-name는 아닙니다.
  • 최대 63자(영문 기준)까지 소문자, 숫자, 하이픈이 있습니다.
  • 스페이스 내에서 고유합니다. 채팅 앱에서는 여러 메시지에 대해 동일한 맞춤 ID를 사용할 수 있습니다.

맞춤 ID를 사용하여 메시지를 보내는 방법은 다음과 같습니다.

Python

  1. 작업 디렉터리에서 chat_create_named_message.py
  2. 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)
    
  3. 코드에서 다음을 바꿉니다.

    • SPACE: 추가하려는 스페이스의 ID입니다. 메시지를 게시하세요. spaces.list 메서드 Chat API 또는 스페이스의 URL에서 가져올 수 있습니다.
    • NAME: 메시지의 맞춤 이름입니다.
  4. 작업 디렉터리에서 샘플을 빌드하고 실행합니다.

    python3 chat_create_named_message.py
    

Chat API는 Message

메시지 하단에 대화형 위젯 추가

<ph type="x-smartling-placeholder">

원하는 경우 액세서리 위젯을 사용하여 메시지를 추가할 수 있습니다. 액세서리 위젯은 메시지의 텍스트 또는 카드 뒤에 표시됩니다. 이러한 다음과 같은 다양한 방법으로 사용자가 메시지와 상호작용하도록 메시지를 표시하는 위젯 다음과 같습니다.

  • 메시지의 정확성 또는 만족도를 평가합니다.
  • 메시지 또는 채팅 앱 문제 신고
  • 문서와 같은 관련 콘텐츠의 링크를 엽니다.
  • Chat 앱에서 비슷한 메시지 닫기 또는 다시 알림 확인할 수 있습니다.

액세서리 위젯을 추가하려면 accessoryWidgets[] 객체를 하나 이상 지정하고 AccessoryWidgets 포함할 수 있습니다. 메시지는 스페이스에 있는 모든 사용자에게 표시되어야 합니다. 비공개 메시지에는 액세서리 위젯을 추가할 수 없습니다.

다음 이미지는 다음을 추가하는 채팅 앱을 보여줍니다. 액세서리 위젯이 포함된 문자 메시지로 사용자가 사용 환경을 평가할 수 있음 채팅 앱

액세서리 위젯의 예

다음 코드 샘플은 이 메시지의 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",
             }
           }
         }
       ]
     }
   }
 ]

비공개로 메시지 보내기

채팅 앱에서 문자 및 카드 메시지를 비공개로 전송하여 메시지는 스페이스의 사용자 한 명에게만 표시됩니다. 비공개로 메시지를 보내려면 다음 안내를 따르세요. 메시지에서 privateMessageViewer 필드를 지정합니다. 단 채팅 앱에서 비공개 메시지를 보낼 수 있습니다. 비공개 메시지 보내기 비동기식으로 사용하려면 앱 인증을 사용해야 합니다.

자세한 내용은 Google Chat에 비공개 메시지 보내기를 참고하세요. 사용자가 누구인지 알아보세요.

문제 해결

Google Chat 앱 또는 card가 오류를 반환하는 경우 Chat 인터페이스에 '문제가 발생했습니다'라는 메시지가 표시됨 또는 '요청을 처리할 수 없습니다'와 같은 메시지가 표시됩니다. 채팅 UI가 오류 메시지가 표시되지 않지만 채팅 앱 또는 카드에서 예기치 않은 결과가 발생합니다. 예를 들어 카드 메시지가 나타납니다.

채팅 UI에 오류 메시지가 표시되지 않을 수도 있지만 오류 해결에 도움이 되는 오류 메시지 및 로그 데이터를 사용할 수 있음 채팅 앱의 오류 로깅이 사용 설정된 경우 보는 데 도움이 필요한 경우 오류를 수정하는 방법에 대한 자세한 내용은 Google Chat 오류 문제 해결하기