Send messages from Home Assistant to [Matrix](https://matrix.org) rooms — including encrypted rooms (E2EE). Ask questions and react to text replies or emoji reactions in automations. Supports mautrix bridges (WhatsApp, Signal, Telegram) out of the box.
**Enable background sync** — when enabled, the integration polls Matrix every 5 seconds continuously. Required if you want to receive replies to questions without triggering `ask_question` first.
Go to **Settings → Devices & Services → Matrix Messenger → Configure** to change the selected rooms or toggle background sync at any time. Rooms you have since left will no longer appear in the list and are removed from the configuration when you save.
Sends a direct message to a Matrix user. Searches all joined rooms for one that contains the target user; if none is found, a new DM room is created.
Works with **mautrix bridge puppets** (WhatsApp, Signal, Telegram) as long as a portal room for that contact already exists (i.e. you have chatted with the contact before via the bridge).
| Parameter | Type | Required | Description |
|---|---|---|---|
| `user_id` | string | ✓ | Matrix user ID, e.g. `@user:matrix.org` |
| `message` | string | ✓ | Message text |
**Example — native Matrix user:**
```yaml
action:matrix_messenger.send_to_user
data:
user_id:"@marc:matrix.org"
message:"Alarm triggered!"
```
**Example — WhatsApp contact via mautrix-whatsapp:**
```yaml
action:matrix_messenger.send_to_user
data:
user_id:"@whatsapp_4917612345678:your.server"
message:"Doorbell rang."
```
#### Bridge puppet ID format
| Bridge | User ID format |
|---|---|
| WhatsApp | `@whatsapp_<number without +>:<server>` |
| Signal | `@signal_<number without +>:<server>` |
| Telegram | `@telegram_<user id>:<server>` |
Find the exact puppet ID in your Matrix client (e.g. Element) under the contact's profile → Matrix ID.
> **Note:** Messages sent via bridge puppets appear to the recipient as coming from your Matrix account — this is how mautrix bridges work by design.
Sends a question to a room and waits for a reply. Once a matching reply arrives, the event `matrix_messenger_response` is fired. After the timeout (default 30 min) the question expires silently.
The integration stores matrix-nio's E2EE keys (Olm/Megolm sessions) in:
```
<ha-config-dir>/.storage/matrix_messenger/
```
**Back this directory up** together with your HA config. If it is deleted, the integration will re-upload keys and may lose access to past encrypted messages.
---
## Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| `ImportError: libolm` on startup | `libolm` not installed | `apt install libolm-dev` (HA Core only) |
| Rooms list is empty after login | Account not joined to any rooms | Join at least one room in your Matrix client first |