Node.js library for interacting with the Botika Socket HTTP API.
You can get the Botika Socket PHP library via a npm package called botika-socket
. See https://www.npmjs.com/package/botika-socket
npm i botika-socket
Use the credentials from your Botika Socket application to create a new instance.
import { Socket, Auth } from 'botika-socket';
const baseURL = 'https://socket.example.com';
const auth = new Auth('username', 'password');
// Initialize socket
const socket = new Socket(baseURL, auth);
const logger = require('pino')()
socket.setLogger(logger);
To trigger an event on one or more channels use the trigger
function.
// Options get from https://axios-http.com/docs/req_config
const options = {};
socket.trigger('my-channel', 'my_event', 'hello world', options);
// Options get from https://axios-http.com/docs/req_config
const options = {};
socket.trigger([ 'channel-1', 'channel-2' ], 'my_event', 'hello world', options);