Messaging

Send SMS Messages

Send SMS messages to your users using Nuvix Messaging.

You can send custom SMS messages to your app's users using Nuvix Messaging and a connected SMS service. This guide takes you through the implementation path of adding SMS messaging to your app.

Add a provider

Nuvix supports Twilio, MSG91, Telesign, Textmagic, and Vonage as SMS providers. You must configure one of them as a provider.

Add SMS provider configuration

To add a new provider navigate to Messaging > Providers > Add provider > SMS and follow the wizard. You can find more details about configuring in the provider guides for Twilio, MSG91, Telesign, Textmagic, and Vonage.

Add targets

In Nuvix Messaging, each user has targets like their email, phone number, and devices with your app installed. You can deliver messages to users through their targets.

Target overview showing user contact methods

If the user signed up with phone (SMS) authentication, their account would already have a phone number as a target. During development, you can add targets to existing accounts by navigating to Authentication > Users > Select a user > Targets > Add a subscriber.

Add target interface for user

You can also implement forms in your app to collect contact information and add it as a target with the createTarget endpoint.

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

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

const users = new Users(client);

const target = await users.createTarget(
  '<USER_ID>',
  '<TARGET_ID>',
  'phone',
  '<IDENTIFIER>',
  '<PROVIDER_ID>',
  '<NAME>'
);

Create topics (optional)

You can use topics to organize targets that should receive the same messages, so you can send SMS messages to groups of targets instead of one at time. This step is optional if you plan to only send SMS messages to individual targets.

To create a topic in the Nuvix Console, navigate to Messaging > Topics > Create topic.

Create topic interface

You can also create topics programmatically using the Nuvix Server SDK.

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(
  '<TOPIC_ID>',
  '<NAME>'
);

Send SMS messages

You can send SMS messages using the Server SDK. To send an SMS messages immediately, you can call the createSms endpoint without passing either the draft or scheduledAt parameters.

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

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

const message = await nx.messaging.createSms(
  '<MESSAGE_ID>',
  '<CONTENT>',
  [],
  [],
  [],
  false,
  ''
);

Schedule SMS message

To send an scheduled SMS message, you can call the createSms endpoint with scheduledAt as an ISO 8601 date time string for the scheduled time.

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

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

const message = await nx.messaging.createSms(
  '<MESSAGE_ID>',
  '<CONTENT>',
  [],
  [],
  [],
  false,
  '2025-02-13T22:01:00+0000'
);

How is this guide?

Last updated on

Send SMS Messages