Error: PayloadTooLargeError: request entity too large in BotKit

Some users have reported they faced issues in botkit.

Error: PayloadTooLargeError: request entity too large
at readStream (/data/kore/Botkitsdk/node_modules/raw-body/index.js:155:17)
at getRawBody (/data/kore/Botkitsdk/node_modules/raw-body/index.js:108:12)
at read (/data/kore/Botkitsdk/node_modules/body-parser/lib/read.js:77:3)
at jsonParser (/data/kore/Botkitsdk/node_modules/body-parser/lib/types/json.js:135:5)
at bodyParser (/data/kore/Botkitsdk/node_modules/body-parser/index.js:109:5)
at Layer.handle [as handle_request] (/data/kore/Botkitsdk/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/data/kore/Botkitsdk/node_modules/express/lib/router/index.js:317:13)
at /data/kore/Botkitsdk/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/data/kore/Botkitsdk/node_modules/express/lib/router/index.js:335:12)
at next (/data/kore/Botkitsdk/node_modules/express/lib/router/index.js:275:10)
at expressInit (/data/kore/Botkitsdk/node_modules/express/lib/middleware/init.js:40:5)
at Layer.

The botkit can help accommodate higher payloads. You will need to go to the lib\app\index.js
Update the Application funciton to something like below:

function Application( expressapp , config ){ this.app = expressapp || express(); this.app.use(bodyparser.json({limit: '50mb'})); this.app.use(bodyparser.urlencoded({limit: '50mb', extended: true})); this.config = config; }

Apart from this, you may also need to check if your forward and/or reverse proxy like Nginix has any limitation in the payload.

1 Like