# Gmail

The **Gmail Node** in StackAI enables you to automate sending and managing emails directly through your Gmail account. This integration streamlines communication tasks, allowing you to trigger email actions within your automated workflows.

***

**How to use it?**

To use the Gmail node, connect your Gmail account using a valid connection ID. Choose the desired action (such as sending an email), provide the required input fields, and configure any optional settings. The node will execute the action and return the relevant output, which can be used in downstream workflow steps.

***

**Example of Usage**

Suppose you want to automatically send a notification email when a new lead is added to your CRM. You can set up a workflow where the Gmail node is triggered with the lead’s details, and an email is sent to your sales team.

***

**Available Actions**

Below are the most commonly used actions for the Gmail node in StackAI:

***

#### 1. Send Email

**Description:**\
Send an email from your connected Gmail account to one or more recipients.

**Inputs:**

* **to** (Required):\
  The recipient’s email address or a list of addresses.\
  \&#xNAN;*Example:* `"to": "recipient@example.com"` or `"to": ["user1@example.com", "user2@example.com"]`
* **email subject** (Required):\
  The subject line of the email.\
  \&#xNAN;*Example:* `"subject": "Welcome to Our Service"`
* **email content** (Required):\
  The main content of the email.\
  \&#xNAN;*Example:* `"content": "Thank you for signing up!"`
* **cc** (Optional):\
  Email addresses to be copied on the email.\
  \&#xNAN;*Example:* `"cc": "manager@example.com"`
* **bcc** (Optional):\
  Email addresses to be blind-copied on the email.\
  \&#xNAN;*Example:* `"bcc": "admin@example.com"`
* **attachments** (Optional):\
  List of file paths or file objects to attach.\
  \&#xNAN;*Example:* `"attachments": ["/path/to/file.pdf"]`&#x20;
* **message format** (Default: Plain text)\
  Format for email content. "Plain text" passes the email content as text. "Rich text (HTML)" pass the email content as HTML. Use "Rich text (HTML)" for formatting email content (e.g., font size, color, background color, etc.)

**Configurations:**

* **connection\_id** (Required):\
  The ID of your Gmail connection.\
  \&#xNAN;*Example:* `"connection_id": "5a56b86a-c7d3-4e6a-af3f-0969d00ff9f8"`

**Outputs:**

* **message\_id** (Always returned):\
  The unique ID of the sent email.\
  \&#xNAN;*Example:* `"message_id": "17c8b2e5e8b2c1a2"`
* **status** (Always returned):\
  The status of the email send operation.\
  \&#xNAN;*Example:* `"status": "sent"`

***

#### 2. Search Emails

**Description:**\
Search for emails in your Gmail account using specific criteria.

**Inputs:**

* **query** (Required):\
  The search query string (Gmail search syntax).\
  \&#xNAN;*Example:* `"query": "from:boss@example.com is:unread"`
* **max\_results** (Optional):\
  Maximum number of emails to return.\
  \&#xNAN;*Example:* `"max_results": 10`

**Configurations:**

* **connection\_id** (Required):\
  The ID of your Gmail connection.

**Outputs:**

* **emails** (Always returned):\
  A list of email objects matching the search criteria.\
  \&#xNAN;*Example:*

  ```json
  "emails": [
    {
      "subject": "Meeting Reminder",
      "from": "boss@example.com",
      "date": "2025-07-07T10:00:00Z",
      "snippet": "Don't forget our meeting at 2pm."
    }
  ]
  ```

***

#### 3. (Optional) Additional Actions

Other actions may be available, such as managing labels or retrieving email details. For most workflow automations, "Send Email" and "Search Emails" are the primary actions used.

***

**Best Practices**

* Always use a valid Gmail connection ID from your available connections.
* Ensure all required fields are provided for each action.
* Use dynamic references (e.g., from previous nodes) to personalize email content or search queries.
* Attachments should be properly formatted and accessible by the workflow.

***

**Summary Table**

| Action        | Required Inputs   | Optional Inputs      | Required Configurations | Outputs             |
| ------------- | ----------------- | -------------------- | ----------------------- | ------------------- |
| Send Email    | to, subject, body | cc, bcc, attachments | connection\_id          | message\_id, status |
| Search Emails | query             | max\_results         | connection\_id          | emails              |

***

Use the Gmail node in StackAI to automate your email workflows, streamline communication, and enhance productivity with seamless Gmail integration.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stackai.com/workflow-builder/apps/gmail.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
