1
0
mirror of synced 2024-11-21 20:16:03 +03:00
mg-bot-api-client-js/README.md
2019-02-06 14:54:15 +03:00

1.0 KiB

retailCRM Message Gateway Bot API JS client

This is js retailCRM bot API client. API documentation

Installation

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

In your file

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

Usage

Get users

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

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
});

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);
    });