Web channel - file upload

I have a case that i need the customer to upload document to the bot, then call apis to archieve the document.

How can i enable file upload in web channel?

I am encountering the same issue. Anyone has any ideas on how to enable users to upload documents through the bot? Thanks!

Edit for update: Was using the BOTPRESS.FILE_UPLOAD in skill choice to upload and could not work because I was using emulator but could work on live chat. However, another problem arises: the file is renamed to a random string. Is there a solution to keep the file name? Also, despite the successful upload, it goes to the failure node. Is there any fix for that as well?

My choice skill is defined as follows:

Edit 2: Hi @sylvain sorry to disturb you here as well but are there any solutions/documentation of handling file uploads? This method seems to not even work in Botpress 12 as I get a new error as follows:

1 Like

Sorry to bump this again but anyone any help on this?

Update: I found a way to get the uploaded name and original name through using the payload and rename the file to the original name. I am using v11.9.5. In case anyone needs it:

const fs = require('fs');

let status = event.payload.text.split(" [")[0];
let success_message = "Uploaded a file"

let base =  //insert your own upload path
let uploaded_name = event.payload.name
let desired_name = event.payload.originalName

try {
  if (status === success_message) {
    fs.rename(base + uploaded_name, base + desired_name, function(err) {
} catch(err) {

However, I still have problem controlling the flow after successful upload since this is defined in actions and jumpTo seems to only work in hooks not actions.

For the jumpTo inside an action, you’ll have to set the event.setFlag(bp.IO.WellKnownFlags.FORCE_PERSIST_STATE, true) so that the position is saved after jumping, also make sure your action awaits the SDK calls (they return a promise).

Hi @sylvain thanks for the response. I tried it out as shown below, moving the setFlag before the jump as well but it still does not work. Am I missing something?

const jump = async () => {
    const sessionId = bp.dialog.createId(event)
    await bp.dialog.jumpTo(sessionId, event, 'main.flow.json', 'jumphere')
    await event.setFlag(bp.IO.WellKnownFlags.FORCE_PERSIST_STATE, true)

return jump();

Hi idkla, please guide me how to use this code and where to edit in version 12.0, Thanks so much.

Hi, I am still using version 11 but it should be the same in version 12. You put the code in an action and put that action in the same node with the skill choice using BOTPRESS.FILE_UPLOAD.