New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

boteco

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boteco

Fastest framework for develop Botmaker Bots, but with low changes can use with different chatbot hosts;

latest
npmnpm
Version
2.2.0
Version published
Weekly downloads
20
Maintainers
1
Weekly downloads
 
Created
Source

Boteco 🤖

Fastest framework for develop Botmaker Bots, but with low changes can use with different chatbot hosts;

To use

  • Install with:
  npm install -D boteco
  • Import with:
const Boteco = require('Boteco').default;
// or in typescript or ES modules
import Boteco from 'Boteco';
  • Use With:
const bot = new Boteco({
  contextType: 'botmaker',
  TOKEN: '<Bot maker Token>',
});

bot.hears('Oi', (ctx) => {
  const hostNumber = ctx.me.telephoneNumber;
  const clientNumber = ctx.from.user.telephoneNumber;
  ctx.sendMessage('Hello from Boteco!', {
    chatPlatform: 'whatsapp',
    chatChannelNumber: hostNumber,
    platformContactId: clientNumber,
  });
});

bot.launch();
  • Run javascript file 👻 👻

Advanced

  • Wizard with session example:
const Boteco = require('boteco').default;
const session = require('boteco').default;
const Composer = require('boteco').default;
const Wizard = require('boteco').default;
const Stage = require('boteco').default;

const bot = new Boteco({
  contextType: 'botmaker',
  TOKEN: '<Bot maker Token>',
});

bot.use(session());

const composerFN = new Composer();

composerFN.hears(/^(\w+)$/gm, async (ctx) => {
  [ctx.session.firstName] = ctx.match;
  await ctx.sendMessage(`Hello! ${ctx.session.firstName}`, {
    chatPlatform: 'whatsapp',
    chatChannelNumber: ctx.me.telephoneNumber,
    platformContactId: ctx.from.user.telephoneNumber,
  });
  await ctx.sendMessage('Tel me your last name:', {
    chatPlatform: 'whatsapp',
    chatChannelNumber: ctx.me.telephoneNumber,
    platformContactId: ctx.from.user.telephoneNumber,
  });

  ctx.wizard.next();
});

composerFN.use((ctx) => {
  ctx.sendMessage("Sorry, i don't understand", {
    chatPlatform: 'whatsapp',
    chatChannelNumber: ctx.me.telephoneNumber,
    platformContactId: ctx.from.user.telephoneNumber,
  });
});

const composerLN = new Composer();

composerLN.hears(/^(\w+)$/gm, (ctx) => {
  [ctx.session.lastName] = ctx.match;
  ctx.sendMessage(`Yeah! You said: ${ctx.session.firstName} ${ctx.session.lastName}!`, {
    chatPlatform: 'whatsapp',
    chatChannelNumber: ctx.me.telephoneNumber,
    platformContactId: ctx.from.user.telephoneNumber,
  });
  ctx.scene.leave();
});

const wizName = new Wizard(
  'NAMEWIZARD',
  (ctx) => {
    ctx.sendMessage('Tel me your first name: ', {
      chatPlatform: 'whatsapp',
      chatChannelNumber: ctx.me.telephoneNumber,
      platformContactId: ctx.from.user.telephoneNumber,
    });
    return ctx.wizard.next();
  },
  composerFN,
  composerLN,
);

const stage = new Stage([wizName]);

bot.use(stage.middleware());

bot.hears('Hi', (ctx) => {
  const hostNumber = ctx.me.telephoneNumber;
  const clientNumber = ctx.from.user.telephoneNumber;
  ctx.sendMessage('Hello from Boteco!', {
    chatPlatform: 'whatsapp',
    chatChannelNumber: hostNumber,
    platformContactId: clientNumber,
  });
  ctx.scene.enter('NAMEWIZARD');
});

bot.launch();

Keywords

BotMaker

FAQs

Package last updated on 07 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts