Messaging

Topics

Allow groups of users to subscribe to a common topic and receive the same notifications.

In Nuvix Messaging, you can use topics to deliver messages to groups of users at once.

Add a target

Topics overview

Topics and targets

A user can have multiple targets, such as emails, phone numbers, and devices with your app installed. These targets can subscribe to a topic, so when messages are published to a topic, all subscribed targets receive the message.

Learn more about targets

Understand how targets work with topics to deliver messages

Organizing topics

A topic should have semantic meaning. For example, a topic can represent a group of customers that receiving a common announcement or publishing public updates. It's important to keep privacy in mind when using topics. Prefer sending private information like chat messages by addressing individual targets attached to a user.

Topics are optimized for delivering the same message to large groups of users. If you need to deliver messages to all devices of the same user, you can find a user's targets by calling nx.account.get().

Create a topic

You can create topics

Add a topic

Add a topic

Navigate to your Nuvix Console > Messaging > Topics > Create topic.

import { Client } from '@nuvix/client';

const nx = new Client()
  .setEndpoint('https://api.nuvix.in/v1')
  .setProject('<PROJECT_ID>')
  .setKey('<API_KEY>');

const topic = await nx.messaging.createTopic({
  topicId: '<TOPIC_ID>',
  name: '<NAME>',
  subscribe: ['<ROLES>']  // permission roles for who can subscribe
});

CLI functionality is coming soon to Nuvix. For now, please use the Console or Server SDK methods described above.

Permissions

Before you can subscribe to a topic, a user needs the appropriate permission. You can set permission by navigating to Messaging > Topics > select a topic to configure > Subscription access.

Learn more about permission roles

Understand how permission roles work in Nuvix

Subscribe targets to a topic

During development, you can subscribe targets to a topic for testing right in the Nuvix console.

Add a topic

Add a subscriber

Navigate to your Nuvix Console > Messaging > Topics > click on your topic > Subscribers > Create topic > Add subscriber.

If you can't find the targets you'd like to add, see the targets page.

import { Client } from '@nuvix/client';

const nx = new Client()
  .setEndpoint('https://api.nuvix.in/v1')
  .setProject('<PROJECT_ID>')
  .setJWT('<JWT_TOKEN>');  // Your secret JSON Web Token



const subscriber = await nx.messaging.createSubscriber({
  topicId: '<TOPIC_ID>',
  subscriberId: '<SUBSCRIBER_ID>',
  targetId: '<TARGET_ID>'
});

How is this guide?

Last updated on

Topics