App Inbox Messaging

Antsomi App Inbox Messaging feature allows you to engage and communicate with your users effectively through notifications within your mobile application. App Inbox messages provide a seamless way to deliver timely and personalized information to your users. With this feature, you can enhance user engagement, promote important updates, and tailor your communication based on user behavior and preferences.

Before continuing, please ensure that you've added the React Native SDK to your app.

1. Configure App Inbox

In your main(), after invoking the config() method of AntsomiSDK, you can init the app inbox by following:

AntsomiRnSDK.configAppInbox('<DESTINATION_ID>', '<AUDIENCE_TYPE>');

To effectively configure Antsomi App Inbox Messaging, you'll need to define two essential parameters: DESTINATION_ID and AUDIENCE_TYPE. The table below provides a quick overview of each parameter and its purpose.

FieldData TypeDescription

DESTINATION_ID

String

A unique identifier specifying the message destination.

AUDIENCE_TYPE

Enum Value:

  • customers

  • users

A classification parameter for targeted messaging. Each DESTINATION_ID can target one AUDIENCE_TYPE only.

If you don't know how to get your DESTINATION_ID, refer to this document

2. App Inbox APIs

After configuring the Antsomi App Inbox, you're ready to harness the power of the following APIs to manage and deliver messages effectively. These APIs empower you to organize messages into categories, retrieve messages, access specific messages by their unique identifiers, and control message statuses, enhancing your ability to engage with users through the App Inbox.

Get a List of Message Labels

When App Inbox messages are delivered via CDP365, they are categorized into one or multiple catalogs based on their content and relevance. This API allows you to retrieve these categorized catalogs, efficiently organizing and presenting messages to users, enhancing their overall messaging experience within your mobile app.

To retrieve a list of message categories, you can use the following function:

import AntsomiRnSDK, { Catalog } from '@antsomicorp/antsomirnsdk';


function AppInboxScreen() {
    const [labels, setLabels] = useState<Catalog[]>([]);

    AntsomiRnSDK.getAllLabels((labels: Catalog[]) => {
        setLabels(labels);
    });
}

In which:

ParamsData TypeDescription

callback

Function

The callback function after the API 'Get list Message Labels' response, which has 1 parameter is an array of the Catalog objects.

The Catalog object is a structured data container that represents a message category within the Antsomi App Inbox. Here's a brief description of the key attributes within the Catalog object:

AttributeData TypeDescription

catalogId

string

A unique identifier for the message category.

catalogName

string

The name or title of the category.

To illustrate, look at the sample result below, showcasing a list of Catalogs retrieved from the API. In a real app scenario, this information is typically presented to users on a mobile app screen, ensuring seamless message organization and access.

Get a List of Messages

The 'Get List Messages' API allows you to retrieve a comprehensive list of messages within your Antsomi App Inbox.

To retrieve a list of messages, you can use the following function:

import AntsomiRnSDK, { AppInboxItem, Catalog } from '@antsomicorp/antsomirnsdk';

function AppInboxScreen() {
    const [filterLabels, setFilterLabel] = useState<Catalog[]>([]);
    const [page, setPage] = useState<number>(1);
    
    const [messages, setMessages] = useState<AppInboxItem[]>();

    AntsomiRnSDK.getListMessage(
        filterLabels.map(label => label.catalogId), 
        page, 
        (messages: AppInboxItem[]) => {
            setMessages(messages);
        }
    );
}

In which:

ParamsData TypeDescription

labels

string[]

The list of filtering message labels. If empty, the API 'Get list Messages' will return all of the messages.

page

number

The current page you want the API to return.

callback

Function

The callback function after the API 'Get list Messages' response, which has 1 parameter is an array of the AppInboxItem objects.

The AppInboxItemobject is a structured data container that represents a message category within the Antsomi App Inbox. Here's a brief description of the key attributes within the AppInboxItem object:

FieldData TypeDescription

item_id

string

The unique ID of each message.

button_label_1

string

The label of the first button is associated with the message.

button_app_url_1

string

The URL or action associated with the first button can lead to a specific destination or action when clicked.

button_label_2

string

The label of the second button associated with the message (if applicable).

button_app_url_2

string

The URL or action associated with the second button can lead to a specific destination or action when clicked (if applicable).

image_url

string

The URL of the message's cover image.

heading

string

The heading or title of the message.

content

string

The text content of the message.

template_id

string

The ID of the message template. Messages can fall into one of three templates:

  • announcements with no buttons

  • coupon with one button

  • order_verified with two buttons

catalog_ids

string[]

An array of Category IDs to which this message has been categorized.

status

number

The status of the message, where:

  • 1 represents unread

  • 2 represents read

date_created

string

The timestamp indicates when the message was created.

last_updated

string

The timestamp indicates the most recent update to the message.

To provide a visual representation of the 'Get List Messages' API's functionality, consider the examples below. The first illustrates a list of messages retrieved from the API without any filtering. In contrast, the second example demonstrates the API's advanced filtering capabilities, resulting in a tailored list of messages associated with specific catalogs.

Get a Message by ID

The 'Get a Message by ID' API serves as a valuable tool to retrieve a specific message from your Antsomi App Inbox. By supplying the unique identifier of the desired message, you can access its content and details with ease.

To retrieve a message using its ID, you can use the following function:

import AntsomiRnSDK, { AppInboxItem } from '@antsomicorp/antsomirnsdk';

function AppInboxScreen() {
    const [selectedMessageId, setSelectedMessageId] = useState<string>("");
    const [selectedMessage, setSelectedMessage] = useState<AppInboxItem>();

    AntsomiRnSDK.getMessageById(
        selectedMessageId, 
        (message: AppInboxItem) => {
            setSelectedMessage(message);
        }
    );
}

In which:

ParamsData TypeDescription

messageId

string

The unique ID of the message you're retrieving.

callback

Function

The callback function after the API 'Get Message by ID' response, which has 1 parameter is the AppInboxItem object.

To illustrate this API's functionality, refer to the example below, showcasing a retrieved message based on its unique ID.

Change a Message status

With the 'Update Message Status' API, you can toggle a message's status between read and unread, allowing for precise control over how messages are presented to users.

To modify a message status, simply call this function:

import AntsomiRnSDK, { AppInboxItem } from '@antsomicorp/antsomirnsdk';

function AppInboxScreen() {
    const [selectedMessageIds, setSelectedMessageIds] = useState<string[]>([]);

    AntsomiRnSDK.modifyAction(
        selectedMessageIds, 
        MessageStatus.READ
    );
}

In which:

ParamsData TypeDescription

messageIds

string

The list of message ID you're modiyfing.

action

MessageStatus

The status of the message:

  • UNREAD

  • READ

  • DELETE

To illustrate the functionality of this API, please refer to the example below, which showcases the process of updating a message's status from read(without the blue dot indicator) to unread(with the blue dot indicator) or vice versa.

Incorporate Antsomi's App Inbox Messaging to elevate your mobile app's communication strategy. With powerful APIs and customization options, you can deliver personalized, engaging messages tailored to your users' preferences.

Last updated