npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fyno/node

v1.1.10

Published

This is the official Node.js module for sending notifications through Fyno.io.

Downloads

1,450

Readme

This is the official Node.js module for sending notifications through Fyno.io.

You can use this module to send notifications to any channel (SMS, Email, WhatsApp, Push, Discord, Teams, Slack, etc).

Fyno: Fire your notifications

Installation

npm install @fyno/node
OR
yarn add @fyno/node

Prerequisite

You will need to:

  • Own a Fyno.io account
  • Create a Fyno API Key
  • Obtain the Workspace ID for your account
  • Create integrations, templates, routing (optional), events as per your requirement

Environment Variables

We recommend using environment variables for storing your Workspace ID and API Key. To set values for these variables, use the following variable names:

  • FYNO_WSID: To store the Workspace ID.
  • FYNO_API_KEY: To store the API Key.
  • FYNO_VERSION: To specify the version you wish to use for sending notifications. Possible values: test, live. Default: live.

Getting Started

Here's a code snippet that can help you get started:

import { Fyno } from "@fyno/node";

// If you set the environment variables discussed earlier, use the following code:
const fyno = new Fyno();

// If you wish to provide the environment variables manually, uncomment the lines below and comment the line above.
// const fyno = new Fyno(
//     "<FYNO_WSID>",
//     "<FYNO_API_KEY>",
//     "<FYNO_VERSION>"
// );

fyno.fire("<EventName>", {
    to: {
        sms: "", // Enter number with country code
        whatsapp: "", // Enter WhatsApp number with country code
        email: "", // Enter email address
        slack: "", // Enter slack ID or email address
        discord: "", // Enter discord ID
        teams: "", // Enter channel name
        push: "" // Enter push token
    },
    data: {
        // Enter data here        
    },
})

The snippet above lets you fire notifications to a single user. If you wish to fire notifications to multiple users, see the code snippet below.

Sending Bulk Notifications

To fire an event to multiple users, use the following code snippet:

fyno.fire("<EventName>", [
        {
            to: {
                // User 1 details
                sms: "", // Enter number with country code
                whatsapp: "", // Enter WhatsApp number with country code
                email: "", // Enter email address
                slack: "", // Enter slack ID or email address
                discord: "", // Enter discord ID
                teams: "", // Enter channel name
                push: "", // Enter push token
            },
            data: {
                // Enter data here
            },
        },
        {
            to: {
                // User 2 details
                sms: "", // Enter number with country code
                whatsapp: "", // Enter WhatsApp number with country code
                email: "", // Enter email address
                slack: "", // Enter slack ID or email address
                discord: "", // Enter discord ID
                teams: "", // Enter channel name
                push: "", // Enter push token
            },
            data: {
                // Enter data here
            },
        },
    ]);

Caution: The maximum accepted payload size (for bulk send) is 10 MB.

For more details, please visit our API Reference guide.

Creating a user profile

You can create a user profile using identify() method and update the existing profile with updateProfile() method, use the below snipped to create user profile in Fyno

const profile = fyno.identify("<DISTINCTID>", {
    name: "<FULL NAME>",
    channel: {
        sms: "", // Enter mobile number for sms channel with country code
        whatsapp: "", // Enter mobile number for whatsapp channel with country code
        email: "", // Enter email address
        slack: "", // Enter Slack Id or Email address
        discord: "", // Enter Discord id
        teams: "", // Enter channel name
        inapp: [{
            token: "", // Enter Inapp token
            integration_id: "", // Enter Inapp integration ID to be used for this token.
            status: "" // Status of token
        }],
        push: [{
            token: "", // Enter Push token
            integration_id: "", // Enter Push integration ID to be used for this token.
            status: "" // Status of token
        }]
    }
})
profile.create()

use the below code to update the existing profile

const profile = fyno.update("<DISTINCTID>", {
    name: "<MODIFIED_FULL NAME>",
    channel: {
        sms: "", // Enter mobile number for sms channel with country code
        whatsapp: "", // Enter mobile number for whatsapp channel with country code
        email: "", // Enter email address
        slack: "", // Enter Slack Id or Email address
        discord: "", // Enter Discord id
        teams: "", // Enter channel name
        inapp: [{
            token: "", // Enter Inapp token
            integration_id: "", // Enter Inapp integration ID to be used for this token.
            status: "" // Status of token
        }],
        push: [{
            token: "", // Enter Push token
            integration_id: "", // Enter Push integration ID to be used for this token.
            status: "" // Status of token
        }]
    }
})

Adding and Removing Channels against a proflie

Once user is created you can use the returned object to add or remove channle data, use the below snippet to add/remove channle data

const profile = fyno.identify("<DISTINCTID>")
//This will add sms number against the profile
profile.setSms("<MOBILE_NUMBER>")
//This will clear sms channel
profile.clearChannel(["sms", "whatsapp"])

NOTE: For clearing channel you can just pass channel name except for inapp and push, for inapp and push you need to pass token like profile.clearChannel("inapp", "<INAPP_TOKEN>")