نظرة عامة على رسائل Google Chat
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
توضّح هذه الصفحة الاختلافات بين الرسائل النصية ورسائل البطاقات.
عندما ترسل تطبيقات Chat رسائل نصية لنقل معلومات أساسية، تظهر الرسائل مضمّنة، تمامًا كما يكتب المستخدمون الرسائل في Google Chat. لإنشاء رسائل تحتوي على أكثر من نص، أو لإنشاء رسائل يمكن للمستخدمين التفاعل معها، يمكن لتطبيقات Chat استخدام البطاقات.
يمكن لتطبيقات المحادثة أيضًا إرفاق رسالة نصية ببطاقة. لتشجيع المستخدمين على إكمال العمليات المتعدّدة الخطوات، مثل إكمال نموذج، يمكن لتطبيقات Chat أيضًا إنشاء بطاقات تفتح في نافذة جديدة على شكل مربّعات حوار.
بنية الرسالة النصية
في Google Chat API، يتم تمثيل الرسائل كعناصر JSON. ضمن الرسالة، يتم تمثيل الرسالة النصية كعنصر text
.
في المثال التالي، ينشئ تطبيق Chat رسالة نصية في مساحة مخصّصة لفريق من مطوّري البرامج لإعلامهم باقتراب موعد إيقاف التعديل على الرمز البرمجي:
{
"text": "Attention <users/all>: Code freeze starts at `11:59 am` Pacific Standard Time! If you need a little more time, type `/moreTime` and I'll push the code freeze back one hour."
}
يعرض JSON الرسالة التالية:
بنية رسالة البطاقة
في Google Chat API، يتم تمثيل الرسائل كعناصر JSON. ضمن الرسالة، يتم تمثيل البطاقة كصفيف cardsV2
ويتألف من العناصر التالية:
على سبيل المثال، تتضمّن رسالة البطاقة التالية العناصر
header
و
section
و
widget
:
يمثّل الرمز التالي ملف JSON الخاص برسالة البطاقة:
JSON
{
"cardsV2": [
{
"cardId": "unique-card-id",
"card": {
"header": {
"title": "Sasha",
"subtitle": "Software Engineer",
"imageUrl": "https://developers.google.com/chat/images/quickstart-app-avatar.png",
"imageType": "CIRCLE",
"imageAltText": "Avatar for Sasha"
},
"sections": [
{
"header": "Contact Info",
"collapsible": true,
"uncollapsibleWidgetsCount": 1,
"widgets": [
{
"decoratedText": {
"startIcon": {
"knownIcon": "EMAIL"
},
"text": "sasha@example.com"
}
},
{
"decoratedText": {
"startIcon": {
"knownIcon": "PERSON"
},
"text": "<font color=\"#80e27e\">Online</font>"
}
},
{
"decoratedText": {
"startIcon": {
"knownIcon": "PHONE"
},
"text": "+1 (555) 555-1234"
}
},
{
"buttonList": {
"buttons": [
{
"text": "Share",
"onClick": {
"openLink": {
"url": "https://example.com/share"
}
}
},
{
"text": "Edit",
"onClick": {
"action": {
"function": "goToView",
"parameters": [
{
"key": "viewType",
"value": "EDIT"
}
]
}
}
}
]
}
}
]
}
]
}
}
]
}
استخدِم "أداة إنشاء البطاقات" لتصميم واجهات المستخدم والمراسلة لتطبيقات Chat ومعاينتها:
افتح "أداة إنشاء البطاقات"
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-04 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-04 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eGoogle Chat apps use text messages for basic information and cards for interactive elements or richer content.\u003c/p\u003e\n"],["\u003cp\u003eText messages appear inline within the chat, similar to regular user messages.\u003c/p\u003e\n"],["\u003cp\u003eCards provide a structured format to include images, buttons, and other interactive widgets within a message.\u003c/p\u003e\n"],["\u003cp\u003eCard messages are represented as JSON objects using the \u003ccode\u003ecardsV2\u003c/code\u003e field in the Google Chat API.\u003c/p\u003e\n"],["\u003cp\u003eThe Card Builder tool can be used to design and preview cards for Chat apps.\u003c/p\u003e\n"]]],["Chat apps use text messages for basic information, represented as JSON `text` objects. For richer content and user interaction, they use card messages. Card messages, represented by `cardsV2` JSON arrays, include a `cardId` and a `card` object. The `card` contains a `header`, `section`, and `widget` objects, enabling elements like titles, text, images, and buttons. Cards can also open as dialogs for multi-step processes, or be appended to a text message.\n"],null,["# Google Chat messages overview\n\nThis page explains the differences between text and card messages.\n\nWhen Chat apps send text messages to convey basic information,\nthe messages appear inline, just like how people in Google Chat write\nmessages. To create messages that contain more than text, or to create\nmessages that users can interact with, Chat apps can use\n[cards](/workspace/chat/create-messages#create).\nChat apps can also append a text message with a card. To\nprompt users to finish multi-step processes such as completing a form,\nChat apps can also create cards that open in a new window as\n[dialogs](/workspace/chat/dialogs).\n\nAnatomy of a text message\n-------------------------\n\nIn the Google Chat API, messages are represented as JSON objects. Within a message,\na text message is represented as a\n[`text`](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.FIELDS.text)\nobject.\n\nIn the following\nexample, a Chat app creates a text message in a space\nfor a team of software developers that a code freeze is approaching: \n\n {\n \"text\": \"Attention \u003cusers/all\u003e: Code freeze starts at `11:59 am` Pacific Standard Time! If you need a little more time, type `/moreTime` and I'll push the code freeze back one hour.\"\n }\n\nThe JSON returns the following message:\n\nAnatomy of a card message\n-------------------------\n\nIn the Google Chat API, messages are represented as JSON objects. Within a message\na card is represented as a\n[`cardsV2`](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.FIELDS.cards_v2)\narray and consists of the following:\n\n- One or more [`CardWithId` objects](/workspace/chat/api/reference/rest/v1/spaces.messages#CardWithId).\n- A `cardId`, used to identify the card and scoped within a given message. (Cards in different messages can have the same ID.)\n- A `card` object, which consists of the following:\n\n - A [`header` object](/workspace/chat/api/reference/rest/v1/cards#CardHeader_1) that specifies things like a title, subtitle, and avatar-style image.\n - One or more [`section` objects](/workspace/chat/api/reference/rest/v1/cards#section) that each contain at least one widget.\n - One or more [`widget` objects](/workspace/chat/api/reference/rest/v1/cards#Widget). Each widget is a composite object that can represent text, images, buttons, and other object types.\n\nAs an example, the following card message contains\n[`header`](/workspace/chat/api/reference/rest/v1/cards#CardHeader_1),\n[`section`](/workspace/chat/api/reference/rest/v1/cards#section), and\n[`widget`](/workspace/chat/api/reference/rest/v1/cards#Widget) objects:\n\nThe following code represents the JSON of the card message: \n\n### JSON\n\n {\n \"cardsV2\": [\n {\n \"cardId\": \"unique-card-id\",\n \"card\": {\n \"header\": {\n \"title\": \"Sasha\",\n \"subtitle\": \"Software Engineer\",\n \"imageUrl\": \"https://developers.google.com/chat/images/quickstart-app-avatar.png\",\n \"imageType\": \"CIRCLE\",\n \"imageAltText\": \"Avatar for Sasha\"\n },\n \"sections\": [\n {\n \"header\": \"Contact Info\",\n \"collapsible\": true,\n \"uncollapsibleWidgetsCount\": 1,\n \"widgets\": [\n {\n \"decoratedText\": {\n \"startIcon\": {\n \"knownIcon\": \"EMAIL\"\n },\n \"text\": \"sasha@example.com\"\n }\n },\n {\n \"decoratedText\": {\n \"startIcon\": {\n \"knownIcon\": \"PERSON\"\n },\n \"text\": \"\u003cfont color=\\\"#80e27e\\\"\u003eOnline\u003c/font\u003e\"\n }\n },\n {\n \"decoratedText\": {\n \"startIcon\": {\n \"knownIcon\": \"PHONE\"\n },\n \"text\": \"+1 (555) 555-1234\"\n }\n },\n {\n \"buttonList\": {\n \"buttons\": [\n {\n \"text\": \"Share\",\n \"onClick\": {\n \"openLink\": {\n \"url\": \"https://example.com/share\"\n }\n }\n },\n {\n \"text\": \"Edit\",\n \"onClick\": {\n \"action\": {\n \"function\": \"goToView\",\n \"parameters\": [\n {\n \"key\": \"viewType\",\n \"value\": \"EDIT\"\n }\n ]\n }\n }\n }\n ]\n }\n }\n ]\n }\n ]\n }\n }\n ]\n }\n\n\n*** ** * ** ***\n\nUse the Card Builder to design and preview messaging and user interfaces for Chat apps:\n[Open the Card Builder](https://addons.gsuite.google.com/uikit/builder)\n\n*** ** * ** ***\n\n\u003cbr /\u003e\n\nRelated topics\n--------------\n\n- [Send a message](/workspace/chat/create-messages)\n- [Format messages](/workspace/chat/format-messages)"]]