Talk to any messaging app with Appraise

The dream of many developers is to be able to communicate with the various instant messaging platforms using a single integrated solution. Appraise is a promising open source library that allows you to send notifications to a wide range of online services, such as WhatsApp, Telegram, Discord, Slack, Amazon SNS, Gotify and many others. The library provides a common and intuitive syntax for managing notifications, supports sending images and attachments (for services that accept them) and is extremely lightweight, ensuring fast response times thanks toasynchronous sending of messages.

The advantages of talking with any messaging app

The main benefit deriving from the use of Appraise (this is the official page) consists, evidently, in the possibility of accessing almost all notification services available without having to develop “ad hoc” code and adapt your applications to each of them.

The open source bookstoreeasily installable for example with the Python command pip install apprise, offers a common and intuitive syntax for specifying message recipients, making it easier for developers to manage different services. It is also lightweight, guarantees top-level performance and fast response times thanks to the asynchronous sending of requests.

Developers who want to implement notification systems no longer have to navigate the jungle of API e di interfaces made available by each service. Simply include the Apprise library in your project to have immediate access to almost all notification services currently available.

For system administrators and DevOps team members, there is no longer any need to search for the right tool: everything you need is already included and supported in the tool and command line (CLI, Command Line Interface) of Apprise.

Installation modes supported by Apprise and Service ID

L’Apprise installation can be done via the pip utility, RPM, or other package managers for major GNU/Linux distributions. As mentioned previously, there is also a convenient and effective command line interface (CLI) called that allows you to easily send notifications by specifying the Service URLs desired.

Using a special one configuration fileApprise allows users to specify their preferences and credentials securely, without having to enter them directly on the command line.

I Service ID reported in this table are URIs (Uniform Resource Identifier) which allow you to interact with each service: tgram://for example, allows you to “talk” to Telegram, whatsapp:// with WhatsApp, twitter:// con X, slack:// with the productivity and collaboration suite of the same name, o365:// with services integrated into the Microsoft 365 platform, msteams:// con Teams, mqtt:// e mqtts:// with MQTT compatible IoT devices, ifttt:// with IFTTT and so on.

Apprise supports several notification categories, including productivity-based notifications, SMS notifications, desktop notifications, email notifications, and custom notifications. For example, you can prepare desktop notifications on Windows, Linux and macOS systems, send emails, structured notifications such as forms, XML or JSON objects.

Some examples of using Apprise

Assuming you use the command line interface, you can for example send messages to multiple services using the following syntax:

apprise -t "Titolo messaggio notifica" -b "Testo del messaggio" \
'telegram://TOKEN/chat_id' \
'slack://webhook_id/webhook_token' \
'pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b'

Using a statement similar to the following, you can send messages with attachments:

apprise -t "Notifica con allegati" -b "Il messaggio ha un allegato" \
--attach /percorso/del/file/allegato.txt \
'mailto://[email protected]'

Furthermore, you can prepare a configuration file (apprise.yml):

urls:
- 'mailto://[email protected]'
- 'slack://webhook_id/webhook_token'
- 'telegram://TOKEN/chat_id'

Then recall it as follows:

apprise -t "notifica di prova" -b "testo del messaggio di notifica" --config=apprise.yml

Customize notification structure with Python

Il Python code allows you to create a custom notification function using the Apprise library. The structure of custom notification it is therefore used to send a message:

# Creare una funzione di notifica personalizzata
from apprise.decorators import notify

@notify(on="mionuovoschema", name="Mio Schema Personalizzato")
def mio_schema_notifica(body, title, notify_type, *args, **kwargs):
# Personalizza la tua logica qui
print(f"{notify_type.upper()}: {title} - {body}")

# Ora utilizza la notifica personalizzata
apprise -t "Notifica personalizzata" -b "Questo messaggio segue il mio schema personalizzato" 'mionuovoschema://'

In the example mionuovoschema:// obviously it does not correspond to a specific service. To actually send the notification to a particular service, a custom scheme must be defined that matches the specifications of the destination service and provide the correct configuration details.

Opening image credit: iStock.com – oatawa

LEAVE A REPLY

Please enter your comment!
Please enter your name here