Using npm
$ npm install --save push-integration
⭐ | Platform |
---|---|
Line | |
Messenger | |
const bot = require("push-integration")
const lineClient = new bot.LineClient({
id: "<Channel id>",
secret: "<Channel secret>",
token: "<Channel access token>"
}, "<Channel name>")
const clients = new bot.Client([lineClient])
import * as bot from "push-integration"
const lineClient = new bot.LineClient({
id: "<Channel id>",
secret: "<Channel secret>",
token: "<Channel access token>"
}, "<Channel name>")
const clients = new bot.Client([lineClient])
or
import { Client, LineClient, WechatClient } from "push-integration"
const lineClient = new Client({
id: "<Channel id>",
secret: "<Channel secret>",
token: "<Channel access token>"
}, "<Channel name>")
const clients = new Client([lineClient])
const wechatClient = new WechatClient(CONFIG, "<Channel name>")
clients.use(wechatClient)
const message = {
channel: "<Channel name>",
receiver: "<User id>",
message: {
type: "<Message type>",
...<Message object>
}
}
clients.send(message)
.then(result => {
console.log(JSON.stringify(result, null, 4))
/*
{
status: "ok"
}
*/
})
.catch(error => {
console.log(JSON.stringify(error, null, 4))
/*
{
status: "error",
message: "<Error message>"
}
*/
})