n8n and Matrix messaging automation

Teams running a self-hosted Matrix homeserver can send alerts, upload media, manage room membership and read room history from n8n using the built-in Matrix node. This page covers the setup, identity and security decisions, and where integrations usually fail.

On this page

How n8n connects to Matrix rooms on your own homeserver

A team that runs a Synapse or other Matrix homeserver instead of Slack usually wants n8n to post alerts and collect approvals inside the rooms people already use. The built-in Matrix node is the starting point. It covers the operations that matter for this work: getting the current account, getting an event by ID, sending messages and media to a room, reading room messages, creating, joining and leaving rooms, inviting or kicking users, and listing room members. Before building on it, check each operation against the n8n version you plan to run, because the node's options and field names can change between releases. The n8n Matrix node documentation lists the operations and their parameters.

The node only talks to the homeserver URL and account you give it, so the traffic path is your own network: n8n, your Matrix homeserver and the clients in your rooms. Nothing in the node requires a hosted n8n service. That matters because n8n is source-available under the Sustainable Use License, not OSI open source. Under that license, internal business use of a self-hosted instance is allowed, but distribution and commercial redistribution are restricted, so the license should be read against how you plan to use the workflows. Confirm with your legal or procurement team whether any planned use, such as offering these workflows to customers, falls outside internal use. Check which n8n features your plan includes as well, since access controls and log streaming depend on the edition you choose.

Decide early which Matrix account n8n will use and what that account is allowed to do. A bot account that can invite and kick users in every room carries much more risk than one limited to posting in a few alert rooms, so scope its room membership and power levels before the first workflow goes live. Confirm the homeserver's federation and registration settings with your Matrix administrator, because they determine whether the bot can reach rooms outside your organization. Keep the homeserver's server_name and the URL n8n uses consistent, or the credential will point at the wrong identity.

What you need before building Matrix workflows

Four pieces must be in place before any Matrix node runs: a known n8n version, a working homeserver, a bot account with a token, and a network path between them. Each card below is a decision or check that, if skipped, usually shows up later as a failed execution or an unexpected permission.

Pin the n8n version and edition

Record the exact n8n version and whether you run Community or a paid self-hosted edition before you build anything. The Matrix node is part of the workflow editor, so the version you test against is the version you must support. Plan upgrades with the release notes in mind, since n8n ships minor releases roughly weekly and uses semantic versioning. Confirm the version in your staging instance matches production before you copy workflows across.

Minor release cadence
Weekly
n8n release notes

Set the homeserver server_name

The server_name setting fixes how user IDs such as @user:example.com and room IDs are identified across your Matrix deployment. Changing it later is disruptive, so decide it before any bot account or room exists. Your n8n Matrix credential must point at the reachable client endpoint, which can differ from the name embedded in IDs when delegation is used. Write both values down and confirm them with the team that owns DNS and certificates.

Synapse federation docs

Create a dedicated bot account

Create a separate homeserver account for n8n rather than reusing a person's login. A dedicated account makes audit logs readable, lets you invite it only to the rooms it needs, and lets you revoke it without affecting staff. Generate its access token under that account and store the token in n8n's credential store, never in workflow notes. Confirm with your Matrix administrator who can create accounts and whether registration is closed on your server.

Confirm the Synapse release line

Check which Synapse release line your team supports against the upgrade notes before you deploy or upgrade the homeserver. Synapse 1.143.0 and later require PostgreSQL 14 or newer, and 1.142.0 and later require Python 3.10 or newer. Synapse also drops support for Python and PostgreSQL versions once they reach upstream end of life, so your database and runtime baseline can change with a release. Record the release you run and the database version it sits on.

Synapse upgrade notes

Plan the network path to the homeserver

Decide how n8n reaches the homeserver: direct on the internal network, through a reverse proxy, or through an egress gateway. n8n calls the client-facing API over HTTPS, so the route, DNS resolution and certificate chain must work from the n8n worker and webhook hosts, not only from your laptop. If you run queue mode, check every worker, not just the main instance. Federation on port 8448 is not needed for bot calls, but any firewall change should be reviewed against the federation settings.

Decide who can reach the bot

Before building, list which rooms the bot must join and which of its actions are allowed, such as posting alerts, reading history or inviting users. The Matrix node can create, join and leave rooms and invite or kick members, so an unrestricted bot can change room membership as well as post. Agree the room list and the actions with the owners of those rooms. Record the decision so the workflow scope matches the access you granted.

Configuring the Matrix credential and first workflows

This sequence takes a bot account on your Synapse homeserver from creation to a working n8n Matrix credential, then proves each operation with a check you can see before building anything larger.

  1. Create a dedicated bot account on the homeserver

    Your Matrix administrator creates a separate user for n8n on your self-hosted homeserver, such as a localpart that makes its purpose obvious to other administrators. Use a dedicated account rather than a person's login so that audit entries and room membership show automation activity clearly. Confirm the account can sign in with a client and that its user ID uses your configured server name, for example @n8n-bot:your-server-name. Check that the account is not granted admin rights unless a specific operation requires them, and record who owns it. The step is done when the account exists and its full user ID is written down for the credential.

  2. Issue an access token for the bot

    Sign in as the bot account and generate an access token for it through your client or the homeserver's login flow, then store the token in your secrets manager. Treat it like a password: a token that leaks gives anyone the bot's room permissions. Note which device or session the token belongs to so you can revoke it later without disturbing other sessions. Ask your administrator to confirm how tokens are issued and revoked under your own authentication setup, since Synapse can be configured with single sign-on that changes the sign-in path. The step is done when you hold a token that is stored outside the workflow canvas.

  3. Add the Matrix credential in n8n

    In n8n, open the credentials area and create a new Matrix credential. Enter your homeserver's base URL, which must be the address clients use, and the access token from the previous step. Save the credential, then confirm that n8n does not display the token again after saving. Credentials are encrypted with the instance encryption key, so if you run queue mode, every worker and webhook processor needs that same key. The step is done when the credential saves without an error and appears in the credential list under a name your team will recognize.

  4. Test the get-current-account operation

    Create a new workflow with a manual trigger and add the Matrix node. Select the credential, choose the operation that gets the current account, and run the node by itself. The output should return the bot's user ID, which must match the account you created in the first step. If the call fails, check the homeserver URL first, then confirm the token is still valid for that account. The step is done when the returned user ID matches the bot, which shows that n8n can reach your homeserver and authenticate.

  5. Send a test message to a joined room

    Have a room administrator create a test room on your homeserver and invite the bot, then have the bot join it. In n8n, use the node's send message operation with the room identifier and a short test text. Run it and read the returned output, which should include an event ID. Open the room in a client and confirm the message appears from the bot account. The step is done when the event ID in the output matches the message visible in the room. If the bot has not joined, the send operation fails, so join first.

  6. Read room history and check the event

    Add a second Matrix node to the workflow that reads messages from the test room, connected after the send step. Run it and confirm the returned messages include the event ID you saw earlier. Then use the get-event operation with that event ID and check that the returned content matches your test text. This verifies that n8n can both write and read events under the bot's permissions. The step is done when the read output contains the same event ID and content as the room timeline.

  7. Add a membership operation and confirm it

    Extend the workflow with a list-members operation on the test room, then run it and compare the returned members with the room's member list in a client. Membership changes such as invite, join, leave or kick affect real people and rooms, so test them only in the dedicated test room with an account you control. The step is done when the member list matches what the client shows and any invite or kick test produces the expected state change. Before moving to production rooms, record which permissions the bot holds there and who approves them.

How Matrix user IDs and room permissions shape the workflow

The n8n bot is a regular Matrix user, identified by a fully qualified ID in the form @user:server_name. The server_name value is fixed when the homeserver is first configured, and it becomes part of every user and room identifier the server issues. Changing it later is effectively a migration, so the team should settle the domain before any bot account or room is created. Synapse's configuration manual and federation guide are the places to confirm how server_name interacts with your DNS and certificates. Delegation is the decision that makes the name usable: a .well-known response can let user IDs such as @bot:example.com be served from a separate host reached on port 443, while federation traffic is served on port 8448 by default. Your network team should confirm which of those ports are open between the homeserver and any other federated server, and whether the federation listener is reachable from the internet at all.

Whatever identity the bot uses, it can only act in rooms it has joined. An n8n Matrix node call that reads history, posts a message or uploads media will fail in any room where the bot account is not a member, so the onboarding step for each alert room is to invite the bot and have it join. Membership alone is not enough for administrative actions. Whether the bot can invite or kick other members depends on the power level that room admins assign to it, and those levels are set per room and per action. A bot that can post alerts but not invite is a common, valid configuration, and it is safer to grant only the actions a workflow needs. Ask the room owners to document the power levels they set and to review them after any change to the workflow, since a single broad grant can let a misconfigured workflow remove people from a room.

Mapping workflow fields to Matrix objects

This table maps each n8n workflow field to the Matrix object it fills, who owns the value, and whether it belongs in fixed configuration. Read it before building a flow so room targets, bot identity and user targets are set once and not retyped on every run.

Workflow fieldMatrix objectValue ownerStore as fixed configuration?
Room ID or aliasTarget room for messages, media and history readsMatrix admin creates the room; bot must be a memberYes for alert rooms, so a typo cannot post to the wrong room
Message bodyEvent content of a text message sent to the roomWorkflow input from the upstream trigger or formNo, built per run from the triggering data
Uploaded mediaContent URI returned after the file is uploaded to the homeserver media storeWorkflow input (file from a prior node)No, the URI is created per upload
User ID (for example @user:example.com)Target of an invite or kick action on a roomWorkflow input from the HR or ticket system, checked against an allowed listOnly the allowed list or policy domain, not individual IDs
Event IDInput to the get-event lookup for an existing messageWorkflow input from an earlier send or a stored referenceNo, but store the mapping if later flows need to find the event
Bot account credentialSender identity for every message, invite and kickMatrix admin provisions the account and tokenYes, held in the n8n credential store and never typed in a node
Homeserver base URL and server nameIdentifies the homeserver and the domain in user and room IDsMatrix admin and platform teamYes, set once in the credential so every flow targets the same server

Securing the bot account and the homeserver path

The n8n bot is a Matrix account with a token that can post, read and change room membership, so its scope is the main control. The homeserver's federation and sign-in settings decide who else can reach that account and the rooms it touches. Check each card against your own homeserver configuration before the workflows go live.

Store the access token in n8n credentials

The Matrix node authenticates with an access token for the bot account, which n8n keeps in its encrypted credential store rather than in workflow JSON. Restrict who can open or export credentials in n8n, because anyone who can read the token can act as the bot. Plan a rotation schedule and a runbook for replacing the token, including which workflows need the new credential and how you confirm the old token no longer works. Confirm with your homeserver administrator how tokens are revoked for the bot account.

Matrix node docs

Limit the bot to the rooms it needs

Create the bot as a dedicated account and invite it only to rooms where it posts alerts or reads history. A bot that joins every room can read content it never needed, and a leaked token then exposes all of it. Use separate rooms for alert feeds and for any room where the workflow reads history, and review membership after each new integration. Ask your Matrix administrator which room settings control who can invite the bot and whether public rooms are allowed.

Restrict who can invite or kick users

The Matrix node can create rooms, invite and kick users and list members, so a workflow with those operations can change who is in a room. Limit membership-changing operations to a small set of reviewed workflows, and keep them out of workflows triggered by external webhooks or chat messages. Require a human approval step for invitations to sensitive rooms where your automation supports it. Log each membership change so the room history can be reconciled with n8n execution history.

Disable federation when it is not needed

Synapse federates on port 8448 by default, so a homeserver used only by internal staff still exposes a federation listener unless you change its configuration. Set federation_domain_whitelist to an empty list to disable federation, or list only partner domains you actually need. The configuration manual also recommends firewalling the federation listener, so confirm at the network layer that unexpected hosts cannot reach it. Test the setting after each upgrade, since a changed default would silently reopen the path.

Synapse configuration manual

Configure sign-in on the homeserver

Synapse supports single sign-on through OpenID Connect providers configured in oidc_providers, SAML2 through saml2_config, and CAS. Set these on the homeserver so that people sign in to Matrix through your identity provider, and keep the bot on a service account with a managed credential. n8n SSO and LDAP require a Business or Enterprise plan, and that is relevant only if you also want n8n users signed in through the same identity provider. Confirm which option your identity provider supports before choosing.

Synapse upgrade notes

How alerts flow from n8n through the homeserver into rooms

The flow starts when a monitoring tool or webhook fires an n8n workflow. The Matrix node then calls the Client-Server API of your own homeserver, which stores the event and delivers it to members of the room. Federation traffic to other servers crosses the trust boundary, so check the federation_domain_whitelist setting and firewall rules before a room is opened to outside members. Confirm which worker processes handle client traffic in your deployment.

Alert path from a monitoring source through n8n and the homeserver to room members.

Why Matrix steps fail and how to fix them

This table lists the failures most often seen when n8n talks to a self-hosted Matrix homeserver, with the cause and fix for each. Read it when a Matrix node step errors or a message appears to send but nobody sees it. Start with the membership and credential rows, since they account for most failed steps.

FailureLikely causeFix
Bot cannot post to the roomThe bot account has not joined the room, or its power level is too low to send messages or invite users in that room.Join the bot with the Join Room operation or invite it first, then check the room's power levels in your Matrix client and raise the bot's level where the workflow needs it.
Requests return unauthorized errorsThe access token has expired, was revoked by a logout or password change, or belongs to another account than the one the workflow expects.Create a fresh token for a dedicated bot account, store it in the n8n credential, and confirm the account with the Get Current Account operation before running the rest of the workflow.
Requests reach the wrong server or fail to connectThe base URL in the credential does not match the homeserver, or the server_name in the homeserver configuration differs from the domain used in user and room IDs.Set the credential's base URL to the address that serves the Client-Server API, and confirm that server_name matches the domain in your user IDs such as @user:example.com. Check the value in the Synapse configuration manual before changing either.
Media uploads are rejectedThe file exceeds the homeserver's maximum upload size, or the content type is not accepted by the media repository or a reverse proxy in front of it.Check the upload limit in your homeserver and reverse proxy settings, raise it only to the size your policy allows, and test with a file of each type the workflow sends.
Remote users never see messagesFederation is misconfigured: port 8448 or delegation is not reachable, the federation whitelist excludes the remote domain, or the federation listener is blocked by a firewall.Confirm delegation and that the federation port answers from outside, review federation_domain_whitelist in the configuration, and test with a remote account. Local room posts succeeding does not prove federation works.
Steps fail after a homeserver upgradeA schema change or dropped runtime version in the new homeserver release breaks an API behavior the workflow depended on, or the credential was not retested after the upgrade.Read the upgrade notes for each release before upgrading, back up the database first, and rerun a test workflow with the Matrix node after the upgrade. Plan for rollback limits, since schema changes can make rolling back difficult.
Membership changes do not take effectThe workflow invites or kicks a user without the power level the room requires, or the target user's homeserver cannot be reached for the invite.Run List Room Members after each membership step to confirm the result, and check the bot's power level and federation status for invites to remote users.
Workflow reads an empty room historyThe bot is not a member of the room, so the read request returns no events or is refused for that room.Join the bot to the room before using Read Room Messages, and confirm the room ID format in the node matches the one your homeserver issues.

Questions teams ask before building Matrix automation

How much does it cost to automate Matrix messaging with n8n?

No price can be stated from the supplied facts, and any figure depends on the written scope. Cost has two parts: the homeserver work (installing, configuring, upgrading and backing up Synapse or another homeserver) and the automation work (designing the n8n workflows that post alerts, upload media and manage membership). Both are one-time build costs and recurring operating costs. Ask any partner to split the quote by these parts, and to state which items recur, such as upgrades, monitoring and retesting. The main cost drivers are the number of rooms, the membership and moderation logic, and how much media flows through the system.

How long does a Matrix automation project usually take?

The supplied facts do not give a duration, so treat any timeline as something to confirm in a written scope. Timing depends mainly on whether a homeserver already exists, how many rooms and integrations are involved, how complex the membership and moderation rules are, and how much testing your environment requires. A team that already runs Synapse in production will usually move faster on the n8n side than a team starting from a new homeserver. Ask for milestones tied to deliverables rather than a single end date.

What does the team need to provide before the work starts?

Plan to provide access to the homeserver and its database, the n8n instance and its credentials, a list of rooms and their purpose, and the membership rules that should apply. You also need named owners who can approve changes to room membership and moderation, plus a staging environment for testing. Confirm how the bot account will be created and which permissions it receives, because the n8n Matrix node can invite and kick users and create rooms. Clarify who signs off on production changes before the first workflow goes live.

Can our own engineers build this without an outside partner?

Yes, if your team already operates an n8n instance and a Matrix homeserver and has the skills to maintain both. The n8n Matrix node covers common operations, including sending messages and media, reading room history, creating and joining rooms, and listing members. The harder work is operational: keeping Synapse upgraded, since rolling back can be difficult because of database schema changes, and keeping its Python and PostgreSQL versions supported. Ask whether your team can own that upgrade cycle before deciding. An outside partner is most useful for the initial design and for the first upgrade.

What makes Matrix automation harder to maintain than a simple alert?

Four factors add ongoing effort. The number of rooms multiplies the membership and permission rules you must track. Membership and moderation logic, such as who can be invited or removed automatically, creates audit and risk questions. Media handling affects storage and the database footprint on the homeserver. Finally, the homeserver itself needs maintenance: Synapse publishes release notes, drops support for Python and PostgreSQL versions once they reach upstream end of life, and requires PostgreSQL 14 or newer from version 1.143.0. Each of these should be scoped and costed separately.

Is Synapse open source, and does its license change how we choose a homeserver?

Synapse is distributed under AGPL-3.0, and Element sells commercial licenses as an alternative. On December 13, 2023, Element announced that future contributions to Synapse would be licensed under AGPLv3 instead of Apache 2.0, moved the repositories to the element-hq organization on GitHub, and began selling AGPL exceptions with contributors signing a CLA. This matters when you compare homeservers, because Matrix.org also lists options under other licenses, such as Conduit and its forks under Apache-2.0. Confirm how AGPL-3.0 applies to your deployment and any modifications with Element or your legal counsel before you commit.

Does n8n's own license affect a Matrix automation build?

Yes. n8n is licensed under the Sustainable Use License, which permits use or modification for your own internal business purposes, but not general commercial redistribution. This is separate from the Synapse license, and the two must be assessed independently. Confirm with n8n or your counsel that your internal use, and any embedding or hosting for others, is permitted. Also check which features your edition includes, since SSO, environments and log streaming are limited to paid plans.

How DeployOpen scopes and delivers a Matrix integration

DeployOpen starts from a written scope that lists the rooms the automation will touch, the workflows that post, upload, invite, kick or read history, the identity model for the n8n service account, and the security requirements the team must meet. Each item needs an owner. Who may create rooms? Which rooms accept bot posts? Should the workflows read history at all, and if so, how far back? Those answers decide the Matrix node operations to enable, the access the n8n credential receives and the tests that follow. Before work starts, confirm whether the Matrix homeserver already runs on infrastructure you control. If it does not, or if its configuration is still open, the homeserver may be a separate scope with its own plan, so the written document should say which one applies.

Within that scope, DeployOpen plans and implements the n8n side on your infrastructure: the Matrix credential with a dedicated account, the workflows for alerts, media uploads and membership changes, error handling for failed sends, and the test cases that prove each operation and each denied action behaves as specified. Credentials stay in your n8n instance, and tests run against a non-production room before anything reaches a live channel. The handover covers workflow exports, a credential and permissions inventory, the runbook for rotating the bot account's access token, and notes on which changes to the homeserver or n8n version could affect the integration. When either side changes later, such as a Synapse upgrade or an n8n minor release, DeployOpen reruns the tests and retests the affected workflows. Ongoing support and continuous testing are available as a retainer.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.