0.14.0 • Published 1 year ago

cf-chat-bridge v0.14.0

Weekly downloads
5
License
MIT
Repository
github
Last release
1 year ago

Chat Bridge by Google Cloud Functions

Latest Stable Version CI codecov

Framework for Google Cloud Functions to bridge communications in chat services, such as

  • LINE -> Slack
  • Slack -> LINE

Example of your index.js

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

Example rules

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",
      },
    ]
  },
]

Variables you might need

secret.json, like this

{
  "LINE": {
    "CHANNEL_SECRET": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "CHANNEL_ACCESS_TOKEN": "xxxxxxxxxxxxxxxxxxxxxxxx",
  },
  "SLACK": {
    "APP_VERIFICATION_TOKEN": "xxxxxxxxxxxxxxxxxxxxx",
    "APP_OAUTH_ACCESS_TOKEN": "xoxp-xxxxxxxxxxxxxxxxxx"
  }
}

See https://github.com/otiai10/cf-chat-bridge/wiki/Getting-Started for more information about getting started.

How to deploy your index.js to Google Cloud Functions

gcloud functions deploy foobar --trigger-http

See links below for more information

0.14.0

1 year ago

0.11.0

3 years ago

0.12.0

3 years ago

0.10.0

3 years ago

0.9.0

3 years ago

0.8.0

3 years ago

0.7.0

3 years ago

0.6.2

3 years ago

0.5.3

3 years ago

0.6.4

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.25

6 years ago

0.2.24

6 years ago

0.2.21

6 years ago

0.2.20

6 years ago

0.2.19

6 years ago

0.2.18

6 years ago

0.2.17

6 years ago

0.2.16

6 years ago

0.2.15

6 years ago

0.2.14

6 years ago

0.2.12

6 years ago

0.2.11

6 years ago

0.2.10

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago