Find Direct Message
Find the existing direct message space between the authenticated user and one other user, identified by email address or numeric user id. Use this to address a person by identity instead of by an opaque space id: a direct message space has no displayName, so list_spaces can never tell you who a DM is with. Only finds conversations that already exist; it never creates one. Caution when the result is fed to create_message: if the identifier is mistyped but still resolves to another real user this account already has a DM with, this action succeeds and returns that person's space, and the returned space id is opaque, so it cannot be eyeballed to confirm the recipient. The result therefore carries peer, the person the space actually belongs to, named by Google Chat or the Workspace directory: read it back to the user and confirm the name before sending. Nothing enforces that check. Naming the peer needs the chat.memberships.readonly and directory.readonly scopes plus the People API on top of the scope below. When the peer cannot be resolved at all (listing the members or reading your own People id failed), peer is null and peerError says why, while the space itself is still returned. A resolved peer can still be unnamed: displayName is null for an AMBIGUOUS peer, for a BOT or SELF peer Google Chat did not name, and for a HUMAN peer the directory could not name (profileUnavailableReason then says why). Treat a null peer or a null displayName as an unconfirmed recipient.
googlechat.find_direct_message