-
Notifications
You must be signed in to change notification settings - Fork 2
Retrieve client_id
osk2 edited this page Apr 10, 2021
·
1 revision
client_id
is LINE user ID or group ID
Retrieve client_id
can be tricky. We have to build a server to receive webhook request from LINE, and extract ID from it
We use Firebase Cloud Functions to reduce our pain
Create a Firebase project and enable Functions on sidebar
you may need to upgrade to Blaze plan which can cost your money, but don't worry there's free quota (2M/month)
npm install -g firebase-tools
mkdir line-webhook-receiver
cd line-webhook-receiver
firebase init
# follow the instruction to complete setup
? What language would you like to use to write Cloud Functions? **JavaScript**
? Do you want to use ESLint to catch probable bugs and enforce style? **No**
? Do you want to install dependencies with npm now? **Yes**
# inside line-webhook-receiver
vim functions/index.js
replace content of index.js
with:
const functions = require('firebase-functions');
exports.helloWorld = functions.https.onRequest((request, response) => {
const events = request.body.events
const source = events.length > 0 ? events[0].source : null;
if (source) {
functions.logger.info(source.groupId || source.userId);
}
response.send("Hello from Firebase!");
});
firebase deploy
Go to https://developers.line.biz/console/channel/<CHANNEL ID>/messaging-api
Friend bot account or invite bot to your group chat
You should be able to see client_id
in Cloud Functions log after sending some nice message to your bot
Disable LINE webhook again or your log will be flooded