Skip to content

XMPP Notifications

Overview

XMPP support requires slixmpp version 1.10.0 or newer:

Terminal window
pip install "slixmpp>=1.10.0"

From here, you will need:

  1. An existing XMPP account username (on a self-hosted or remotely hosted XMPP server).
  2. The password associated with that account.
  3. The hostname of your XMPP server.
  4. (Optional) The port the XMPP server listens on.

In Apprise, the login JID is automatically constructed as {user}@{host}. You do not need to explicitly provide a full JID. Authentication credentials are supplied using {user}:{password}@{host}, but the resulting login identity is always normalized to {user}@{host}.

Valid syntax is as follows:

  • xmpp://{user}:{password}@{host}
  • xmpps://{user}:{password}@{host}
  • xmpp://{user}:{password}@{host}:{port}
  • xmpp://{user}:{password}@{host}/{jid}
  • xmpp://{user}:{password}@{host}/{jid1}/{jid2}
  • xmpps://{user}:{password}@{host}/{jid}?verify=no

Secure connections should be referenced using xmpps://, whereas insecure connections should be referenced using xmpp://.

If no target is specified, Apprise sends the notification to the authenticated account itself ({user}@{host}).

Targets may also be supplied using the to= query argument (comma-separated).

To send to an XMPP Multi-User Chat room (XEP-0045), prefix the room JID with #:

  • xmpps://{user}:{password}@{host}/#room@{conference_host}
  • xmpps://{user}:{password}@{host}/#room1@{ch}/#room2@{ch}

You can mix room and user targets freely in the same URL:

  • xmpps://{user}:{password}@{host}/#room@{ch}/{jid}
VariableRequiredDescription
userYesXMPP username (localpart), combined with host to form the login JID
passwordYesPassword for the XMPP account
hostYesXMPP server hostname (domain)
portNoServer port (defaults: 5222 for xmpp, 5223 for xmpps)
modeNoTransport secure mode override; possible values are none, starttls, or tls
rosterNoRetrieves roster from the server after connection; default is no
keepaliveNoEnables XMPP keepalive mode to maintain a persistent connection between notifications. This is only effective when Apprise remains resident in memory (for example, in long-running applications). It has no practical effect when using the Apprise CLI or API in one-shot mode, as the instance is created, sends the notification, and is then destroyed. Even with ?keepalive=yes, the connection closes once the Apprise instance goes out of scope. Default is no.
subjectNoMessages are sent as mtype=chat, which do not typically use the built-in XMPP subject= field. Setting this to yes redirects any title provided into the subject= field instead of concatenating it to the body (default behavior which is subject=no).
nameNoNickname used when joining MUC rooms (alphanumeric and underscores only). The JID username is detected and used by default unless explicitly overridden here. If neither is available, the system default is used.
toNoAlternate way to specify target JIDs or MUC rooms (comma-separated); prefix rooms with #
targetNoRecipient JID (plain user) or MUC room JID when prefixed with #
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.

The mode parameter explicitly controls how the XMPP connection is established and overrides the schema (xmpp:// or xmpps://) default.

ModeDescription
nonePlaintext connection (no TLS)
starttlsSTARTTLS upgrade on a plaintext connection
tlsDirect TLS connection

:::

  • xmpp:// defaults to mode=none
  • xmpps:// defaults to mode=starttls

Keepalive mode is intended for long-running applications that reuse a single Apprise instance.

When enabled:

  • The XMPP connection remains open between notifications.
  • Multiple messages reuse the same session.
  • Connection overhead is reduced.

When using the CLI or a one-shot execution model, keepalive provides no benefit because the process exits immediately after sending.

Example of enabling keepalive:

Terminal window
apprise -vv -b "Persistent Message" \
xmpps://user:password@chat.example.com?keepalive=yes

In embedded usage:

from apprise import Apprise
a = Apprise()
a.add("xmpps://user:password@chat.example.com?keepalive=yes")
a.notify(body="First message")
a.notify(body="Second message")

In this scenario, the connection is reused between notifications.

Apprise normalizes JIDs to ensure consistent and predictable behaviour, even when shorthand forms are used.

Consider the following Apprise XMPP URL:

xmpp://user:pass@example.ca
^
|
default_host
URLTargets Notified
xmpps://user:pass@example.causer@example.ca (self)
xmpps://user:pass@example.ca/janejane@example.ca
xmpps://user:pass@example.ca/jane/joejane@example.ca, joe@example.ca
xmpps://user:pass@example.ca/jane@foobar.cajane@foobar.ca
xmpps://user:pass@example.ca/jason%2Fmobilejason@example.ca/mobile
xmpps://user:pass@example.ca/jane@foobar.ca%2Fworkstationjane@foobar.ca/workstation
xmpps://user:pass@example.ca/#general@conference.example.caMUC room general@conference.example.ca
xmpps://user:pass@example.ca/#general@conference.example.ca/janeMUC room general@... and user jane@example.ca
xmpps://user:pass@example.ca/#room1@conference.ca/#room2@conference.caMUC rooms room1@... and room2@...

Send a plaintext XMPP notification:

Terminal window
apprise -vv -b "Test Message" \
xmpp://user:password@localhost

Send a STARTTLS-secured notification:

Terminal window
apprise -vv -b "Secure Message" \
xmpp://user:password@localhost?mode=starttls

Send a direct TLS notification:

Terminal window
apprise -vv -b "TLS Message" \
xmpps://user:password@chat.example.com

Send a message to a specific recipient:

Terminal window
apprise -vv -t "Test Title" -b "Hello from Apprise" \
xmpps://user:password@chat.example.com/alice@example.net

Send a message to multiple recipients using the to= argument:

Terminal window
apprise -vv -b "Group Message" \
xmpps://user:password@chat.example.com?to=alice@example.net,bob@example.org

Disable TLS certificate verification:

Terminal window
apprise -vv -b "Test Message" \
xmpps://user:password@chat.example.com/alice@example.net?verify=no

Send a notification to a resource:

Terminal window
apprise -vv -b "Test Message" \
xmpps://user:password@chat.example.com/?to=alice@example.net/mobile

Send a message to a MUC room:

Terminal window
apprise -vv -b "Hello, room!" \
"xmpps://user:password@chat.example.com/#general@conference.example.com"

Send a message to multiple MUC rooms and a direct user:

Terminal window
apprise -vv -b "Broadcast" \
"xmpps://user:password@chat.example.com/#ops@conference.example.com/#dev@conference.example.com/alice@example.com"

Send to a MUC room using the to= argument:

Terminal window
apprise -vv -b "Room message" \
"xmpps://user:password@chat.example.com?to=#general@conference.example.com"
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