Identify and specify Google Chat users (original) (raw)

This page explains the ways Google Chat apps can identify or specify Chat users.

To do any of the following, a Chat app must specify a user:

How Chat identifies users

The Google Chat API generates aUser resourcefor each person that uses Chat. The following are two importantUser fields:

Specify a user in a call to the Google Chat API

To specify a user, use the following values for the {user} value:

Identify a user from an interaction event

Every time a user interacts with a Chat app, Chat sends aninteraction event with information about the interaction and the user. For example, when a user mentions a Chat app in a message, the Chat app receives information about the interaction, including what the message says, and who sent it. Chat apps reference users when retrieving information about Chat resources.

To identify the user who interacted with a Chat app, get the value of the name property on theUser resource, which you can get fromEvent.user.name.

The following JSON example shows the expected format of the user identity in an interaction with a Chat app:

{
  ...,
  "user": {
    "name": "users/12345678901234567890",
    "displayName": "Sasha",
    "avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
    "email": "sasha@example.com"
  }
}

A message is a specific type of interaction. To identify a user who sent a message to a Chat app, get the value of the name property on theUser resource, using either of the following: