Google Chat का इस्तेमाल करने वाले लोगों की पहचान करना और उनके बारे में बताना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
इस पेज पर बताया गया है कि Google Chat ऐप्लिकेशन, Chat के उपयोगकर्ताओं की पहचान कैसे कर सकते हैं या उनके बारे में जानकारी कैसे दे सकते हैं.
इनमें से कोई भी काम करने के लिए, चैट ऐप्लिकेशन को किसी उपयोगकर्ता की जानकारी देनी होगी:
Chat, उपयोगकर्ताओं की पहचान कैसे करता है
Google Chat API, Chat का इस्तेमाल करने वाले हर व्यक्ति के लिए एक User
संसाधन जनरेट करता है. यहां दो अहम User
फ़ील्ड दिए गए हैं:
name
, संसाधन का नाम है. इसे users/{user}
के तौर पर फ़ॉर्मैट किया जाता है. इसमें {user}
, यूनीक और स्टेबल आइडेंटिफ़ायर को दिखाता है. users/app
का इस्तेमाल, कॉल करने वाले Chat ऐप्लिकेशन के लिए किसी दूसरे नाम के तौर पर किया जा सकता है.
type
, उपयोगकर्ता का टाइप है. इस टाइप से Chat को पता चलता है कि उपयोगकर्ता, Chat ऐप्लिकेशन है या कोई व्यक्ति. चैट ऐप्लिकेशन के लिए, वैल्यू BOT
होती है. लोगों के लिए, वैल्यू HUMAN
होती है.
Google Chat API को कॉल करते समय किसी उपयोगकर्ता की जानकारी देना
किसी उपयोगकर्ता की जानकारी देने के लिए, {user}
वैल्यू के लिए इन वैल्यू का इस्तेमाल करें:
Google Workspace के संगठन में शामिल उपयोगकर्ताओं के लिए, इनमें से किसी एक तरीके का इस्तेमाल करें:
- Chat API में,
User
संसाधन का name
, जैसे कि users/123456789
.
- People API में
Person
संसाधन के नाम के लिए {person_id}
, जहां resourceName
people/{person_id}
है. उदाहरण के लिए, Chat API में users/123456789
उसी व्यक्ति को दिखाता है जिसे People API में people/123456789
दिखाया जाता है.
- Directory API में
User
संसाधन के लिए id
—उदाहरण के लिए, Chat API में users/123456789
, Directory API में users/123456789
के तौर पर उसी व्यक्ति को दिखाता है.
Google Workspace के किसी बाहरी संगठन के उपयोगकर्ता या Google खाते का इस्तेमाल करने वाले उपयोगकर्ता के लिए, ईमेल पते के किसी दूसरे नाम का इस्तेमाल करें. उदाहरण के लिए,
users/EMAIL_USERNAME@WORKSPACE_DOMAIN.com
या users/EMAIL_USERNAME@gmail.com
.
इंटरैक्शन इवेंट से उपयोगकर्ता की पहचान करना
जब भी कोई उपयोगकर्ता Chat ऐप्लिकेशन के साथ इंटरैक्ट करता है, तब Chat, इंटरैक्शन और उपयोगकर्ता के बारे में जानकारी के साथ एक इंटरैक्शन इवेंट भेजता है. उदाहरण के लिए, जब कोई उपयोगकर्ता किसी मैसेज में Chat ऐप्लिकेशन का ज़िक्र करता है, तो Chat ऐप्लिकेशन को इंटरैक्शन के बारे में जानकारी मिलती है. इसमें यह जानकारी शामिल होती है कि मैसेज में क्या लिखा है और उसे किसने भेजा है. Chat पर उपलब्ध रिसॉर्स की जानकारी हासिल करते समय, Chat ऐप्लिकेशन उपयोगकर्ताओं का रेफ़रंस देते हैं.
Chat ऐप्लिकेशन से इंटरैक्ट करने वाले उपयोगकर्ता की पहचान करने के लिए,
User
रिसॉर्स पर name
प्रॉपर्टी की वैल्यू पाएं. इसे Event.user.name
से पाया जा सकता है.
यहां दिए गए JSON उदाहरण में, चैट ऐप्लिकेशन के साथ इंटरैक्शन में उपयोगकर्ता की पहचान का अनुमानित फ़ॉर्मैट दिखाया गया है:
{
...,
"user": {
"name": "users/12345678901234567890",
"displayName": "Sasha",
"avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
"email": "sasha@example.com"
}
}
मैसेज एक खास तरह का इंटरैक्शन है. Chat ऐप्लिकेशन पर मैसेज भेजने वाले उपयोगकर्ता की पहचान करने के लिए, User
रिसॉर्स पर name
प्रॉपर्टी की वैल्यू पाएं. इसके लिए, इनमें से किसी एक का इस्तेमाल करें:
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2024-12-21 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2024-12-21 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eGoogle Chat apps can identify users through a unique \u003ccode\u003eUser\u003c/code\u003e resource with a \u003ccode\u003ename\u003c/code\u003e and \u003ccode\u003etype\u003c/code\u003e field to distinguish between bots and humans.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify a user in API calls using their resource name, Person resource ID, Directory API ID, or email alias depending on their location and account type.\u003c/p\u003e\n"],["\u003cp\u003eChat apps receive user information during interactions through the \u003ccode\u003eUser\u003c/code\u003e resource within the event data, allowing identification and actions based on user details.\u003c/p\u003e\n"],["\u003cp\u003eUser identification enables features like mentioning users in messages, adding them to spaces, managing memberships, sending private messages, and subscribing to events.\u003c/p\u003e\n"],["\u003cp\u003eResources such as the \u003ccode\u003eUser\u003c/code\u003e and \u003ccode\u003ePerson\u003c/code\u003e objects, along with API guides, are available for further understanding and implementing user management in Chat apps.\u003c/p\u003e\n"]]],["Google Chat apps specify users to perform actions like @-mentioning, adding users to spaces, finding direct messages, retrieving membership details, sending private messages, and subscribing for membership change events. Users are identified via a `User` resource, with a unique `name` (e.g., `users/123456789`) and `type` (`BOT` or `HUMAN`). External users are specified using email aliases. Interactions with the Chat app include the user's `name` in the `Event.user.name` property.\n"],null,["# Identify and specify Google Chat users\n\nThis page explains the ways Google Chat apps can identify or specify\nChat users.\n\nTo do any of the following, a Chat app\nmust specify a user:\n\n- Create a message that [@ mentions a user](/workspace/chat/format-messages#messages-@mention).\n- Invite or add a user to an [existing space](/workspace/chat/create-members), or add a user to a [new space](/workspace/chat/set-up-spaces).\n- [Find direct messages](/workspace/chat/find-direct-message-in-spaces) between the Chat app and a specified user, or between two users.\n- [Get a user's membership details in a space](/workspace/chat/get-members).\n- [Send a private message](/workspace/chat/private-messages) to a user.\n- [Subscribe to a user](/workspace/chat/events-overview) using the Google Workspace Events API to get events about their membership changes.\n\nHow Chat identifies users\n-------------------------\n\nThe Google Chat API generates a\n[`User` resource](/workspace/chat/api/reference/rest/v1/User)\nfor each person that uses Chat. The following are two important\n`User` fields:\n\n- `name` is the resource name for the resource, formatted as `users/{user}`, where `{user}` represents a unique and stable identifier. `users/app` can be used as an alias for the calling Chat app.\n- `type` is the type of user. This type tells Chat whether the user is a Chat app or a person. For Chat apps, the value is `BOT`. For people, the value is `HUMAN`.\n\nSpecify a user in a call to the Google Chat API\n-----------------------------------------------\n\nTo specify a user, use the following values for the `{user}` value:\n\n- For users in your Google Workspace organization, use one of the\n following approaches:\n\n - The `name` of the [`User` resource](/workspace/chat/api/reference/rest/v1/User) in the Chat API, such as `users/123456789`.\n - The `{person_id}` for the name of a [`Person` resource](/people/api/rest/v1/people) in the People API, where the `resourceName` is `people/{person_id}`---for example, `users/123456789` in the Chat API represents the same person as `people/123456789` in the People API.\n - The `id` for a `User` resource in the Directory API---for example, `users/123456789` in the Chat API represents the same person as `users/123456789` in the Directory API.\n- For a user in an external Google Workspace organization, or a user\n who uses a Google Account, use an email alias---for example,\n `users/`\u003cvar translate=\"no\"\u003eEMAIL_USERNAME\u003c/var\u003e`@`\u003cvar translate=\"no\"\u003eWORKSPACE_DOMAIN\u003c/var\u003e`.com`\n or `users/`\u003cvar translate=\"no\"\u003eEMAIL_USERNAME\u003c/var\u003e`@gmail.com`.\n\nIdentify a user from an interaction event\n-----------------------------------------\n\nEvery time a user interacts with a Chat app,\nChat sends an\n[interaction event](/workspace/chat/receive-respond-interactions) with information about the\ninteraction and the user. For example, when a\nuser mentions a Chat app in a message, the\nChat app receives information about the interaction,\nincluding what the message says, and who sent it. Chat apps\nreference users when retrieving information about Chat resources.\n\nTo identify the user who interacted with a Chat app,\nget the value of the `name` property on the\n[`User` resource](/workspace/chat/api/reference/rest/v1/User),\nwhich you can get from\n[`Event.user.name`](/workspace/chat/api/reference/rest/v1/Event).\n\nThe following JSON example shows the expected format of the user identity in an\ninteraction with a Chat app: \n\n {\n ...,\n \"user\": {\n \"name\": \"users/12345678901234567890\",\n \"displayName\": \"Sasha\",\n \"avatarUrl\": \"https://lh3.googleusercontent.com/.../photo.jpg\",\n \"email\": \"sasha@example.com\"\n }\n }\n\nA message is a specific type of interaction. To identify a user who sent\na message to a Chat app,\nget the value of the `name` property on the\n[`User` resource](/workspace/chat/api/reference/rest/v1/User), using either of the\nfollowing:\n\n- [`spaces.messages.sender.name`](/workspace/chat/api/reference/rest/v1/spaces.messages)\n- [`Event.user.name`](/workspace/chat/api/reference/rest/v1/Event)\n\nRelated topics\n--------------\n\n- [Add a user to a space](/workspace/chat/api/guides/v1/members/create-members).\n- [Manage members in a space](/workspace/chat/list-members).\n- [@ mention a user in a message](/workspace/chat/format-messages#messages-@mention)."]]