Class ComposeActionResponseBuilder
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-28 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-28 (שעון UTC)."],[[["\u003cp\u003eComposeActionResponseBuilder helps create responses for actions that generate draft emails when a UI element is interacted with.\u003c/p\u003e\n"],["\u003cp\u003eIt's important to understand that this is distinct from compose actions used to extend the Gmail compose UI.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use this builder to set a Gmail draft created using methods like GmailMessage.createDraftReply().\u003c/p\u003e\n"],["\u003cp\u003eThe build() method finalizes the response and ensures it's valid before use.\u003c/p\u003e\n"]]],["The `ComposeActionResponseBuilder` creates responses to actions that compose draft messages. It has two key methods: `build()` and `setGmailDraft(draft)`. `build()` constructs and validates the `ComposeActionResponse`. If it is invalid an error is thrown. `setGmailDraft(draft)` sets the `GmailDraft` using functions such as `GmailMessage.createDraftReply(body)`, allowing for modification of the draft before composing. The builder itself is not directly related to compose actions but creates responses when UI elements are selected.\n"],null,["# Class ComposeActionResponseBuilder\n\nComposeActionResponseBuilder\n\nA builder for [ComposeActionResponse](/apps-script/reference/card-service/compose-action-response) objects.\n\n\n| **Note** : This object isn't related to **compose actions** that are used to [extend the compose UI](/gmail/add-ons/how-tos/extending-compose-ui). Rather, this builder creates responses to an [Action](/apps-script/reference/card-service/action) that composes draft messages when a specific UI element is selected.\n\n\u003cbr /\u003e\n\n### Methods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [build()](#build()) | [ComposeActionResponse](/apps-script/reference/card-service/compose-action-response) | Builds the current compose action response and validates it. |\n| [setGmailDraft(draft)](#setGmailDraft(GmailDraft)) | [ComposeActionResponseBuilder](#) | Sets the draft [GmailMessage](../gmail/gmail-message.html) created using [GmailMessage.createDraftReply(body)](../gmail/gmail-message.html#createDraftReply(String)) or similar functions. |\n\nDetailed documentation\n----------------------\n\n### `build()`\n\nBuilds the current compose action response and validates it.\n\n#### Return\n\n\n[ComposeActionResponse](/apps-script/reference/card-service/compose-action-response) --- A validated [ComposeActionResponse](/apps-script/reference/card-service/compose-action-response).\n\n#### Throws\n\n\n[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the constructed compose action response isn't valid.\n\n*** ** * ** ***\n\n### `set``Gmail``Draft(draft)`\n\nSets the draft [GmailMessage](../gmail/gmail-message.html) created\nusing [GmailMessage.createDraftReply(body)](../gmail/gmail-message.html#createDraftReply(String)) or\nsimilar functions.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|-----------------------------------------|-----------------------------------------------------|\n| `draft` | [GmailDraft](../gmail/gmail-draft.html) | The [GmailDraft](../gmail/gmail-draft.html) to use. |\n\n#### Return\n\n\n[ComposeActionResponseBuilder](#) --- This object, for chaining."]]