Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vk-chat-bot

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vk-chat-bot

Framework for easy creation of chat bots for VK communities (uses Callback API).

  • 13.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-98.62%
Maintainers
1
Weekly downloads
 
Created
Source

❮vk-chat-bot❯

version downloads style travis

A chat bot framework for VK communities (groups).
documentation »changelog »featuresusagecontributinglicense

Features

  • Easy to use - setting up behavior is simple - see 2. Behavior setup below
  • Respects the quota - the framework calls VK API not more then 20 times/second, so you don't exceed the quota

Usage

Installation
$ npm i vk-chat-bot
Example

You can find an example bot in the u32i64/vk-chat-bot-example repository.
Also, a step-by-step Heroku Deploy Guide can guide you through the process of deploying u32i64/vk-chat-bot-example to Heroku.

Quick Start
1. Preparation

First, require() the framework:

const vk = require('vk-chat-bot');

Then, create your bot using the vk.bot function (see Params object for more information about params):

const params = {
  vkToken: 'your_vk_access_token',
  confirmationToken: 'f123456',
  groupId: 1234567,
  secret: 's3r10us1y_s3cr3t_phr4s3',
  port: 12345,

  cmdPrefix: "/"
};

var { bot, core } = vk.bot(params);
2. Behavior setup

See Core wiki to learn more about behavior functions.
Here are some examples:

// Use stuff from the framework...
const { colors, Button, Keyboard } = vk.kbd;

// ...to create a keyboard like this.
// +---------+---------+----------+----------+
// | Default | Primary | Negative | Positive |
// +---------+---------+----------+----------+
// |     Maximum rows is 10, columns - 4.    |
// +-----------------------------------------+
var kbd = new Keyboard([
  [ /* Row (array of buttons) */
    new Button('Default'),
    new Button('Primary', colors.primary),
    new Button('Negative', colors.negative),
    new Button('Positive', colors.positive)
  ],
  [
    new Button('Maximum rows is 10, columns - 4.')
  ],
]);

// When user presses the `Start` button...
// (you have to enable the button in community settings)
core.on('start', $ => {
  // ...send them our keyboard.
  $.text("Thanks for messaging us! Choose from the options below:");
  $.keyboard(kbd);

  // Here, $.send() is added automatically.
});
// Searches for cmd_prefix + 'help', e.g. "/help"
core.cmd('help', $ => {
  // core.help() returns the help message
  $.text('Test Bot v1.0' + core.help());

  // Attach an image from
  // https://vk.com/team?z=photo6492_45624077
  $.attach('photo', 6492, 456240778);
}, 'shows the help message');
// Use case-insensitive regular expression to find words "hi", "hello" or "hey"
core.regex(/h(i|ello|ey)/i, $ => {
  $.text('Hello, I am a test bot. You said: ' + $.msg);
});
3. Start it!

Start the bot:

bot.start();

The bot will log some useful information, see Logging documentation for more information.

Contributing

  • Something does not seem right or you have a feature request? Open an issue.
  • You know how to make vk-chat-bot better? Open a pull request!

License

This project is licensed under the terms of the MIT license.

Keywords

FAQs

Package last updated on 22 Feb 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc