Skip to content

tilli-pro/nudge.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nudge.js

A nudge in time saves nine

The nudge.js SDK is a lightweight (ZERO dependencies) wrapper around nudge and its APIs.

Getting Started

The nudge.js SDK clients come in 2 flavors:

  1. The fully featured nudge.js client that exposes all API capabilities within nudge
  2. The "Send" client which specifically only supports sending real-time nudges

To use the nudge.js SDK you need either an API key (for sending real-time nudges via the "Send" client) or the user credentials used to log into app.nudge.net (all other functionality).

Tip

If you're not sure how to get an API key, you can read more here: Nudge API Documentation

In either case, getting started is the same:

import { createSendClient, createClient } from "@tilli-pro/nudge.js";

const apiKey = ""; // get this from the nudge dashboard
const sendClient = createSendClient({ apiKey });

// credentials used to login to app.nudge.net
const authCredentials = {
  email: "",
  password: "",
};
const client = createClient({ apiKey, authCredentials });

The clients can be used immediately for sending real-time nudges:

sendClient.send({
  nudgeId: "1234", // you can get this from the nudge dashboard
  recipient: {
    email: "[email protected]",
    name: "Ibrahim Ali", // OPTIONAL
  },
  options: { // OPTIONAL
    cc: ["[email protected]"], // OPTIONAL
    bcc: ["[email protected]"], // OPTIONAL
  },
  mergeTags: { // OPTIONAL
    productName: "tilliX",
  },
  files: [ // OPTIONAL
    new File(["test_document_text"], "test_document.txt", { type: "text/plain" }),
  ],
});
// => Promise<NudgeSendResult>
// { success: true; error: undefined }
// { success: false; error: { HasErrors: boolean; Code: number; Error: string; } }

That's it. Your nudge has been sent.

About

Send nudges wherever you are

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published