Aller au contenu

Matrix Notifications

Ce contenu n’est pas encore disponible dans votre langue.

Overview

By default, Apprise communicates directly with your Matrix server using the official Client API.

Alternatively, you may use the Matrix Webhook service. At the time of writing, this is still considered late beta. Webhook usage is enabled by specifying ?mode=matrix or ?mode=slack, assuming you have configured the webhook service (for example via https://github.com/turt2live/matrix-appservice-webhooks).

Valid syntax is as follows:

  • matrix://{user}:{password}@{hostname}/#{room_alias}
  • matrixs://{user}:{password}@{hostname}/!{room_id}

You may specify multiple rooms:

  • matrixs://{user}:{password}@{matrixhost}/!{room_id}/#{room_alias}/

Note: If no user and/or password is specified, the Matrix registration process may be invoked. Some Matrix servers allow automatic registration of temporary users, depending on server configuration. In most production environments you should always provide both {user} and {password}.

Matrix supports both:

  • Room aliases (prefixed with #)
  • Room IDs (prefixed with !)

Room identifiers may include a homeserver component (for example :example.com). In Matrix, room aliases are typically written with a homeserver, and room IDs are generally expected to include one as well.

Examples:

  • #general
  • #general:example.com
  • !abc123
  • !abc123:example.com

By default, Apprise enforces a homeserver on room identifiers when it is missing.

If you provide:

  • #room: it is internally interpreted as #room:{hostname}
  • !room: it is internally interpreted as !room:{hostname}

If you explicitly include a homeserver component, Apprise honours it exactly as specified.

You may disable homeserver enforcement by specifying ?hsreq=no. In this setting:

  • #room is used exactly as provided.
  • !room is used exactly as provided.

This is intended for environments where a reverse proxy, non-standard server behaviour, or strict URL routing makes :homeserver suffixing undesirable.

If you are using room IDs (prefixed with !), note that many Matrix deployments expect fully-qualified room IDs. If your server rejects !room:{hostname} but accepts !room as-is, hsreq=no may be required.

For example; given:

matrix://user:pass@localhost/#room/!abc123

With default behaviour (hsreq=yes):

  • #room becomes #room:localhost
  • !abc123 becomes !abc123:localhost

With enforcement disabled:

matrix://user:pass@localhost/#room/!abc123?hsreq=no
  • #room is used as #room
  • !abc123 is used as !abc123

When specifying the ?mode= argument, the plugin switches entirely to webhook behaviour and the syntax changes:

  • matrix://{user}:{token}@{hostname}?mode=matrix
  • matrixs://{token}@{hostname}:{port}?mode=matrix
  • matrix://{user}:{token}@{hostname}?mode=slack&format=markdown
  • matrixs://{token}@{hostname}?mode=slack&format=markdown

If you use t2bot.io, you may use:

  • matrix://{t2bot_webhook_token}
  • matrix://{user}@{t2bot_webhook_token}

Or directly:

  • https://webhooks.t2bot.io/api/v1/matrix/hook/{t2bot_webhook_token}
VariableRequiredDescription
hostname*YesThe Matrix server you wish to connect to.
t2bot_webhook_token*YesUsed when leveraging t2bot webhook mode. Acts as hostname in this case.
userNoThe user to authenticate (and/or register) with the Matrix server.
passwordNoThe password to authenticate (and/or register) with the Matrix server.
portNoThe server port Matrix is listening on. By default matrixs:// uses port 443, while matrix:// uses port 80.
room_aliasNoThe room alias to join and notify. It is recommended to prefix with #.
room_idNoThe room ID to join and notify. You must prefix this with !.
thumbnailNoDisplays an image before each notification identifying the notification type. Default is False.
modeNoEnables webhook mode. Valid values are matrix or slack.
msgtypeNoMatrix message type: text or notice. Default is text.
versionNoOverrides the Matrix Client API version. Supported values are 2 and 3. Default is 3. This does not affect room ID formatting.
hsreqNoWhen enabled, enforces Room Version 12 semantics (such as hashed room IDs) as defined in the Matrix v1.17 specification. This patches state-reset vulnerabilities and formalizes room creator power levels. By default, this is set to yes.

Note: If neither a {room_alias} nor a {room_id} is specified, Apprise will query the server for currently joined rooms and notify all of them.

VariableDescription
overflowThis parameter can be set to either split, truncate, or upstream. This determines how Apprise delivers the message you pass it. By default this is set to upstream
👉 upstream: Do nothing at all; pass the message exactly as you received it to the service.
👉 truncate: Ensure that the message will fit within the service’s documented upstream message limit. If more information was passed then the defined limit, the overhead information is truncated.
👉 split: similar to truncate except if the message doesn’t fit within the service’s documented upstream message limit, it is split into smaller chunks and they are all delivered sequentially there-after.
formatThis parameter can be set to either text, html, or markdown. Some services support the ability to post content by several different means. The default of this varies (it can be one of the 3 mentioned at any time depending on which service you choose). You can optionally force this setting to stray from the defaults if you wish. If the service doesn’t support different types of transmission formats, then this field is ignored.
verifyExternal requests made to secure locations (such as through the use of https) will have certificates associated with them. By default, Apprise will verify that these certificates are valid; if they are not then no notification will be sent to the source. In some occasions, a user might not have a certificate authority to verify the key against or they trust the source; in this case you will want to set this flag to no. By default it is set to yes.
ctoThis stands for Socket Connect Timeout. This is the number of seconds Requests will wait for your client to establish a connection to a remote machine (corresponding to the connect()) call on the socket. The default value is 4.0 seconds.
rtoThis stands for Socket Read Timeout. This is the number of seconds the client will wait for the server to send a response. The default value is 4.0 seconds.
emojisEnable Emoji support (such as providing :+1: would translate to 👍). By default this is set to no.
Note: Depending on server side settings, the administrator has the power to disable emoji support at a global level; but default this is not the case.
tzIdentify the IANA Time Zone Database you wish to operate as. By default this is detected based on the configuration the server hosting Apprise is running on. You can set this to things like America/Toronto, or any other properly formated Timezone describing your area.

Send a secure Matrix notification:

Terminal window
# Assuming {hostname} is matrix.example.com
# Assuming {user} is nuxref
# Assuming {password} is abc123
# Notify #general and #apprise
apprise -vv -t "Test Message Title" -b "Test Message Body" \
matrixs://nuxref:abc123@matrix.example.com/#general/#apprise

Disable homeserver enforcement:

Terminal window
apprise -vv -t "Test Message Title" -b "Test Message Body" \
matrixs://nuxref:abc123@matrix.example.com/!abc123?hsreq=no

Use API v2 (required for attachments in some deployments):

Terminal window
apprise -vv -t "Test Message Title" -b "Test Message Body" \
matrixs://nuxref:abc123@matrix.example.com/#general?v=2

Send a t2bot.io webhook request:

Terminal window
# Assuming {webhook} is ABCDEFG12345
apprise -vv -t "Test Message Title" -b "Test Message Body" \
matrix://ABCDEFG12345
Questions or Feedback?

Documentation

Notice a typo or an error? Report it or contribute a fix .

Technical Issues

Having trouble with the code? Open an issue on GitHub:

Made with love from Canada