Framework for Google Cloud Functions to bridge communications in chat services, such as
- LINE -> Slack
- Slack -> LINE
const { Bridge } = require("cf-chat-bridge");
// Your secret variables, see following for more details.
const secrets = require("./your/secrets");
// Your rules to bridge messages, see following for more details.
const rules = require("./your/rules");
// Initialize your bridge.
const bridge = new Bridge({rules, secrets});
// Export your endpoint as a member of module,
// so that Google CloudFunctions can listen /foobar as an endpoint.
exports.foobar = bridge.endpoint();
// Then you can use following endpoints for Slack & LINE webhooks:
// - Slack: /foobar?source=SLACK
// - LINE: /foobar?source=LINE
module.exports = [
/**
* ONE-WAY bridge: LINE group → SLACK channel(s)
*/
{
// From any groups of LINE in which the bot is a member
source: {
service: "LINE",
group: /.*/
},
// To "random" channel of Slack in which the bot is a member
destination: {
service: "Slack",
channels: ["random"]
}
},
/**
* ONE-WAY bridge: Slack channel → LINE group(s)
*/
{
source: {
service: "Slack",
channel: "dev-test"
},
destination: {
service: "LINE",
to: ["C3a08fbcbd1c7c3dc4c68d42fb46bd112"],
},
},
/**
* BOTH-WAY bridge: LINE group ↔ SLACK channel
*/
{
pipe: [
{
service: "LINE",
group: "C3a08fbcbd1c7c3dc4c68d42fb46bd112",
},
{
service: "SLACK",
channel: "general",
},
]
},
]
secret.json
, like this
{
"LINE_CHANNEL_SECRET": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"LINE_CHANNEL_ACCESS_TOKEN": "xxxxxxxxxxxxxxxxxxxxxxxx",
"SLACK_APP_VERIFICATION_TOKEN": "xxxxxxxxxxxxxxxxxxxxx",
"SLACK_APP_OAUTH_ACCESS_TOKEN": "xoxp-xxxxxxxxxxxxxxxxxx"
}
LINE_CHANNEL_SECRET
- Secret key to verify request triggered from LINE webhook
- Created when you create
a channel
on https://developers.line.me/console/
LINE_CHANNEL_ACCESS_TOKEN
- Access token to send message to LINE
- Created when you create
a channel
on https://developers.line.me/console/
SLACK_APP_VERIFICATION_TOKEN
- Secret key to verify request triggered from Slack webhook
- Created when you create
an app
on https://api.slack.com/apps- and enable Events API
SLACK_APP_OAUTH_ACCESS_TOKEN
- Access token to send message to Slack
- Created when you create
an app
on https://api.slack.com/apps- and install the app to your workspace
See https://github.com/otiai10/cf-chat-bridge/wiki/Getting-Started for more information about getting started.
gcloud functions deploy foobar --trigger-http
See links below for more information