ibm-cloudibm-cloud-infrastructureibm-cloud-toolsibm-cloud-functions

Implementing a chatbot using FB Messenger with file upload functionality in Bluemix


We are implementing a chatbot using FB Messenger. One of their requirements is that the customer have set of guides, documents (PDF, DocX), which they want to store in IBM Cloud. Whenever user asks for download of a guide then the chatbot should provide a link to the file, on clicking of which the file contents should be opened in a new window. Customer also has a requirement that their admin users should be provided a provision via Admin UI to upload new set of guides in future.

We are using Node.JS application. We are working on an approach of storing all the guides, documents within the Node.JS app and provide a relative location to those files in the chat interface.

We are adding files as static component:

'use strict';

var express = require('express'); 

app.use(express.static('./public'));

Then changing chat output string to have document URL to open it in new window successfully.

We want to upload the files as that's the requirement that user would like to upload the files through a UI in future.

Please provide pointers on uploading files as static components into the running application.


Solution

  • Have you given this a read: http://upkarlidder.com/blog/posts/2017/bluemix-simple-static-site.html

    Or this one: https://www.ibm.com/blogs/bluemix/2014/08/deploying-static-web-sites/

    Nodejs magic to serve static site

    app.use(express.static(__dirname + '/public'));
    

    That single line in your app.js tells node.js where to fetch the static files from. You can just place your static site in the public directory and publish back to Bluemix using the next step