Skip to main content
Version: Release

Send alerts triggered by API call

Triggering notifications via API calls from your server can be done by creating a topic, and then using Notifi NodeJS SDK package here to trigger from your server

Step 1

Log in to the Admin Portal (create an account if you haven't done so already) and head to the Alert Manager page.

Step 2

Create your topic by selecting the Topics tab (default) and click on "+ Topic" in the top right, then select the "Send an alert triggered by an API call from my server".

create announcement

For the steps below, we will provide examples as if you were creating a topic to let users know about liquidity pool price updates. topic creation page

Topic Name

To start off, provide a name and display names for the topic:

  • Name this topic: The name of the topic that will appear in Alert Manager (e.g. "Liquidity Pool Price Updates")
  • Topic display name: The name of the topic that will appear in the subscriber card shown to users. Defaults to the topic name.
  • Topic display title in alert: The display name of the topic that will appear in Alert History (e.g. "Liquidity Pool Price Update")

Topic Data

When a user subscribes to a topic, they can be asked for some information to help address the notifications they are interested in:

Wallet Address (default)

The user is asked for their wallet address when they subscribe (the Notifi React Card will handle this automatically). Use this if you are sending alerts that only concern a specific wallet address (such as a liquidation warning for a specific user).

No Input From User

The user is not asked for any additional information. This is used for topics that broadcast to everyone, such as price pool updates.

User Selects From List

The user is asked to specify one or more custom values from a list when they subscribe. This is used in more complex UI scenarios where a user might be interested in one of several categories of update, such as getting updates on a price pair for an exchange. For more info on how to set up this feature, view this page.

Maximum Frequency

If you want to limit how often a user gets a message, regardless of how often you send alerts, set the Alert Frequency option. This allows you to limit alerts anywhere from once per minute to once per week, with an additional option to only ever send the alert to a user one time.

note

If you select the "User Selects From List" data above, this frequency will be tracked separately for each list item. For instance, if an alert sends updates once per day and a user signs up for both item A and item B, they can receive one notification for both items each day.

Optional Filters

You can also define optional filters:

Without Additional Filters

This is the simplest usecase where users will be presented with a simple toggle to register for alerts on this topic. When you'd like to send notifications from your server, you can use our SDK to send to either everyone who has subscribed, or subsets of users based on the wallet address they registered with.

Alt text

With Additional Filters

This allows your users to fully customize alerts even further. An example of this would be a liquidity pool price update, where your users subscribe to this topic, but would only want to receive updates if a particular value is above a certain threshold (even if you're publishing to the topic for a subset of users). For this experience, you will need to provide additional variables in the message you're publishing to the topic with. This will be covered in more detail in subsequent steps.

Alt text

Step 3

Upon creation of a new topic, you'll be presented with quick start guides and links to our SDK.

Alt text

Once you click Done, you'll be taken back to the Alert Management page. Make note of this "Event Type ID" that's specified for your topic. This will be used on your server to publish to this "Liquidity Pool Price Update" topic.

Alt text

Configure your infrastructure to publish to your topic

First, you want to install the NPM package in the NodeJS application that will be sending this notification.

npm install @notifi-network/notifi-node

Ensure this application is running in a secure location that can access sensitive credentials that will be used to initialize the Notifi NodeJS SDK. Never allow the initialization credentials to ever be sent to a user's web browser.

Decide where to store your initialization credentials. This is app specific. We highly recommend not storing in anything that's committed to source control such as git. Here are some ideas of how to store secrets for a NodeJS app.

Step 4

Once you've created your topic, make note of the topic identifier to use in a publishFusionMessage. To get started you may also copy/paste the sample code that's provided after you've created a topic. This must be copy/pasted in the same NodeJS app you did step (1) in.

Finally, you should modify the sample to only call the initialization routine once daily, and then customize the publishFusionMessage with your specific topic data. You may pass whatever JSON object you'd like. This JSON object is what will be used to help render notifications later. If you have defined any optional filters for the user to be able to specify when registering for an alert on this topic, then you must also make sure to pass in the required filter parameter variables in your call.

Now that you're triggering the notifications with your custom JSON object, you can configure your templates so that the notifications are rendered appropriated per destination.