1
0
mirror of synced 2024-11-24 21:36:02 +03:00
JS client for MG Bot API
Go to file
2019-02-08 15:08:52 +03:00
lib Restructuring 2019-02-08 13:32:10 +03:00
tests Restructuring 2019-02-08 13:32:10 +03:00
.gitignore Initial bot api client 2019-02-06 14:54:15 +03:00
.travis.yml fix travis configuration 2019-02-08 15:00:17 +03:00
index.js Restructuring 2019-02-08 13:32:10 +03:00
LICENSE Initial commit 2018-09-04 10:25:53 +03:00
package.json Restructuring 2019-02-08 13:32:10 +03:00
README.md Update README.md 2019-02-08 15:08:52 +03:00

Build Status GitHub release Node version

retailCRM Message Gateway Bot API JS client

This is js retailCRM bot API client.

Installation

npm install --save mg-bot-api-client-js

In your file

var RetailcrmBotApiClient = require('mg-bot-api-client-js');

Usage

Get users

var api = new RetailcrmBotApiClient({
    host: 'https://api.example.com',
    token: 'your bot token',
    apiVersion: 'v1' // optional
}).getClient();

api.getUsers()
    .then(function (users) {
        console.log(users);
    })
    .catch(function (e) {
        console.log(e);
    });

Send message

var api = new RetailcrmBotApiClient({
    host: 'https://api.example.com',
    token: 'your bot token',
    apiVersion: 'v1' // optional
}).getClient();

var message = {
    chat_id: 1,
    content: 'Text message',
    scope: 'public',
    type: 'text'
};

api.sendMessage(message)
    .then(function (result) {
        console.log(result);
    })
    .catch(function (e) {
        console.log(e);
    });