Google Chat 사용자에게 비공개 메시지 보내기

이 페이지에서는 개인 메시지를 Google Chat 앱

비공개 메시지는 지정된 Chat 사용자에게 표시됩니다. 다음에서 비공개 메시지를 사용할 수 있습니다. 다른 사용자와 비공개로 상호작용할 수 있는 스페이스입니다. 채팅 앱 예를 들어 채팅 앱에서 비공개로 메시지를 전송하여 있습니다.

  • 슬래시 명령어에 응답합니다. 예를 들어 사용자가 채팅 앱의 /about 슬래시를 호출하는 경우 명령어를 사용하면 채팅 앱에서 채팅 앱 내용을 설명하는 비공개 메시지 이해하는 것이 중요합니다.
  • 한 명의 사용자에게만 관련된 정보를 알리거나 전송합니다. 대상 예: 사용자에게 작업이 할당되었다고 알림 또는 알림 작업을 완료합니다
  • 오류 메시지를 보냅니다. 예를 들어 사용자가 필수 인수 텍스트를 생략한 경우 슬래시 명령어의 경우 채팅 앱은 비공개 메시지를 사용하여 오류를 설명하고 사용자가 명령어 형식을 지정할 수 있도록 지원합니다.
  • 스페이스에 사용자가 추가되면 비공개 환영 메시지 전송 에서 가이드라인이나 채팅 앱 사용 방법을 설명합니다.

채팅 앱에서 비공개 메시지를 보내면 메시지 는 메시지가 본인에게만 표시된다는 것을 사용자에게 알리는 라벨을 표시합니다.

비공개 메시지:
  Cymbal Labs 채팅 앱 메시지에
  Cymbal Labs에서 만든 채팅 앱은 링크를 공유합니다.
  문서 및 지원팀에 문의할 수 있는 링크를 제공합니다.
그림 1: 채팅 앱이 비공개 메시지인 경우 사용자에게 라벨이 있는 메시지가 표시됩니다. Only visible to you라고 표시됩니다.

기본 요건

Node.js

  • 양방향 기능이 사용 설정된 Google Chat 앱 대화형 채팅 앱을 사용하려면 이 빠른 시작을 완료하세요.
  • 슬래시 명령어에 비공개로 응답하기 위해 채팅 앱 빌드하려면 다음을 참조하세요. 슬래시 명령어에 응답합니다.

  • 앱을 사용하여 비공개 메시지를 보내려면 messages.create() 메서드를 사용하려면 앱 인증을 사용해야 합니다.

Python

  • 양방향 기능이 사용 설정된 Google Chat 앱 대화형 채팅 앱을 사용하려면 이 빠른 시작을 완료하세요.
  • 슬래시 명령어에 비공개로 응답하기 위해 채팅 앱 빌드하려면 다음을 참조하세요. 슬래시 명령어에 응답합니다.

  • 앱을 사용하여 비공개 메시지를 보내려면 messages.create() 메서드를 사용하려면 앱 인증을 사용해야 합니다.

Apps Script

  • 양방향 기능이 사용 설정된 Google Chat 앱 Apps Script에서 대화형 채팅 앱을 사용하려면 이 빠른 시작을 완료하세요.
  • 슬래시 명령어에 비공개로 응답하기 위해 채팅 앱 빌드하려면 다음을 참조하세요. 슬래시 명령어에 응답합니다.

  • 앱을 사용하여 비공개 메시지를 보내려면 messages.create() 메서드를 사용하려면 앱 인증을 사용해야 합니다.

비공개 메시지 보내기

채팅 앱으로 비공개로 메시지를 보내려면 privateMessageViewer 필드를 설정할 수 있습니다. 비공개 메시지를 작성할 때처럼 사용자 상호작용에 응답하여 메시지를 만들 수 있습니다. Google Chat API의 create() 메서드 Message 리소스. 문자 또는 카드 메시지를 보내는 방법은 다음을 참고하세요. 메시지 보내기

다음 예는 Hello private world!:

{
    "text": "Hello private world!",
    "privateMessageViewer": "USER"
}

이 예에서 USER는 Chat 사용자를 나타냅니다. User 리소스 상호작용 이벤트에서 User 객체를 지정할 수 있습니다. 예는 다음 섹션을 참고하세요. 슬래시 명령어에 비공개로 응답

또는 비공개 메시지의 뷰어를 지정하려면 Username 필드 리소스:

{
    "text": "Hello private world!",
    "privateMessageViewer": {
      "name": "users/USER_ID"
    }
}

이 예시에서는 name 필드를 사용하여 뷰어의 User를 지정합니다. 리소스 이름을 입력합니다. USER_ID 교체 사용자의 고유 ID(예: 12345678987654321 또는 hao@cymbalgroup.com입니다.

사용자 지정에 대한 자세한 내용은 다음을 참조하세요. Google Chat 사용자를 식별하고 지정합니다.

슬래시 명령어에 비공개로 응답

다음 코드는 채팅 앱의 예를 보여줍니다. 비공개 메시지로 슬래시 명령어에 응답합니다.

채팅 앱은 MESSAGE 상호작용 이벤트 그런 다음 /help 슬래시 명령어에 사용 방법을 설명합니다.

Node.js

/**
* Responds to a MESSAGE event in Google Chat.
*
* @param {!Object} req Request sent from Google Chat app
* @param {!Object} res Response to send back
*
* @return {!Object} respond to slash command
*/
exports.onMessage = function onMessage(req, res) {
  if (req.method === 'GET' || !req.body.message) {
    return res.send('Hello! This function is meant to be used in Google Chat app.');
  }

  const event = req.body;

  // Checks for the presence of event.message.slashCommand.
  // If the slash command is "/help", responds with a private text message.
  if (event.message.slashCommand) {
    switch (event.message.slashCommand.commandId) {
      case '1':  // /help
        return res.json({
          privateMessageViewer: event.user,
          text: 'This Chat app was created by Cymbal Labs. To get help with this app, <https://cymbalgroup.com/docs|see our documentation> or <https://cymbalgroup.com/support|contact our support team>.'
        });
    }
  }

  // If the Chat app doesn't detect a slash command, it responds
  // with a private text message
  return res.json({
    privateMessageViewer: event.user,
    text: 'Try a slash command.'
  });
};

Apps Script

/**
* Responds to a MESSAGE event in Google Chat.
*
* @param {Object} event the event object from Google Chat
*/
function onMessage(event) {
  if (event.message.slashCommand) {
    switch (event.message.slashCommand.commandId) {
      case 1: // Responds to /help
        return {
          "privateMessageViewer": event.user,
          "text": "This Chat app was created by Cymbal Labs. To get help with this app, <https://cymbalgroup.com/docs|see our documentation> or <https://cymbalgroup.com/support|contact our support team>."
        };
    }
  }
  else {
    return { "text": "Try a slash command.", "privateMessageViewer": event.user };
  }
}

Python

from typing import Any, Mapping

import flask
import functions_framework

@functions_framework.http
def main(req: flask.Request) -> Mapping[str, Any]:
  """Responds to a MESSAGE event in Google Chat.

  Args:
      req (flask.Request): the event object from Chat API.

  Returns:
      Mapping[str, Any]: open a Dialog in response to a card's button click.
  """
  if req.method == 'GET':
    return 'Hello! This function must be called from Google Chat.'

  request = req.get_json(silent=True)

  # Checks for the presence of event.message.slashCommand.
  # If the slash command is "/help", responds with a private text message.
  if request.get('message', {}).get('slashCommand'):
    command_id = request.get('message', {}).get('slashCommand').get('commandId')
    if command_id == '1':  # /help
      return {
          'privateMessageViewer': request.get('user'),
          'text': (
              'This Chat app was created by Cymbal Labs. To get help with this'
              ' app, <https://cymbalgroup.com/docs|see our documentation> or'
              ' <https://cymbalgroup.com/support|contact our support team>.'
          ),
      }

  return {
      'privateMessageViewer': request.get('user'),
      'text': 'Try a slash command.',
  }

제한사항

비공개 메시지를 보내려면 메시지에 있습니다.

  • 첨부파일.
  • 액세서리 작업.
  • 부분 비공개 메시지입니다. 예를 들어 채팅 앱이 있습니다. 문자 메시지 및 텍스트가 포함된 카드가 포함된 메시지를 보낼 수 없음 한 명이지만 스페이스의 모든 사용자에게 카드가 표시됩니다.
  • 사용자 인증. 채팅 앱에서만 비공개 메시지를 보낼 수 있으므로 채팅 앱이 사용자로 인증하여 메시지가 비공개로 표시됩니다.

비공개 메시지 업데이트 또는 삭제하기

Google Chat 메시지를 업데이트하거나 삭제하려면 Chat API 비공개 메시지의 뷰어를 변경하거나 메시지를 공개합니다. 따라서 비공개 메시지를 업데이트할 때 API 호출의 privateMessageViewer 필드 (이 필드는 출력 전용)

비공개 메시지를 업데이트하려면 다음을 참조하세요. 메시지 업데이트하기 비공개 메시지를 삭제하려면 다음을 참조하세요. 메시지 삭제