Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple LINE@(Official Account) run on one express server #642

Open
pepper opened this issue Feb 3, 2020 · 2 comments
Open

Multiple LINE@(Official Account) run on one express server #642

pepper opened this issue Feb 3, 2020 · 2 comments
Assignees

Comments

@pepper
Copy link

pepper commented Feb 3, 2020

In the past version of bottender we can use "cross-platform-example" skill to run multiple LineBot at different express endpoint.

But now all bot config come from "root/bottender.config.js", and there just can have one "line" channel key. So we can not run multiple LineBot at one express server.

Why need this feature? If we want build a platform let customer provide their own LINE@ to bind:

https://sample.bot/say_hello/${customer_id}/line

And the bot will work according to database data query by customer_id.
Now I just can use docker or create 1000+ of cloud function to reach goals.
Any structure suggestions or right way to do?

Thanks!

Relate: #141 #415 (Messenger)

@pepper pepper changed the title Multiple LINE@(Official Account) run on same server Multiple LINE@(Official Account) run on one express server Feb 3, 2020
@chentsulin
Copy link
Collaborator

chentsulin commented Feb 5, 2020

Hi @pepper, this definitely an important use case that we want to support in Bottender. We were all set to support this use case by using destination field from LINE requests, but after a while we found that was totally useless because we can't convert the bot id to the channel id.

As far as I can tell, There is no recommended way to do this, however, we will try our best to find a solution in a few days.

@chentsulin
Copy link
Collaborator

Hi @pepper,
We have implemented a solution in v1.5.0-alpha.3 using a getConfig function:

module.exports = {
  channels: {
    line: {
      enabled: true,
      path: '/webhooks/line/:channelId',
      async getConfig({ params }) {
        console.log(params.channelId);
        // ...get the config from the API, database or wherever you like when every time receiving a new event 
        return {
          accessToken,
          channelSecret,
        };
      },
    },
  },
};

You can find the full example here: https://github.com/Yoctol/bottender/tree/release/1.5/examples/line-multiple-channels

Let me know if you have any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants