Skip to content

Messaging

Messages_

Learn about Appwrite messages, the different types of messages, what can be sent in different message types.

7 min read

Raw

Each time you send or schedule a push notification, email, or SMS text, it's recorded in Appwrite as a message is displayed in the Messages tab.

Add a target
Add a target

Messages

Each message displays with the following information.

Column Description
Message IDThe unique ID of the message.
DescriptionThe developer defined description of the message. End users do not see this description.
MessageThe message delivered to end users.
TypeType of message, either Push, Email, and SMS.
StatusIndicates the status of the message, can be one of draft, scheduled, processing, failed, success.
Scheduled atIndicates the scheduled delivery time of the message.
Delivered atIndicates the time at which the message was successfully delivered.

Messages types

There are three types of messages

Message type Description
Push notificationsPush notifications are alerts that show up on a user device's notification center. This can be used to deliver messages to the user whether their application is open or not.
EmailsEmails let you deliver rich content to a users' inbox. Appwrite allows you to send customized HTML email messages so you can include links, styling, and more.
SMSSMS messages let you deliver text messages to your user's phone. This helps you reach your user, even when their device do not have internet access.

Messages lifecycle

Messages can begin as a draft, or proceed directly to processing if it's sent immediately. If the message is scheduled to be sent later, its status is set to scheduled, then to processing at schedule time. After attempted delivery, it is marked as sent or failed depending on if the message was successfully delivered.

Message lifecycle
Message lifecycle

Choosing a message type

Choosing the right type of notification to reach your audience is important for your app's success. Here are some common factors to consider when deciding what type of message should be sent.

Message type Description
Time-sensitive messagesPush notifications or SMS messages are ideal for time-sensitive messages, as they are typically checked frequently and opened within minutes, ensuring prompt attention.
Guaranteed deliveryEmails and SMS messages are more reliable for guaranteed delivery of important messages like invoices and order confirmations, as push notifications can be easily missed.
Content-rich messagesEmails are best suited for delivering content-rich messages like promotional letters, detailed updates, and newsletters, thanks to support for HTML, allowing for rich text, links, and styling.
Increasing engagementPush notifications are effective for increasing engagement with users, as they can be clicked on to link directly to your app, promoting immediate interaction.
Accessibility and reachEmails and SMS messages allow you to reach users even before they have installed your app, making them suitable for announcement-type messages that require broad accessibility.

Composing messages

Different types of messages have different content and configurable options. Here are the different components that make up a message.

Parameter Required Description
messageIdrequiredThe title of the push notification. This is the headline text that recipients see first.
titleoptionalThe title of the push notification. This is the headline text that recipients see first. Can be omitted for background notifications.
bodyoptionalThe main content or body of the push notification. Provides the details or message you want to convey. Can be omitted for background notifications.
dataoptionalExtra key-value pairs that apps can use to handle the notification more effectively, such as directing users to a specific part of the app.
actionoptionalSpecifies which activity or view controller to open within the app when the notification is tapped.
iconoptionalSets the icon of the notification, used only for Android devices. This can help in branding the notification.
soundoptionalSets the sound to use for the notification. For Android, the sound file must be located in /res/raw; for Apple devices, it must be in the app's main bundle or the Library/Sounds folder of the app container.
coloroptionalSpecifies a color tint for the notification icon, used only for Android devices. This can be used to align with brand colors.
tagoptionalCan be used to replace an existing notification with the same tag, used only for Android devices. Useful for updating or canceling notifications.
badgeoptionalSets the number to display next to the app's icon, indicating the number of notifications or updates. Setting to 0 removes any existing badge. Must be an integer. For Apple devices only.
contentAvailableoptionalFor iOS devices only. When set, wakes up the app in the background without showing a notification. Used to update app data remotely. Requires priority to be set to normal. Note: APNS may throttle if sending more than 2-3 background notifications per hour. For Android, similar functionality can be achieved by sending a data-only notification without title and body.
criticaloptionalFor iOS devices only. Marks the notification as critical to bypass silent and do not disturb settings. Requires the app to have the critical notification entitlement from Apple.
priorityoptionalSets notification priority to normal or high. Normal priority delivers at the most convenient time based on battery life and may group notifications. High priority delivers immediately.
draftoptionalIf the message is a draft, can be true or false.
scheduledAtoptionalAn ISO date time string specifying when the push notification should be sent.

Sending a message

You can create a message with a Server SDK. You can send a push notification like this.

const sdk = require('node-appwrite');
// Init SDK
const client = new sdk.Client();
const messaging = new sdk.Messaging(client);
client
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<PROJECT_ID>') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
const message = await messaging.createPush({
messageId: '<MESSAGE_ID>',
title: '<TITLE>',
body: '<BODY>',
topics: [],
users: [],
targets: [],
data: {},
action: '<ACTION>',
icon: '<ICON>',
sound: '<SOUND>',
color: '<COLOR>',
tag: '<TAG>',
badge: 1,
contentAvailable: false,
critical: false,
priority: 'normal',
draft: true,
scheduledAt: ''
});

You can send an email like this.

const sdk = require('node-appwrite');
// Init SDK
const client = new sdk.Client();
const messaging = new sdk.Messaging(client);
client
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<PROJECT_ID>') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
const message = await messaging.createEmail({
messageId: '<MESSAGE_ID>',
subject: '<SUBJECT>',
content: '<CONTENT>',
topics: [],
users: [],
targets: [],
cc: [],
bcc: [],
draft: true,
html: false,
scheduledAt: ''
});

You can send an SMS message like this.

const sdk = require('node-appwrite');
// Init SDK
const client = new sdk.Client();
const messaging = new sdk.Messaging(client);
client
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<PROJECT_ID>') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
const message = await messaging.createSms({
messageId: '<MESSAGE_ID>',
content: '<CONTENT>',
topics: [],
users: [],
targets: [],
draft: true,
scheduledAt: ''
});

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.