Watson Conversation chatbot integration with Facebook Messenger

This flow integrates IBM Watson Conversation service on IBM Bluemix with Facebook Messenger using Facebook Messenger Webhooks and the Send API. A detailed step-by-step tutorial about how to create the chatbot is found here at the FreeBootcamp.io site: https://www.freebootcamp.io/courses/developing-chatbots/

[{"id":"94fb56.6cb8e4a8","type":"http in","z":"9080ea2e.ed36d8","name":"","url":"/facebook/webhook","method":"get","swaggerDoc":"","x":425,"y":81.5,"wires":[["b4d1a8f7.99d508"]]},{"id":"37e4163c.585962","type":"comment","z":"9080ea2e.ed36d8","name":"Verify Request from Facebook","info":"","x":436,"y":41,"wires":[]},{"id":"9ac60335.27067","type":"comment","z":"9080ea2e.ed36d8","name":"Redirect URL from Facebook Webhook","info":"","x":468,"y":208,"wires":[]},{"id":"8466b62c.e426e8","type":"http in","z":"9080ea2e.ed36d8","name":"","url":"/facebook/webhook","method":"post","swaggerDoc":"","x":428,"y":250.5,"wires":[["72718dac.03b6a4","91f3f2f3.5cad18"]]},{"id":"445ea04c.edd348","type":"http response","z":"9080ea2e.ed36d8","name":"","x":1563.5,"y":248.25,"wires":[]},{"id":"b4d1a8f7.99d508","type":"function","z":"9080ea2e.ed36d8","name":"verifyRequest","func":"msg.payload = msg.payload['hub.challenge'];\nreturn msg;","outputs":1,"noerr":0,"x":663,"y":81,"wires":[["9c2c6e35.5705d","636b0447.6081e4"]]},{"id":"9c2c6e35.5705d","type":"http response","z":"9080ea2e.ed36d8","name":"","x":835,"y":80.75,"wires":[]},{"id":"636b0447.6081e4","type":"debug","z":"9080ea2e.ed36d8","name":"logVerifyResponse","active":true,"console":"false","complete":"payload","x":874,"y":125.75,"wires":[]},{"id":"e9abb619.651df","type":"watson-conversation-v1","z":"9080ea2e.ed36d8","name":"ibm watson conversation","workspaceid":"","multiuser":false,"context":true,"x":942,"y":249.75,"wires":[["556acbb8.3b2f04"]]},{"id":"72718dac.03b6a4","type":"function","z":"9080ea2e.ed36d8","name":"Set Conversation Input","func":"context.global.sid = msg.payload.entry[0].messaging[0].sender.id;\nmsg.payload = msg.payload.entry[0].messaging[0].message.text;\nreturn msg;","outputs":1,"noerr":0,"x":684,"y":250,"wires":[["e9abb619.651df"]]},{"id":"556acbb8.3b2f04","type":"function","z":"9080ea2e.ed36d8","name":"Format Send Request","func":"var messageText = msg.payload.output.text[0];\nvar senderId = context.global.sid;\nmsg.payload = \n{\n    \"recipient\": {\n        \"id\": senderId \n    }, \n    \"message\": { \n        \"text\": messageText\n    } \n};\nreturn msg;","outputs":1,"noerr":0,"x":1181,"y":249,"wires":[["bb05dae1.654be"]]},{"id":"bb05dae1.654be","type":"http request","z":"9080ea2e.ed36d8","name":"Send API Request","method":"POST","ret":"obj","url":"https://graph.facebook.com/v2.6/me/messages?access_token=EAAGcGwTI2MMBAPvY9qa0u7yXiF4B7QTuHX2HlvO6f2KJZCDJ61zR8UZB5v4qc2KRWUI78UvHOWWOgDJKn4i1rN0qaZATjYzDaT4dY5vNZCjZCZABmsDCnhBnl4ZAW0iLZAnP4nAtZATR6rUqj34M9xi6cA1nmcaPS48QhSy8F8hVLYgZDZD","tls":"","x":1399,"y":249,"wires":[["445ea04c.edd348","576ec5dc.cc8d8c"]]},{"id":"91f3f2f3.5cad18","type":"debug","z":"9080ea2e.ed36d8","name":"log1","active":true,"console":"false","complete":"payload","x":623,"y":294.75,"wires":[]},{"id":"47bcee27.949dc","type":"debug","z":"9080ea2e.ed36d8","name":"log2","active":true,"console":"false","complete":"payload","x":881,"y":293.75,"wires":[]},{"id":"3029a131.dcc5ee","type":"debug","z":"9080ea2e.ed36d8","name":"log3","active":true,"console":"false","complete":"payload","x":1354,"y":295.75,"wires":[]},{"id":"576ec5dc.cc8d8c","type":"debug","z":"9080ea2e.ed36d8","name":"log4","active":true,"console":"false","complete":"payload","x":1567,"y":291.75,"wires":[]},{"id":"c099fcc8.ccfcf","type":"http in","z":"9080ea2e.ed36d8","name":"","url":"/facebook/privacy","method":"get","swaggerDoc":"","x":414.5,"y":443.25,"wires":[["632b07f2.097c18"]]},{"id":"76ce462d.3b6a08","type":"http response","z":"9080ea2e.ed36d8","name":"","x":806.5,"y":442.5,"wires":[]},{"id":"632b07f2.097c18","type":"template","z":"9080ea2e.ed36d8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"This is the Privacy Policy for the Messenger App \nand the Chatbot that answers your Messages. \nBe aware that all your messages might be saved but\nnot shared with anyone other but FreeBootcamp.io.\n","x":637.5,"y":441.75,"wires":[["76ce462d.3b6a08"]]},{"id":"e9fc7b8.2791d08","type":"comment","z":"9080ea2e.ed36d8","name":"Privacy License for Application Submission","info":"","x":475,"y":403,"wires":[]}]
remkohdev

Flow Info

created 3 weeks ago

Node Types

Core
  • comment (x3)
  • debug (x5)
  • function (x3)
  • http in (x3)
  • http request (x1)
  • http response (x3)
  • template (x1)
Other

Tags

  • ibm
  • ibm-watson
  • bluemix
  • facebook-messenger
  • facebook
  • messenger
  • chatbot
  • ibm-watson-conversation
  • conversation
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option