Skip to content

bottenderjs/messaging-apis

Repository files navigation

Messaging APIs

Build Status coverage License: MIT

Messaging APIs is amono repowhich collects APIs needed for bot development.

It helps you build your bots using similar API for multiple platforms, e.g. Messenger, LINE. Learn once and make writing cross-platform bots easier.

If you are looking for a framework to build your bots,Bottendermay suit for your needs. It is built on top ofMessaging APIsand provides some powerful features for bot building.

Packages

Package Version Platform
messaging-api-messenger npm Messenger
messaging-api-line npm LINE
messaging-api-slack npm Slack
messaging-api-telegram npm Telegram
messaging-api-viber npm Viber
messaging-api-wechat npm WeChat

Usage

Messenger

Messenger

Installmessaging-api-messengerpackage from the registry:

npm i --save messaging-api-messenger

or

yarn add messaging-api-messenger

Then, create aMessengerClientto call Messenger APIs:

const{MessengerClient}=require('messaging-api-messenger');

// get accessToken from facebook developers website
constclient=newMessengerClient({
accessToken:'ACCESS_TOKEN',
});

client.sendText(userId,'Hello World').then(()=>{
console.log('sent');
});

Check outfull API documentationfor more detail information.

LINE

LINE

Installmessaging-api-linepackage from the registry:

npm i --save messaging-api-line

or

yarn add messaging-api-line

Then, create aLineClientto call LINE APIs:

const{LineClient}=require('messaging-api-line');

// get accessToken and channelSecret from LINE developers website
constclient=newLineClient({
accessToken:'ACCESS_TOKEN',
channelSecret:'CHANNEL_SECRET',
});

client.pushText(userId,'Hello World').then(()=>{
console.log('pushed');
});

Check outfull API documentationfor more detail information.

Slack

Slack

Installmessaging-api-slackpackage from the registry:

npm i --save messaging-api-slack

or

yarn add messaging-api-slack

Then, create aSlackOAuthClientorSlackWebhookClientto call Slack APIs:

const{SlackOAuthClient}=require('messaging-api-slack');

// get access token by setup OAuth & Permissions function to your app.
// https://api.slack /docs/oauth
constclient=newSlackOAuthClient({
accessToken:'xoxb-000000000000-xxxxxxxxxxxxxxxxxxxxxxxx',
});

client.postMessage('#random','Hello World').then(()=>{
console.log('sent');
});
const{SlackWebhookClient}=require('messaging-api-slack');

// get webhook URL by adding a Incoming Webhook integration to your team.
// https://my.slack /services/new/incoming-webhook/
constclient=newSlackWebhookClient({
url:'https://hooks.slack /services/XXXXXXXX/YYYYYYYY/zzzzzZZZZZ',
});

client.sendText('Hello World').then(()=>{
console.log('sent');
});

Check outfull API documentationfor more detail information.

Telegram

Telegram

Installmessaging-api-telegrampackage from the registry:

npm i --save messaging-api-telegram

or

yarn add messaging-api-telegram

Then, create aTelegramClientto call Telegram APIs:

const{TelegramClient}=require('messaging-api-telegram');

// get accessToken from telegram [@BotFather](https://telegram.me/BotFather)
constclient=newTelegramClient({
accessToken:'12345678:AaBbCcDdwhatever',
});

client.sendMessage(chatId,'Hello World').then(()=>{
console.log('sent');
});

Check outfull API documentationfor more detail information.

Viber

Viber

Installmessaging-api-viberpackage from the registry:

npm i --save messaging-api-viber

or

yarn add messaging-api-viber

Then, create aViberClientto call Viber APIs:

const{ViberClient}=require('messaging-api-viber');

// get authToken from the "edit info" screen of your Public Account.
constclient=newViberClient({
accessToken:'AUTH_TOKEN',
sender:{
name:'Sender',
},
});

client.sendText(userId,'Hello World').then(()=>{
console.log('sent');
});

Check outfull API documentationfor more detail information.

WeChat

WeChat

Installmessaging-api-wechatpackage from the registry:

npm i --save messaging-api-wechat

or

yarn add messaging-api-wechat

Then, create aWechatClientto call Wechat APIs:

const{WechatClient}=require('messaging-api-wechat');

// get appId, appSecret from “WeChat công chúng ngôi cao - khai phá - cơ bản phối trí” page
constclient=newWechatClient({
appId:'APP_ID',
appSecret:'APP_SECRET',
});

client.sendText(userId,'Hello World').then(()=>{
console.log('sent');
});

Check outfull API documentationfor more detail information.

Documentation

Change Log

Every release, along with the migration instructions, is documented on theCHANGELOG.mdfile.

License

MIT ©Yoctol