Git Product home page Git Product logo

line-bot-sdk-nodejs's Introduction

LINE Messaging API SDK for nodejs

Github Action npmjs

Introduction

The LINE Messaging API SDK for nodejs makes it easy to develop bots using LINE Messaging API, and you can create a sample bot within minutes.

Documentation

See the official API documentation for more information

line-bot-sdk-nodejs documentation: https://line.github.io/line-bot-sdk-nodejs/#getting-started

Requirements

  • Node.js 18 or higher

Installation

Using npm:

$ npm install @line/bot-sdk --save

Help and media

FAQ: https://developers.line.biz/en/faq/

News: https://developers.line.biz/en/news/

Versioning

This project respects semantic versioning

See http://semver.org/

Contributing

Please check CONTRIBUTING before making a contribution.

License

Copyright (C) 2016 LINE Corp.
 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
 
   http://www.apache.org/licenses/LICENSE-2.0
 
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

line-bot-sdk-nodejs's People

Contributors

4geru avatar actions-user avatar chentsulin avatar cm-nakamura-yuki avatar dependabot[bot] avatar dlackty avatar dtinth avatar gasol avatar github-actions[bot] avatar hrtk92 avatar kcvlex avatar ktomomi avatar lauslim12 avatar louis70109 avatar micksatana avatar musou1500 avatar nanato12 avatar nsuzuki7713 avatar pengoosedev avatar quentinbt avatar renovate[bot] avatar sombreroelgringo avatar taichunmin avatar tawash1 avatar tokuhirom avatar tomohirohiratsuka avatar tw0517tw avatar xingoxu avatar yang-33 avatar yunchaotsai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

line-bot-sdk-nodejs's Issues

How can i get userId who not added the bot as a friend

Hi :)
thank you for updating to 3.0.0

I have one question

in line api docs. they say

This can be the user ID of a user who has not added the bot as a friend or has blocked the bot

but how can i know userId who not added the bot as a friend?
when I logged event, not added the bot as a friend users don't return userId. (only return groupId or roomId)

this function should be use with Get group/room member IDs?
if so, I think Get group/room member profile also should have Info like Get group/room member IDs in line api docs

Info mean this message

This feature is only available for LINE@ Approved accounts or official accounts.

How to setup echo bot

Hello, Can you please kindly explain how can I make echo test bot run? I made index.js in which I wrote the code for echo and in config I have defined my secret and key. I deployed that to heroku but bot didn't work and messages were sent normally like chat to bot.

[error] npm run build No matching files. Patterns tried: '{lib,test}/**/*.ts' !**/node_modules/** !./node_modules/**

npm ERR! Windows_NT 6.2.9200
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\xampp\htdocs\line-bot-sdk-n
run" "prettier" "--" "-l"
npm ERR! node v9.0.0
npm ERR! npm v3.7.5
npm ERR! code ELIFECYCLE
npm ERR! @line/[email protected] prettier: `prettier --parser typescript --trailing-comma
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @line/[email protected] prettier script 'prettier --parser typescri
"-l"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the @line/bot-sdk package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! prettier --parser typescript --trailing-comma all '{lib,test}/**/*.ts' "-
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs @line/bot-sdk
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls @line/bot-sdk
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\xampp\htdocs\line-bot-sdk-nodejs\npm-debug.log

npm ERR! Windows_NT 6.2.9200
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\xampp\htdocs\line-bot-sdk-n
run" "format:check"
npm ERR! node v9.0.0
npm ERR! npm v3.7.5
npm ERR! code ELIFECYCLE
npm ERR! @line/[email protected] format:check: npm run prettier -- -l
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @line/[email protected] format:check script 'npm run prettier -- -l
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the @line/bot-sdk package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run prettier -- -l
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs @line/bot-sdk
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls @line/bot-sdk
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\xampp\htdocs\line-bot-sdk-nodejs\npm-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @line/[email protected] prebuild: npm run format:check && npm run clean
npm ERR! Exit status 1
npm ERR!
npm-debug.log

Error Code 401 when sending emoji message to bot

Hello LINE,

I'm using the code from the example to validating message from user.
But when I'm trying to send message which contains emoji, the webhook always return 401.

I have trying several changes in code for validating message but when sending emoji like this (🏁) the webhook still return 401.

Here is the code that I'm using right now, I'm using jsesc package to escape emoji

image

Thanks. 😄

How to solve the problem if we don't find sub menu "Bot Settings"?

I have some one issue with web LINE@ Manager.
When I try to add the existing line account but I don't see sub menu "Bot Settings"
Do you have the way to solve this issue? I notice that new account which has been created from web LINE@ Manager I can see this sub menu.

Created from web
Create by Web

Existing Account
Existing Account

Thank you in advance.

UnhandledPromiseRejectionWarning: Unhandled promise rejection

Hi, I have tried using the echo-bot example, and then get error

"UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: Request failed with status code 400"

When click verify button. I have set up the channelAccessToken and channelSecret, do I miss something?

User language / localisation API?

Hi,

Quick question: As LINE is used internationally, is there any way to get a user's preferred language / localisation from the API? Or do I need to have some kind of dialogue where my bot asks a user, which language he/she would like to interact with?

Thanks,
@gfmio

Is it possible to use the Messaging API in order to control the 1: 1 chat feature supported by LINE @ App?

I would like to switch to LINE@App 1-on-1 chat mode, only when the customer requests (input keyword or enter Event in RichMenu or Button Template).
Because 1: 1 chat mode does not respond automatically.
Can this be implemented with the Messaging API?

ps.
LINE @ Enable Messaging API Settings in App Manager

Enabling the API is a permanent action and you will not be able to use the features listed below.
• 1-on-1 Chat
• LINE @ App

If I use the Messaging API, will I be unable to work with LINE @ App?

Https request instead of http request

There is http request in echo bot and line need https request.
so how to convert this http to https?

app.post('/webhook', line.middleware(config), (req, res) => {
  Promise
    .all(req.body.events.map(handleEvent))
    .then((result) => res.json(result));
});

'rm' is not recognized as an internal or external command, operable program or batch file.

I am following the guide on this website. https://line.github.io/line-bot-sdk-nodejs/pages/getting-started/install.html
When I get to this step:

c:\line-bot-sdk-nodejs>npm run build

This is what follows:

@line/[email protected] prebuild c:\line-bot-sdk-nodejs
npm run lint && npm run clean

@line/[email protected] lint c:\line-bot-sdk-nodejs
tslint '{lib,test}/**/*.ts'

@line/[email protected] clean c:\line-bot-sdk-nodejs
rm -rf dist

'rm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @line/[email protected] clean: rm -rf dist
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @line/[email protected] clean script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\justin\AppData\Roaming\npm-cache_logs\2017-07-12T10_15_07_639Z-debug.log

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "build"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @line/[email protected] prebuild: npm run lint && npm run clean
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @line/[email protected] prebuild script 'npm run lint && npm run clean'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the @line/bot-sdk package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run lint && npm run clean
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs @line/bot-sdk
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls @line/bot-sdk
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! c:\line-bot-sdk-nodejs\npm-debug.log

I see no file in c:\line-bot-sdk-nodejs...named npm-debug.log

Im running on windows 10 with 64 bit

Please be kind enough to help with this issue as I am just beginning to learn how to use node.js and i have performed hours of searches with answers telling me to change paths and change parts of the scripts and and other various solutions that i am not sure will even solve the issue. I don't want to end up digging myself into a deeper hole by messing with things like env variables if that is not the problem. Thank you very much for your time and consideration.

Returning two answers for one message event

Can we return two answer for one message event?
like in echo bot example it is like

const echo = { type: 'text', text: event.message.text };
return client.replyMessage(event.replyToken, echo);

But can we return two answers and is there any way for this?

const echo = { type: 'text', text: event.message.text };
const echo1 = { type: 'text', text: event.message.text };

return (client.replyMessage(event.replyToken, echo, client.replyMessage(event.replyToken, echo1));

GetProfile from not friend

Hello,
How to using getProfile to identify not friend user by using their userId. Is it possible to do that ?

kitchensink can't run when reply image message,but reply text message is ok

The code runs on my own nodejs server

Error: Request failed with status code 400 when reply image message.

[root@dft-lab5 line]# node line.js
listening on 3000
downloadPath: /home/260im/line/downloaded/8176050397203.jpg
{ Error: Request failed with status code 400
at wrapError (/home/260im/line/node_modules/@line/bot-sdk/dist/http.js:10:15)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
statusCode: 400,
statusMessage: 'Bad Request',
originalError:
{ Error: Request failed with status code 400
at createError (/home/260im/line/node_modules/@line/bot-sdk/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/260im/line/node_modules/@line/bot-sdk/node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (/home/260im/line/node_modules/@line/bot-sdk/node_modules/axios/lib/adapters/http.js:191:11)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
config:
{ adapter: [Function: httpAdapter],
transformRequest: [Object],
transformResponse: [Object],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
headers: [Object],
method: 'post',
url: 'https://api.line.me/v2/bot/message/reply',
data: '{"messages":[{"type":"image","originalContentUrl":"/home/260im/line/downloaded/8176050397203.jpg","previewImageUrl":"/home/260im/line/downloaded/8176050397203.jpg"}],"replyToken":"db9227714g3ercdf402ca1cbe24f1b702065"}' },
request:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Object],
connection: [Object],
_header: 'POST /v2/bot/message/reply HTTP/1.1\r\nAccept: application/json, text/plain, /\r\nContent-Type: application/json\r\nAuthorization: Bearer Tvys+4/cXSwidwlogmK9hZSruhRefkyEwUuoRm3sIUFf1ywzyPFV/LcxqkKkJwmpRW7XKvz8c1Cyt1KyF00GSmYzCeGo54sOfVaFCwtgwHyUQ77TNm3rgYnM1PZvPwQTfu5QMLuB/y/9aNUOYDfj3wdB04t89/1O/w1cDnyilFU=\r\nUser-Agent: @line/bot-sdk/6.1.0\r\nContent-Length: 214\r\nHost: api.line.me\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'POST',
path: '/v2/bot/message/reply',
_ended: true,
res: [Object],
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
_redirectable: [Object],
[Symbol(outHeadersKey)]: [Object] },
response:
{ status: 400,
statusText: 'Bad Request',
headers: [Object],
config: [Object],
request: [Object],
data: [Object] } } }

===== the source code ========

function downloadContent(messageId) {
const downloadPath = path.join(rootPath, 'downloaded', ${messageId}.jpg);

return client.getMessageContent(messageId)
.then((stream) => new Promise((resolve, reject) => {
const writable = fs.createWriteStream(downloadPath);
stream.pipe(writable);
stream.on('end', () => resolve(downloadPath));
stream.on('error', reject);
}));
};

function handleImage(message, replyToken,source) {

return downloadContent(message.id)
.then((downloadPath) => {
// ImageMagick is needed here to run 'convert'
// Please consider about security and performance by yourself
// cp.execSync(convert -resize 240x jpeg:${downloadPath} jpeg:${previewPath});
//
console.log("downloadPath:",downloadPath);
return client.replyMessage(
replyToken,
{
type : 'image',
originalContentUrl: rootPath + '/downloaded/' + path.basename(downloadPath),
previewImageUrl : rootPath + '/downloaded/' + path.basename(downloadPath),
}
);

});

}

Sending GIF?

Currently, when sending GIFs in a image message, the image is shown stabilized (i.e. Doesn't move). I know this is probably not the right place to inquire about a Line API specification, but is there any possibility of this feature getting supported?

I use Microsoft BotBuilder + my custom converter.

Bad request with examples

Hi,

When I try your basics examples I get a Bad Request every time I try to verify my webhook from the console.

I just c/p your code and deploy it on heroku

TypeError: Data must be a string or a buffer

I am using line-bot-sdk on Google Firebase (cloud function).
The function was successfully deployed and received a webhook event but it throw error.

TypeError: Data must be a string or a buffer.

It appears to be from the "Crypto" in validateSignature function, which is called from "middleware.ts".
I didn't do any manual signature validation while testing.
Please help.

Why should not I use body-parser?

I found it in documentation.

Do not use another body-parser before the webhook middleware()

I think the explanation is confusing because express don't have any responsibility for parse it.
express documentation says

Contains key-value pairs of data submitted in the request body. By default, it is undefined, and is populated when you use body-parsing middleware such as body-parser and multer.

Actually, you use it in test-server, don't you?
https://github.com/line/line-bot-sdk-nodejs/blob/master/test/helpers/test-server.ts#L13

Can I Invite another Bot in chat room or Create Chat room by using Message API?

Hello, Can I Invite another Bot in chat room or Create Chat room by using Message API?

I want to know whether the following situation can be made to be available by using Messaging API.
Situation : When the chatbot A is in the chat room with me. So there are two in chat room.
Case 1. I want to invite another chatbot B in our chat room by using replyMessage.
Case 2. I want to join another chat room with chatbot C. By using replyMessage, can I create another chat room with chatbot C and me together ?

421756903:AAG_AghlDGDJx5zbwpbe0vtCC1YSochj1

Do this before creating an issue

  • Check the FAQ for LINE bots
  • Make sure your issue is related to the LINE Bot SDK. For general questions or issues about LINE bots, create an issue on the FAQ repository. Note that we don't provide technical support.

When creating an issue

  • Provide detailed information about the issue you had with the SDK
  • Provide logs if possible

Echobot test via GET method

when I using php, i test push message via GET method `https://localhost:8000/callback and return success

$app->get('/callback', function (\Slim\Http\Request $req, \Slim\Http\Response $res, $args) {
            /**
             * @var \LINE\LINEBot
             */
            $bot = $this->get('bot');

            $textMessageBuilder = new \LINE\LINEBot\MessageBuilder\TextMessageBuilder('ping pong');

            $response = $bot->pushMessage(getenv('USERID'), $textMessageBuilder);
            if ($response->isSucceeded()) {
                echo 'Succeeded!';

                return;
            }
            // Failed
            echo $response->getHTTPStatus() . ' ' . $response->getRawBody();

now, i want to test using nodejs via GET, how to implement get method to push message. My code

app.get('/callback', line.middleware(config), (req, res) => {
    
    Promise
    .all(req.body.events.map(handleEvent))
    .then((result) => res.json(result));  
});

result is

Error: no signature
    at T:\Tutorial\NodeJS\line_nodejs\node_modules\@line\bot-sdk\dist\middleware.js:16:18

Echo bot - Request failed with status code 400

Hi,
I deployed the example - Echo bot on AWS EC2, but I could not verify the Webhook URL.
I cloned this repo, cd to the echo bot, installed deps, and did the three configuration, CHANNEL_SECRET, CHANNEL_ACCESS_TOKEN and PORT(8080). My Webhook URL is https. Is there anything that I need to configure in order to run the echo bot?

The error message is as below.

{ Error: Request failed with status code 400
at wrapError (/home/ubuntu/line-bot-sdk-nodejs/examples/echo-bot/node_modules/@line/bot-sdk/dist/http.js:10:15)
at
at process._tickCallback (internal/process/next_tick.js:160:7)
statusCode: 400,
statusMessage: '',
originalError:
{ Error: Request failed with status code 400
at createError (/home/ubuntu/line-bot-sdk-nodejs/examples/echo-bot/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/ubuntu/line-bot-sdk-nodejs/examples/echo-bot/node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (/home/ubuntu/line-bot-sdk-nodejs/examples/echo-bot/node_modules/axios/lib/adapters/http.js:191:11)
at IncomingMessage.emit (events.js:165:20)
at endReadableNT (_stream_readable.js:1101:12)
at process._tickCallback (internal/process/next_tick.js:152:19)
config:
{ adapter: [Function: httpAdapter],
transformRequest: [Object],
transformResponse: [Object],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
headers: [Object],
method: 'post',
url: 'https://api.line.me/v2/bot/message/reply',
data: '{"messages":[{"type":"text","text":"Hello, world"}],"replyToken":"00000000000000000000000000000000"}' },
request:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [TLSSocket],
connection: [TLSSocket],
_header: 'POST /v2/bot/message/reply HTTP/1.1\r\nAccept: application/json, text/plain, /\r\nContent-Type: application/json\r\nAuthorization: Bearer p9XQZY+h1w8Qg98tOnsRIw+nrEWw9bESZ6CV+z2+eJl6ivRzat+PP7ZgVGmRXjLoP5KjRCYxN0AySIVP5yvE8T5hknQTgyIroQ3b0MDxu/WryATVeduMJw/dtaAflzFvl7rbrQsvKeeA1MfX+ez0IAdB04t89/1O/w1cDnyilFU=\r\nUser-Agent: @line/bot-sdk/5.2.0\r\nContent-Length: 100\r\nHost: api.line.me\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
timeout: undefined,
method: 'POST',
path: '/v2/bot/message/reply',
_ended: true,
res: [IncomingMessage],
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
_redirectable: [Writable],
[Symbol(outHeadersKey)]: [Object] },
response:
{ status: 400,
statusText: '',
headers: [Object],
config: [Object],
request: [ClientRequest],
data: [Object] } } }

about richMeun uploadImage statusCode 411

it's image about log
https://imgur.com/a/jBeit
{ Error: Request failed with status code 411 2017-12-08T06:25:58.690170+00:00 app[web.1]: at wrapError (/app/node_modules/@line/bot-sdk/dist/http.js:11:15) 2017-12-08T06:25:58.690171+00:00 app[web.1]: at <anonymous> 2017-12-08T06:25:58.690172+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:188:7) 2017-12-08T06:25:58.690172+00:00 app[web.1]: statusCode: 411, 2017-12-08T06:25:58.690173+00:00 app[web.1]: statusMessage: 'Length Required', 2017-12-08T06:25:58.690173+00:00 app[web.1]: originalError: 2017-12-08T06:25:58.690173+00:00 app[web.1]: { Error: Request failed with status code 411 2017-12-08T06:25:58.690174+00:00 app[web.1]: at createError (/app/node_modules/axios/lib/core/createError.js:16:15) 2017-12-08T06:25:58.690174+00:00 app[web.1]: at settle (/app/node_modules/axios/lib/core/settle.js:18:12) 2017-12-08T06:25:58.690175+00:00 app[web.1]: at IncomingMessage.handleStreamEnd (/app/node_modules/axios/lib/adapters/http.js:191:11) 2017-12-08T06:25:58.690176+00:00 app[web.1]: at emitNone (events.js:111:20) 2017-12-08T06:25:58.690176+00:00 app[web.1]: at IncomingMessage.emit (events.js:208:7) 2017-12-08T06:25:58.690177+00:00 app[web.1]: at endReadableNT (_stream_readable.js:1056:12) 2017-12-08T06:25:58.690177+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:138:11) 2017-12-08T06:25:58.690178+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:180:9) 2017-12-08T06:25:58.690179+00:00 app[web.1]: config: 2017-12-08T06:25:58.690179+00:00 app[web.1]: { adapter: [Function: httpAdapter], 2017-12-08T06:25:58.690183+00:00 app[web.1]: transformRequest: [Object], 2017-12-08T06:25:58.690183+00:00 app[web.1]: transformResponse: [Object], 2017-12-08T06:25:58.690184+00:00 app[web.1]: timeout: 0, 2017-12-08T06:25:58.690184+00:00 app[web.1]: xsrfCookieName: 'XSRF-TOKEN', 2017-12-08T06:25:58.690185+00:00 app[web.1]: xsrfHeaderName: 'X-XSRF-TOKEN', 2017-12-08T06:25:58.690185+00:00 app[web.1]: maxContentLength: -1, 2017-12-08T06:25:58.690185+00:00 app[web.1]: validateStatus: [Function: validateStatus], 2017-12-08T06:25:58.690186+00:00 app[web.1]: headers: [Object], 2017-12-08T06:25:58.690186+00:00 app[web.1]: method: 'post', 2017-12-08T06:25:58.690187+00:00 app[web.1]: url: 'https://api.line.me/v2/bot/richmenu/richmenu-1580e0ba6b867071e2d04f8437774a15/content', 2017-12-08T06:25:58.690187+00:00 app[web.1]: data: [Object] }, 2017-12-08T06:25:58.690188+00:00 app[web.1]: request: 2017-12-08T06:25:58.690188+00:00 app[web.1]: ClientRequest { 2017-12-08T06:25:58.690188+00:00 app[web.1]: domain: null, 2017-12-08T06:25:58.690189+00:00 app[web.1]: _events: [Object], 2017-12-08T06:25:58.690189+00:00 app[web.1]: _eventsCount: 5, 2017-12-08T06:25:58.690190+00:00 app[web.1]: _maxListeners: undefined, 2017-12-08T06:25:58.690190+00:00 app[web.1]: output: [], 2017-12-08T06:25:58.690190+00:00 app[web.1]: outputEncodings: [], 2017-12-08T06:25:58.690191+00:00 app[web.1]: outputCallbacks: [], 2017-12-08T06:25:58.690191+00:00 app[web.1]: outputSize: 0, 2017-12-08T06:25:58.690191+00:00 app[web.1]: writable: true, 2017-12-08T06:25:58.690192+00:00 app[web.1]: _last: true, 2017-12-08T06:25:58.690192+00:00 app[web.1]: upgrading: false, 2017-12-08T06:25:58.690192+00:00 app[web.1]: chunkedEncoding: true, 2017-12-08T06:25:58.690193+00:00 app[web.1]: shouldKeepAlive: false, 2017-12-08T06:25:58.690193+00:00 app[web.1]: useChunkedEncodingByDefault: true, 2017-12-08T06:25:58.690193+00:00 app[web.1]: sendDate: false, 2017-12-08T06:25:58.690193+00:00 app[web.1]: _removedConnection: false, 2017-12-08T06:25:58.690194+00:00 app[web.1]: _removedContLen: false, 2017-12-08T06:25:58.690194+00:00 app[web.1]: _removedTE: false, 2017-12-08T06:25:58.690194+00:00 app[web.1]: _contentLength: null, 2017-12-08T06:25:58.690195+00:00 app[web.1]: _hasBody: true, 2017-12-08T06:25:58.690195+00:00 app[web.1]: _trailer: '', 2017-12-08T06:25:58.690195+00:00 app[web.1]: finished: true, 2017-12-08T06:25:58.690196+00:00 app[web.1]: _headerSent: true, 2017-12-08T06:25:58.690196+00:00 app[web.1]: socket: [Object], 2017-12-08T06:25:58.690196+00:00 app[web.1]: connection: [Object], 2017-12-08T06:25:58.690197+00:00 app[web.1]: _header: 'POST /v2/bot/richmenu/richmenu-1580e0ba6b867071e2d04f8437774a15/content HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: image/png\r\nAuthorization: Bearer pgU+ORe6VMoKzyq77792rhM7SL9InUpAnczYcaDuycpao+6NTQa18DhI26G7uc6gSrSFgQJ2sPVgsQDZBdAq/TrCSG0yvxIjnH6oVkYpYK+CitVnSBZ1Yj8yX4PDGZZ0HraClufefNbh0ZTRRedYmwdB04t89/1O/w1cDnyilFU=\r\nUser-Agent: @line/bot-sdk/5.0.1\r\nHost: api.line.me\r\nConnection: close\r\nTransfer-Encoding: chunked\r\n\r\n', 2017-12-08T06:25:58.690198+00:00 app[web.1]: _onPendingData: [Function: noopPendingOutput], 2017-12-08T06:25:58.690198+00:00 app[web.1]: agent: [Object], 2017-12-08T06:25:58.690198+00:00 app[web.1]: socketPath: undefined, 2017-12-08T06:25:58.690199+00:00 app[web.1]: timeout: undefined, 2017-12-08T06:25:58.690199+00:00 app[web.1]: method: 'POST', 2017-12-08T06:25:58.690199+00:00 app[web.1]: path: '/v2/bot/richmenu/richmenu-1580e0ba6b867071e2d04f8437774a15/content', 2017-12-08T06:25:58.690200+00:00 app[web.1]: _ended: true, 2017-12-08T06:25:58.690200+00:00 app[web.1]: res: [Object], 2017-12-08T06:25:58.690200+00:00 app[web.1]: aborted: undefined, 2017-12-08T06:25:58.690201+00:00 app[web.1]: timeoutCb: null, 2017-12-08T06:25:58.690201+00:00 app[web.1]: upgradeOrConnect: false, 2017-12-08T06:25:58.690201+00:00 app[web.1]: parser: null, 2017-12-08T06:25:58.690202+00:00 app[web.1]: maxHeadersCount: null, 2017-12-08T06:25:58.690202+00:00 app[web.1]: _redirectable: [Object], 2017-12-08T06:25:58.690202+00:00 app[web.1]: [Symbol(outHeadersKey)]: [Object] }, 2017-12-08T06:25:58.690203+00:00 app[web.1]: response: 2017-12-08T06:25:58.690203+00:00 app[web.1]: { status: 411, 2017-12-08T06:25:58.690204+00:00 app[web.1]: statusText: 'Length Required', 2017-12-08T06:25:58.690204+00:00 app[web.1]: headers: [Object], 2017-12-08T06:25:58.690204+00:00 app[web.1]: config: [Object], 2017-12-08T06:25:58.690204+00:00 app[web.1]: request: [Object], 2017-12-08T06:25:58.690205+00:00 app[web.1]: data: '<HTML><HEAD>\n<TITLE>Bad Request</TITLE>\n</HEAD><BODY>\n<H1>Bad Request</H1>\nYour browser sent a request that this server could not understand.<P>\nReference&#32;&#35;7&#46;eee13217&#46;1512714358&#46;1def6d09\n</BODY>\n</HTML>\n' } } }
it's code
it's image about code
https://imgur.com/a/7sylD
return createMenu().then((richMenuId) => { console.log('user: '+source.userId) console.log('richMenu: '+richMenuId) return client.setRichMenuImage(richMenuId,fs.createReadStream('./static/rich/controller_01.png')) })

it's controller_01.png
https://imgur.com/a/CFjEg

I don't know why it say "Length Required"
how can I fix it
and thank you last time help

Is there any function in Messaging API that I can send a push message which is about chat message update?

Hello, I have some questions about the function of Messaging API

After successful build by pushing new code to Heroku server,
I want to send a sentence like "New Version Updated" to the Chat Bot in all chat rooms.

However, as I look at the Webhook Event list in the Messaging API, there is no event whether the chat bot is started or not.

I would be grateful if you could give me an advice or sample codes.

How FileEventMessage works

I want to handle for FileEventMessage, but apparently FileEventMessage is not in union of EventMessage? Is this a bug or there's someway to do this?

Webhook working but on verifying with line it sends **A http status of the response was '404 Not Found'.**

https://susi-linebot.herokuapp.com/
Here is the webhook link.

Kindly see this i will be very thankful if I can understand this

// create LINE SDK client
const client = new line.Client(config);

// create Express app
// about Express itself: https://expressjs.com/
const app = express();

app.get('/',function(req, res){
res.writeHead(200);
res.write('Hi User');
res.end();
});
// register a webhook handler with middleware
// about the middleware, please refer to doc
app.post('https://susi-linebot.herokuapp.com/callback', line.middleware(config), (req, res) => {
Promise
.all(req.body.events.map(handleEvent))
.then((result) => res.json(result));
});

// event handler
function handleEvent(event) {
if (event.type !== 'message' || event.message.type !== 'text') {
// ignore non-text-message event
return Promise.resolve(null);
}

// create a echoing text message
const echo = { type: 'text', text: event.message.text };

// use reply API
return client.replyMessage(event.replyToken, echo);
}

// listen on port
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(listening on ${port});
});

Method unlinkRichMenuFromUser receive error "The request method, 'DELETE', is not supported"

Error Log:
(I remove token, user Id and richmenu Id)

{ Error: Request failed with status code 405
at HTTPError (/var/task/node_modules/@line/bot-sdk/dist/exceptions.js:34:9)
at wrapError (/var/task/node_modules/@line/bot-sdk/dist/http.js:10:15)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
statusCode: 405,
statusMessage: '',
originalError:
{ Error: Request failed with status code 405
at createError (/var/task/node_modules/axios/lib/core/createError.js:16:15)
at settle (/var/task/node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (/var/task/node_modules/axios/lib/adapters/http.js:191:11)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
config:
{ adapter: [Function: httpAdapter],
transformRequest: [Object],
transformResponse: [Object],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
headers: [Object],
method: 'delete',
url: 'https://api.line.me/v2/bot/user/xxxxxxxxxxxxxxxxxxxxxxxx/richmenu/richmenu-xxxxxxxxxxxxxxxxxxxxxxxx',
data: undefined },
request:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedHeader: {},
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Object],
connection: [Object],
_header: 'DELETE /v2/bot/user/xxxxxxxxxxxxxxxxxxxxxxxx/richmenu/richmenu-xxxxxxxxxxxxxxxxxxxxxxxx HTTP/1.1\r\nAccept: application/json, text/plain, /\r\nAuthorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx=\r\nUser-Agent: @line/bot-sdk/5.2.0\r\nHost: api.line.me\r\nConnection: close\r\n\r\n',
_headers: [Object],
_headerNames: [Object],
_onPendingData: null,
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'DELETE',
path: '/v2/bot/user/xxxxxxxxxxxxxxxxxxxxxxxx/richmenu/richmenu-xxxxxxxxxxxxxxxxxxxxxxxx',
_ended: true,
_redirectable: [Object],
parser: null,
res: [Object] },
response:
{ status: 405,
statusText: '',
headers: [Object],
config: [Object],
request: [Object],
data: [Object] } } }

In response data:

{ message: 'The request method, 'DELETE', is not supported' }

Handle body when it's already parsed

Moved from #5

The problem is that we really do not know how req.body has been parsed by just checking its type (e.g. Firebase Cloud Functions). It's straight forward when its type is string, but things go difficult when it's an object. Calling .toString() cannot be a silver bullet as we do not know how it's implemented. If it results in a different string from the original request body, the validation process will silently fail which I do not want to happen.

I will first make it work with a string and a buffer, and look into how an object can be handled. Any idea is welcomed.

How to receive location and image type response.

when I tried receiving location via response it didn't send location I did it in this way.

const answer = {
type: "location",
title: string,
address: string,
latitude: number,
longitude: number,
}

return client.replyMessage(event.replyToken, answer);

Kindly guide.

Kitchensink

Would you please add sample bot for Kitchensink? Seems there is no Kitchensink bot for Node.js. Thanks.

Can't build from source

Dear Line official,

I want to modify your bot client to extend some functionality. Since then, I tried to build your sdk from source by running these commands :

git clone https://github.com/line/line-bot-sdk-nodejs
cd line-bot-sdk-nodejs
npm install
npm run build

However, I got some error message like this :

> @line/[email protected] prebuild /home/fawwaz.muhammad/personal/line-bot-sdk-nodejs
> npm run lint && npm run clean


> @line/[email protected] lint /home/fawwaz.muhammad/personal/line-bot-sdk-nodejs
> tslint '{lib,test}/**/*.ts'


ERROR: lib/client.ts[19, 7]: The key 'messages' is not sorted alphabetically
ERROR: lib/client.ts[26, 7]: The key 'messages' is not sorted alphabetically
ERROR: lib/client.ts[33, 7]: The key 'messages' is not sorted alphabetically


npm ERR! Linux 4.4.0-79-generic
npm ERR! argv "/usr/bin/nodejs" "/home/fawwaz.muhammad/personal/line-bot-sdk-nodejs/node_modules/.bin/npm" "run" "lint"
npm ERR! node v4.8.2
npm ERR! npm  v3.7.5
npm ERR! code ELIFECYCLE
npm ERR! @line/[email protected] lint: `tslint '{lib,test}/**/*.ts'`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @line/[email protected] lint script 'tslint '{lib,test}/**/*.ts''.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the @line/bot-sdk package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tslint '{lib,test}/**/*.ts'
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs @line/bot-sdk
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls @line/bot-sdk
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/fawwaz.muhammad/personal/line-bot-sdk-nodejs/npm-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @line/[email protected] prebuild: `npm run lint && npm run clean`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @line/[email protected] prebuild script 'npm run lint && npm run clean'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the @line/bot-sdk package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run lint && npm run clean
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs @line/bot-sdk
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls @line/bot-sdk
npm ERR! There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/fawwaz.muhammad/.npm/_logs/2017-06-15T16_08_55_129Z-debug.log

I checked my node version and it satisfy your requirement

node --version
v 4.8.2

What should I do ?

Deprecated 'native-or-bluebird' in should use 'any-promise' instead

After installation,

npm WARN deprecated [email protected]: 'native-or-bluebird' is deprecated. Please use 'any-promise' instead.

I checked in package-lock.json the node module get-audio-duration using mz which using native-or-bluebird and causes this warning. It'd be nice to remove the deprecated code. Either wait for a fix from mz and get-audio-duration node modules or change the way to get audio duration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.