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

@cocomail/node

v1.0.2

Published

Nodejs library for cocomail.io

Downloads

6

Readme

Cocomail NodeJS Library

NodeJS library for integrating with the Cocomail API

API Documentation

API Documentation

Getting Started

  • Create an API key

Create an API key under the Account Section of the app and find the API Keys section.

The API key should have the access control events_trigger_access

  • Create an event

Create an API key under the Event Section of the app and copy the identifier field which will be used in the next step.

  • Triggering an event

Instantiate a new instance of Cocomail and provide the API key created earlier.

const cocoClient = new Cocomail(process.env.COCOMAIL_API_KEY);

const identifier = 'SIGNUP'
const response = await cocoClient.triggerEvent({
  identifier: identifier,
  email: email
});

Required fields

email

The email of the contact that triggered the event - If a contact with the email does not already exist it will be created

identifier

The identifier of the event to trigger.

Events can be created under the Events tab of the dashboard.

Optional fields

consentsToEmails

Default value: true

If the created contact consents to receive emails or not

const cocoClient = new Cocomail(process.env.COCOMAIL_API_KEY);

const identifier = 'SIGNUP';
const userReceivesToMarketingEmails = true;

const response = await cocoClient.triggerEvent({
  identifier: identifier,
  email: email,
  consentsToEmails: userReceivesToMarketingEmails
});

contactMetadata

Default value: empty object

Metadata that should be added to the contact when the event is triggered. If the field already exists on the contact it will be updated with the new values.

const cocoClient = new Cocomail(process.env.COCOMAIL_API_KEY);

const identifier = 'SIGNUP'
const response = await cocoClient.triggerEvent({
  identifier: identifier,
  email: email,
  contactMetadata: {
    signed_up_at = new Date().toString();
  }
});

triggerMetadata

Default value: empty object

Metadata that should only be used for the duration of the request and in subsequent Automations triggered by the event.

The forgot_password_link field in the request will be substituted with the {{forgot_password_link}} template variable in the Email Template

const cocoClient = new Cocomail(process.env.COCOMAIL_API_KEY);

const identifier = 'FORGOT_PASSWORD'
const response = await cocoClient.triggerEvent({
  identifier: identifier,
  email: email,
  triggerMetadata: {
    forgot_password_link = "https://app-url.com/forgot-password/unique-password-reset-link"
  }
});

Example Response

{
  "data":{
    "contact":{
        "id":"018e32c3-4fd6-71cb-9425-ebd7f8ac09d2",
        "email":"[email protected]",
        "metadata":{
          "forgot_password_at":"2024-03-18T10:25:00.000Z"
        },
        "createdAt":"2024-03-12T13:04:04.566Z"
    },
    "event":{
        "id":"018e50e3-5b19-734e-ab70-4909b83426ec",
        "name":"Forgot Password",
        "identifier":"FORGOT_PASSWORD",
        "createdAt":"2024-03-18T09:27:41.000Z"
    },
    "trigger":{
        "metadata":{
          "forgot_password_link":"https://app-url.com/forgot-password/unique-password-reset-page"
        }
    }
  },
  "error":null
}

Example Error Response

{
  "data": null,
  "error": "Event with identifier INVALID_EVENT_IDENTIFIER not found"
}