# Connect EMQX Agents to Google Docs

The Google Docs connector lets EMQX Agents create, copy, search, read, export, and edit Google documents. Use it to generate reports, update operational documents, and turn agent results into shareable documents.

## Common Use Cases

- Create a report from EMQX Tables query results.
- Update a runbook with the latest incident findings.
- Search documents and use their content as context.
- Export a generated document as a PDF.

Example chat prompt:

```text
Use the operations-docs connector to create a Google document named Daily Device Health Report and write a Markdown summary of the devices that require attention.
```

## Prerequisites

Before adding the connector, prepare:

- A Google account with access to Google Docs.
- Permission to authorize Composio to view, create, edit, and delete Google Docs documents and Google Drive files.
- Access to the documents and Drive locations required by the workflow.

## Add a Google Docs Connector

1. In the left navigation menu, click **Connectors**.
2. On the **Available** tab, locate **Google Docs** and click **Add**.
3. Enter a descriptive connector name.
4. Click **Confirm**. The Google authorization flow opens in a dialog.
5. Select the Google account to connect, or click **Use another account**.
6. If Google asks you to sign in to Composio again, review the information and click **Continue**.
7. Review the access requested by Composio. The authorization includes permission to:
   - View, create, edit, and delete Google Drive files.
   - Create Google Docs documents, and view, edit, and delete Google Docs documents.
   - View your primary Google Account email address and associate you with your personal information on Google.
8. Click **Continue** to grant access.
9. Wait for the authorization dialog to close and return to EMQX Agents.
10. On the **Added** tab, verify that the connector status is **Authorized**.

Google may show permissions that were granted previously. Review the requested access before continuing. For a managed Google Workspace account, organization policies may prevent you from authorizing third-party applications.

## Supported Tools

### Create Documents

| Tool | Access | Description |
|---|---|---|
| `GOOGLEDOCS_COPY_DOCUMENT` | Write | Copies a Google document. |
| `GOOGLEDOCS_CREATE_DOCUMENT` | Write | Creates a Google document and can add initial text. |
| `GOOGLEDOCS_CREATE_DOCUMENT_MARKDOWN` | Write | Creates a Google document from Markdown content. |

### Read and Export Documents

| Tool | Access | Description |
|---|---|---|
| `GOOGLEDOCS_EXPORT_DOCUMENT_AS_PDF` | Read | Exports a Google document as a PDF. |
| `GOOGLEDOCS_GET_DOCUMENT_BY_ID` | Read | Gets a Google document and its structure by document ID. |
| `GOOGLEDOCS_GET_DOCUMENT_PLAINTEXT` | Read | Gets the plain-text content of a Google document. |
| `GOOGLEDOCS_SEARCH_DOCUMENTS` | Read | Searches Google documents by name, content, modification time, or other criteria. |

### Edit Documents

| Tool | Access | Description |
|---|---|---|
| `GOOGLEDOCS_INSERT_INLINE_IMAGE` | Write | Inserts an inline image at a document location. |
| `GOOGLEDOCS_INSERT_PAGE_BREAK` | Write | Inserts a page break. |
| `GOOGLEDOCS_INSERT_TABLE_ACTION` | Write | Inserts a table with the specified number of rows and columns. |
| `GOOGLEDOCS_INSERT_TEXT_ACTION` | Write | Inserts or appends text at a document location. |
| `GOOGLEDOCS_REPLACE_ALL_TEXT` | Write | Replaces all matching text in a document. |
| `GOOGLEDOCS_REPLACE_IMAGE` | Write | Replaces an image in a document. |
| `GOOGLEDOCS_UPDATE_DOCUMENT_MARKDOWN` | Write | Replaces and updates a document by using Markdown content. |
| `GOOGLEDOCS_UPDATE_EXISTING_DOCUMENT` | Write | Updates a document through insert, delete, or formatting operations. |

::: warning Important Notice
Update and replacement tools can overwrite document content. Confirm the target document before using full-document Markdown updates or replace-all operations.
:::

## Use the Connector in a Chat

1. In the chat input area, click the connector icon.
2. Select the authorized **Google Docs** connector.
3. In the prompt, identify the external resource and operation that the agent should use.
4. Review the generated agent definition and confirm that it contains only the required tools.

## Permissions and Data Access

The connector uses the authorized Google account and can access documents available to that account, subject to Google Workspace policies and document sharing permissions.

Do not include external service credentials or access tokens in the chat prompt or agent instructions.

## Limitations

- Google Docs and Drive API quotas apply.
- Image insertion and document export can depend on file size and external resource accessibility.
- Some formatting or embedded content might not be preserved by plain-text or Markdown operations.

<!-- TODO: Confirm service-specific result size limits, file limits, API rate limits, plan restrictions, and unsupported resource types. -->
<!-- TODO: Confirm the default Google Drive location for documents created through the connector. -->

## Troubleshooting

| Symptom | Resolution |
|---|---|
| The connector remains **Unauthorized**. | Retry authorization, select the intended Google account, and click **Continue** to grant the requested access. For a managed Google Workspace account, verify that your administrator allows Composio. |
| A tool returns a permission error. | Verify that the authorized account can access the target document or Drive location and that the required Google permissions are still granted. Reauthorize the connector if necessary. |
| A required tool is unavailable. | Verify that the tool is supported and approved for this connector, then select the connector again in the chat. |
| Requests are rejected intermittently. | Check the external service status, API quota, rate limits, and account plan. |

## Related Links

- [Connectors](../connectors.md)
- [Start a Chat](../chats.md)
- [Manage Agents](../agents.md)
