npm.io
0.1.1 • Published 2 years ago

@teleflow/stateless

Licence
MIT
Version
0.1.1
Deps
3
Size
8 kB
Vulns
0
Weekly
0

Install

npm install @teleflow/stateless
yarn add @teleflow/stateless

Usage

import { TeleflowStateless, ChannelTypeEnum } from '@teleflow/stateless';
import { SendgridEmailProvider } from '@teleflow/sendgrid';

const teleflow = new TeleflowStateless();

await teleflow.registerProvider(
  new SendgridEmailProvider({
    apiKey: process.env.SENDGRID_API_KEY,
    from: 'sender@mail.com',
  })
);

const passwordResetTemplate = await teleflow.registerTemplate({
  id: 'password-reset',
  messages: [
    {
      subject: 'Your password reset request',
      channel: ChannelTypeEnum.EMAIL,
      template: `
          Hi {{firstName}}!
          
          To reset your password click <a href="{{resetLink}}">here.</a>
          
          {{#if organization}}
            <img src="{{organization.logo}}" />
          {{/if}}
      `,
    },
  ],
});

await teleflow.trigger('<REPLACE_WITH_EVENT_NAME>', {
  $user_id: '<USER IDENTIFIER>',
  $email: 'test@email.com',
  firstName: 'John',
  lastName: 'Doe',
  organization: {
    logo: 'https://evilcorp.com/logo.png',
  },
});

Providers

Teleflow provides a single API to manage providers across multiple channels with a simple-to-use interface.

Email
SMS
Push
Chat
In-App
Other (Coming Soon...)
  • PagerDuty