{"action":"opened","issue":{"url":"https://api.github.com/repos/howdyai/botkit/issues/1446","repository_url":"https://api.github.com/repos/howdyai/botkit","labels_url":"https://api.github.com/repos/howdyai/botkit/issues/1446/labels{/name}","comments_url":"https://api.github.com/repos/howdyai/botkit/issues/1446/comments","events_url":"https://api.github.com/repos/howdyai/botkit/issues/1446/events","html_url":"https://github.com/howdyai/botkit/issues/1446","id":351122149,"node_id":"MDU6SXNzdWUzNTExMjIxNDk=","number":1446,"title":"Problem with middleware and socketBot","user":{"login":"hvaneylen","id":21175866,"node_id":"MDQ6VXNlcjIxMTc1ODY2","avatar_url":"https://avatars2.githubusercontent.com/u/21175866?v=4","gravatar_id":"","url":"https://api.github.com/users/hvaneylen","html_url":"https://github.com/hvaneylen","followers_url":"https://api.github.com/users/hvaneylen/followers","following_url":"https://api.github.com/users/hvaneylen/following{/other_user}","gists_url":"https://api.github.com/users/hvaneylen/gists{/gist_id}","starred_url":"https://api.github.com/users/hvaneylen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvaneylen/subscriptions","organizations_url":"https://api.github.com/users/hvaneylen/orgs","repos_url":"https://api.github.com/users/hvaneylen/repos","events_url":"https://api.github.com/users/hvaneylen/events{/privacy}","received_events_url":"https://api.github.com/users/hvaneylen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-16T09:18:27Z","updated_at":"2018-08-16T09:18:27Z","closed_at":null,"author_association":"NONE","body":"I'm trying to create a small socket server bot from the starter. I want the smallest code.\r\nHere it is :\r\nvar controller = Botkit.socketbot({\r\n    debug: false,\r\n\tjson_file_store: __dirname + '/data/consoledb/'\r\n});\r\nvar webserver = express();\r\nwebserver.use(bodyParser.json());\r\nwebserver.use(bodyParser.urlencoded({ extended: true }));\r\n\r\nvar server = http.createServer(webserver);\r\nserver.listen(process.env.PORT || 3000, null, function() {\r\n        console.log('serveur en ligne')\r\n    });\r\ncontroller.webserver = webserver;\r\ncontroller.httpserver = server;\r\n\r\n// Open the web socket server\r\ncontroller.openSocketServer(server);\r\n\r\n// Start the bot brain in motion!!\r\ncontroller.startTicking();\r\n\r\n// call NLP service\r\ncontroller.middleware.receive.use(function(bot, message, next){\r\n\t//console.log('detect intent appelé')\r\n\tvar query = {'text': message.text}\r\n\trequest.post({\r\n\t\theaders: {'content-type': 'application/json'},\r\n\t\turl: ServiceNLU_url,\r\n\t\tjson: true,\r\n\t\tbody: query\r\n\t}, function(error, response, body){\r\n\t\t//controller.log(\"NLU:\",JSON.stringify(body))\r\n\t\tif ((body.intent != null) && (body.intent.probability >= Seuil)){\r\n\t\t\tmessage.intentionReconnue=true\r\n\t\t\tmessage.intentName= body.intent.intentName\r\n\t\t\tmessage.parameters =[]\r\n\t\t\tfor (var index in body.slots){\r\n\t\t\t\tmessage.parameters[body.slots[index].slotName]=body.slots[index].value.value\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tmessage.intentionReconnue= false\r\n\t\t}\r\n\t\tnext() <- error 1\r\n\t})\r\n\t//next() <- error 2\r\n})`\r\nDepending where I put the call to the next function I have 2 kind of error \r\n error 1 \r\nD:\\logiciels\\nodejs\\console\\node_modules\\md5\\md5.js:152\r\n      throw new Error('Illegal argument ' + message);\r\n      ^\r\n\r\nError: Illegal argument undefined\r\nerror 2\r\nAn error occured in the receive middleware:  Error: Illegal argument undefined\r\n at module.exports (D:\\logiciels\\nodejs\\workspace\\console\\node_modules\\md5\\md5.js:152:13)\r\n\r\nerror 1 abort the server - not error 2 but in this case, the results from the called NLP are not processed because the next() runs before the results are accessible from the hears call.  The right place for the next call is in error 1 position. But why is there an error ?? If someone can help ? because I'm clearly stuck and without calling the NLP service - the bot is useless.\r\nThe same code (error 1) run right with a consoleBot or a SlackBot so I'm a bit disappointed.\r\n\r\nI want to write my own small server in order to understand how it works and to build my own chat client.\r\n\r\nThanks in advance if anyone have an idea."}}
{"actor":{"display_login":"hvaneylen"}}