Messages

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.

ColumnDescription
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 typeDescription
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 typeDescription
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.

    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://cloud.appwrite.io/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2')                 // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    const message = await messaging.createPush(
            '[MESSAGE_ID]',                          // messageId
            '[TITLE]',                               // title
            '[BODY]',                                // body
            [],                                      // topics (optional)
            [],                                      // users (optional)
            [],                                      // targets (optional)
            {},                                      // data (optional)
            '[ACTION]',                              // action (optional)
            '[ICON]',                                // icon (optional)
            '[SOUND]',                               // sound (optional)
            '[COLOR]',                               // color (optional)
            '[TAG]',                                 // tag (optional)
            '[BADGE]',                               // badge (optional)
            true,                                    // draft (optional)
            ''                                       // scheduledAt (optional)
        );
    

    Learn more about sending a push notification

    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://cloud.appwrite.io/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2')                 // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    const message - await messaging.createEmail(
            '[MESSAGE_ID]',                          // messageId
            '[SUBJECT]',                             // subject
            '[CONTENT]',                             // content
            [],                                      // topics (optional)
            [],                                      // users (optional)
            [],                                      // targets (optional)
            [],                                      // cc (optional)
            [],                                      // bcc (optional)
            true,                                    // draft (optional)
            false,                                   // html (optional)
            ''                                       // scheduledAt (optional)
        );
    

    Learn more about sending an email

    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://cloud.appwrite.io/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2')                 // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    const message = await messaging.createSMS(
            '[MESSAGE_ID]',                          // messageId
            '[CONTENT]',                             // content
            [],                                      // topics (optional)
            [],                                      // users (optional)
            [],                                      // targets (optional)
            true,                                    // draft (optional)
            ''                                       // scheduledAt (optional)
        );
    

    Learn more about sending a SMS message