Messaging APIs adalah repo mono yang mengumpulkan API yang diperlukan untuk pengembangan bot.
Ini membantu Anda membangun bot menggunakan API serupa untuk berbagai platform, misalnya Messenger, LINE. Pelajari sekali dan jadikan penulisan bot lintas platform lebih mudah.
Jika Anda mencari kerangka kerja untuk membuat bot Anda, Bottender mungkin sesuai dengan kebutuhan Anda. Itu dibangun di atas Messaging API dan menyediakan beberapa fitur canggih untuk pembuatan bot.
Kemasan | Versi | Platform |
---|---|---|
messaging-api-messenger | Kurir | |
messaging-api-line | GARIS | |
messaging-api-slack | Kendur | |
messaging-api-telegram | Telegram | |
messaging-api-viber | getaran | |
messaging-api-wechat | Wechat wechat |
Instal paket messaging-api-messenger
dari registri:
npm i --save messaging-api-messenger
atau
yarn add messaging-api-messenger
Lalu, buat MessengerClient
untuk memanggil API Messenger:
const { MessengerClient } = require ( 'messaging-api-messenger' ) ;
// get accessToken from facebook developers website
const client = new MessengerClient ( {
accessToken : 'ACCESS_TOKEN' ,
} ) ;
client . sendText ( userId , 'Hello World' ) . then ( ( ) => {
console . log ( 'sent' ) ;
} ) ;
Lihat dokumentasi API lengkap untuk informasi lebih detail.
Instal paket messaging-api-line
dari registri:
npm i --save messaging-api-line
atau
yarn add messaging-api-line
Lalu, buat LineClient
untuk memanggil LINE API:
const { LineClient } = require ( 'messaging-api-line' ) ;
// get accessToken and channelSecret from LINE developers website
const client = new LineClient ( {
accessToken : 'ACCESS_TOKEN' ,
channelSecret : 'CHANNEL_SECRET' ,
} ) ;
client . pushText ( userId , 'Hello World' ) . then ( ( ) => {
console . log ( 'pushed' ) ;
} ) ;
Lihat dokumentasi API lengkap untuk informasi lebih detail.
Instal paket messaging-api-slack
dari registri:
npm i --save messaging-api-slack
atau
yarn add messaging-api-slack
Lalu, buat SlackOAuthClient
atau SlackWebhookClient
untuk memanggil API Slack:
const { SlackOAuthClient } = require ( 'messaging-api-slack' ) ;
// get access token by setup OAuth & Permissions function to your app.
// https://api.slack.com/docs/oauth
const client = new SlackOAuthClient ( {
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/
const client = new SlackWebhookClient ( {
url : 'https://hooks.slack.com/services/XXXXXXXX/YYYYYYYY/zzzzzZZZZZ' ,
} ) ;
client . sendText ( 'Hello World' ) . then ( ( ) => {
console . log ( 'sent' ) ;
} ) ;
Lihat dokumentasi API lengkap untuk informasi lebih detail.
Instal paket messaging-api-telegram
dari registri:
npm i --save messaging-api-telegram
atau
yarn add messaging-api-telegram
Lalu, buat TelegramClient
untuk memanggil API Telegram:
const { TelegramClient } = require ( 'messaging-api-telegram' ) ;
// get accessToken from telegram [@BotFather](https://telegram.me/BotFather)
const client = new TelegramClient ( {
accessToken : '12345678:AaBbCcDdwhatever' ,
} ) ;
client . sendMessage ( chatId , 'Hello World' ) . then ( ( ) => {
console . log ( 'sent' ) ;
} ) ;
Lihat dokumentasi API lengkap untuk informasi lebih detail.
Instal paket messaging-api-viber
dari registri:
npm i --save messaging-api-viber
atau
yarn add messaging-api-viber
Lalu, buat ViberClient
untuk memanggil Viber API:
const { ViberClient } = require ( 'messaging-api-viber' ) ;
// get authToken from the "edit info" screen of your Public Account.
const client = new ViberClient ( {
accessToken : 'AUTH_TOKEN' ,
sender : {
name : 'Sender' ,
} ,
} ) ;
client . sendText ( userId , 'Hello World' ) . then ( ( ) => {
console . log ( 'sent' ) ;
} ) ;
Lihat dokumentasi API lengkap untuk informasi lebih detail.
Instal paket messaging-api-wechat
dari registri:
npm i --save messaging-api-wechat
atau
yarn add messaging-api-wechat
Lalu, buat WechatClient
untuk memanggil API Wechat:
const { WechatClient } = require ( 'messaging-api-wechat' ) ;
// get appId, appSecret from「微信公众平台-开发-基本配置」page
const client = new WechatClient ( {
appId : 'APP_ID' ,
appSecret : 'APP_SECRET' ,
} ) ;
client . sendText ( userId , 'Hello World' ) . then ( ( ) => {
console . log ( 'sent' ) ;
} ) ;
Lihat dokumentasi API lengkap untuk informasi lebih detail.
Setiap rilis, beserta instruksi migrasi, didokumentasikan di file CHANGELOG.md.
MIT © Yoctol