0.2.5 • Published 4 years ago

zipbot v0.2.5

Weekly downloads
11
License
ISC
Repository
github
Last release
4 years ago

Zipwhip Bot SDK

This library automates the process of enabling and disabling webhooks upon bot installation. It gives users' a clean way to listen in on events triggering upon a Zipwhip account all while letting them focus on business logic.

Chatbot Example

const { Bot, Event } = require("../dist/index");
const badWords = require('./badwords');

const bot = new Bot(process.env.BOT_ID);

let counter = 0;

bot.on(Event.Receive, (ctx, msg) => {
  switch (msg.body) {
    case "count":
      counter++;
      ctx.reply(`The counter is at ${counter}`);
      break;
    case "reset"
      counter = 0;
      ctx.reply("I've reset the counter");
  }
});

bot.run();

This library works hand in hand with the Zipwhip App Store, automatically listening for the activate/deactivate webhooks which initializes the webhooks and other resources required for the bots operation

UI Components

const { Bot, Event } = require("../dist/index");
const badWords = require('./badwords');

const bot = new Bot(process.env.BOT_ID);
let counter = 0;

bot.sidebar((ui, {convId, line}) => {
  ui.text("Conversation Id: " + convId);
  ui.text("Line: " + line);

  ui.text("Page has been hit " + counter + " times")
  ui.button("Reset Counter", () => counter = 0)

  ui.button("Hello World!", () => console.log("Hello, World!"))
  ui.button("Goodbye!", () => console.log("Goodbye!"))

  counter++;
});

bot.on(Event.Receive, (ctx, msg) => {
  switch (msg.body) {
    case "count":
      ctx.reply("I've seen ", counter, "visitors");
      break;
    case "reset":
      counter = 0;
      ctx.reply("I've reset the counter for you!");
      break;
  }
});

bot.run();

This code will produce the following ui component:

Sidebar Example

0.2.5

4 years ago

0.2.3

4 years ago

0.2.4

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.2.2

4 years ago

0.1.1

5 years ago

0.1.0

5 years ago