Class ComposeActionResponseBuilder
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-28 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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."]]