Closed iamaugustin closed 7 years ago
Okay.. I finally find the trouble I suffer from. The invalid token... Although the callback means the reply is sent successfully based on the document, this is not really true. After I print out the returned data object, I find the authentication trouble. Now, I could send the message to the user. :)
Hi, I have started to write a linebot for demo recently. However, I find I can't reply the user any message. In other words, I could receive the message from users and invoke linebot.reply successfully (Because this method will return a promise object and I could print some message after I send the message). I am not sure what's going on :S Could you please help me to give some hints or any troubles around the usage of Linebot library.
Here is the certain part of my codes related to the bot
var mLineBot = require("linebot"); var express = require("express"); var https = require("https"); var fs = require("fs");
var mBot = mLineBot({ channelId : "XXXXXXXXXXXX", channelSecret: "XXXXXXXXXXXX", channelAccessToken: "XXXXXXXXX", verify: true }); mBot.on('message', function(event){ if (event.message.type == 'text') { var msg = event.message.text; event.reply(msg).then(function(data) { console.log(msg); }).catch(function(err){ console.log("error"); }); } }); const app = express(); const lineBotParser = mBot.parser(); var options = { key: fs.readFileSync("./ssl/privatekey.pem"), cert: fs.readFileSync("./ssl/certification.pem"), ca : [ fs.readFileSync("./ssl/ca_bundle.crt","utf-8") ] } app.post("/", lineBotParser); app.get("/testpage", function(req, res){ res.send("Hello!"); });
var server = https.createServer(options, app).listen(443, function(){ console.log("Express server is running now!"); });
BTW, I run all the service on GCP.
Thanks