You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Messaging APIs is a mono repo which 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, Bottender may suit for your needs. It is built on top of Messaging APIs and provides some powerful features for bot building.
Install messaging-api-line package from the registry:
npm i --save messaging-api-line
or
yarn add messaging-api-line
Then, create a LineClient to call LINE APIs:
const{ LineClient }=require('messaging-api-line');// get accessToken and channelSecret from LINE developers websiteconstclient=newLineClient({accessToken: 'ACCESS_TOKEN',channelSecret: 'CHANNEL_SECRET',});client.pushText(userId,'Hello World').then(()=>{console.log('pushed');});
Install messaging-api-slack package from the registry:
npm i --save messaging-api-slack
or
yarn add messaging-api-slack
Then, create a SlackOAuthClient or SlackWebhookClient to call Slack APIs:
const{ SlackOAuthClient }=require('messaging-api-slack');// get access token by setup OAuth & Permissions function to your app.// https://api.slack.com/docs/oauthconstclient=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.com/services/new/incoming-webhook/constclient=newSlackWebhookClient({url: 'https://hooks.slack.com/services/XXXXXXXX/YYYYYYYY/zzzzzZZZZZ',});client.sendText('Hello World').then(()=>{console.log('sent');});
Install messaging-api-telegram package from the registry:
npm i --save messaging-api-telegram
or
yarn add messaging-api-telegram
Then, create a TelegramClient to 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');});
Install messaging-api-viber package from the registry:
npm i --save messaging-api-viber
or
yarn add messaging-api-viber
Then, create a ViberClient to 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');});