# n8n

> n8n integration example.

Canonical page: https://xmemory.ai/n8n/

## xmemory integration with n8n

Visit [https://xmemory.ai/integration-overview/](https://xmemory.ai/integration-overview/) for **comprehensive guides, API references, and integration examples**.

**API key:** To use xmemory APIs or integrations (including n8n), you need an API key. Get one from the [xmemory console](https://console.xmemory.ai). Copy and securely store the key. Never share your API key publicly.

## Integration with `n8n-nodes-xmemory` custom node

This chapter walks through the full integration flow using the `n8n-nodes-xmemory` custom node:

1. Add **xmemory node**
2. **Create instance from YAML**
3. **Authorize using API key**
4. **Write** memory
5. **Read** memory
6. Run **full execution**

Source code of the node could be found in the [n8n-nodes-xmemory repository](https://github.com/xmemory-ai/n8n-nodes-xmemory/).

### 0) Install xmemory node

- Go to Settings -> Community Nodes in n8n.
- Click "Install a community node".
- Enter `n8n-nodes-xmemory` and install the package.

> Image: Install n8n xmemory community node

### 1) xmemory node

Add the xmemory custom node in your workflow.

> Image: n8n xmemory custom node

### 2) Create instance from yml

Use the node operation that creates a new xmemory instance from a YAML schema.

For a new design, an agent can author [XMD](https://xmemory.ai/xmd/) directly or generate it from a plain-language
memory description to save time. Review and validate either result, then paste it here.

The **Create Instance** operation requires:
- **Cluster ID** — the cluster to create the instance in, either by entering the ID manually or picking a cluster from the list
- **Instance Name** — a name for the new instance
- **Schema Format** and **Schema Text** — the schema content (JSON or YAML)

> Image: Create xmemory instance from yaml in n8n

Here the following xmemory schema was used:

```yaml
xmd_version: v1
title: Website Contact Form
description: Schema for capturing people interested in xmemory who submitted their contact information through the website form.
objects:
  Contact:
    description: Represents a person interested in xmemory who submitted their contact
      information through the website form. Captures personal identification details
      and contact information for follow-up communication.
    fields:
      uuid:
        type: str
        required: true
        description: Unique identifier for the person. Used for internal tracking and
          reference. Must be a non-empty string.
        enum: null
        default: null
      name:
        type: str
        required: false
        description: Name of the person. Required for personalized communication.
        enum: null
        default: null
      email:
        type: str
        required: false
        description: Email address of the person. Primary contact method for follow-up
          communication. Must be a valid email format.
        enum: null
        default: null
      use_case:
        type: str
        required: false
        description: Optional field to capture the specific use case or interest of the person regarding xmemory. This information can help tailor follow-up communication and provide relevant resources.
        enum: null
        default: null
    primary_key:
    - uuid
relations: {}
```

It represents a simple schema for a chatbot collecting contact information from website visitors interested in xmemory.

Normally, you don't need to create instances on-the-fly. You'll need your `cluster_id` to create an instance — find it in the xmemory dashboard. Once created, store the `instance_id` and reuse it in your workflow for all subsequent `write` and `read` operations.

### 3) Authorize using API key

Configure your xmemory API key in node credentials so the workflow can access your instance.

> Image: Authorize n8n xmemory node with API key

### 4) Write

Send content to xmemory with the **write** operation.

> Image: Write data to xmemory from n8n

### 5) Read

Query stored memory with the **read** operation.

> Image: Read data from xmemory in n8n

### 6) Full execution

Execute the workflow end-to-end to validate create, write, and read in one run.

> Image: Full n8n workflow execution with xmemory node

## Integration with xmemory MCP

You can also connect n8n to xmemory via MCP. For full MCP documentation, see [https://xmemory.ai/mcp](https://xmemory.ai/mcp).

### 1) MCP credentials and auth type

Set the MCP server address to `https://mcp.xmemory.ai/` and use **OAuth2** authentication.

> Image: n8n MCP credentials with xmemory server address and OAuth2 auth

### 2) OAuth2 server address

Configure the OAuth2 authentication via `https://oauth2.xmemory.ai/` xmemory server.

> Image: n8n OAuth2 credential showing xmemory server address

### 3) Login and instance selection

Sign in on the xmemory login page (use the API key) and select the instance you want the MCP session to use.

> Image: xmemory MCP login page and instance selection

### 4) Available xmemory MCP tools

After successful auth, n8n lists all available xmemory MCP tools.

> Image: n8n MCP tools list for xmemory
