Tutorial: Using listeners to wait for a file download

We can build apps using Flow that wait for an event to occur. For example, we can have an app that ‘listens’ for a file to be downloaded – and sends out a text message when it does. We do this using a ‘listener’.

We configure a listener in Flow as an asynchronous message action, that is waiting for a predefined event to happen. We add a new listener (available under Advanced options in a message element), assign the listener to a value (the value must be a typed object from a service), tell it to listen for a certain event type (these are defined by the service, and need to be known beforehand), and then the flow waits with the spinner until the service calls back. The service calls back whenever the desired event happens in the external system, and will return the updated value back to the flow. The flow, which has been waiting all this while for the desired event to happen, will now move forward.

Let’s build a simple app that waits for a file to be downloaded in Box. We will use three elements. The first will be a load element – In order to listen to file changes, we need to get a file object from Box. Next, we want to listen to changes to that file. To do that, we set up a listener using the message element; where we tell Box the file and event type that we want to listen to. Lastly, we use a step element to tell the user that the file was downloaded.

This is what the canvas will look like when we are done building:

We will need:

  1. Boomi Flow username/password  (Get a free Flow login here)
  2. A Flow tenant/subtenant with the Box Service installed
  3. A file in Box which we can download

Building the app

Let’s get started at the very beginning then; generally believed to be a very good place to start.

  1. Click LOG IN to log in to the Flow Drawing Tool. We are in the Flows tab. The sidebar menu on the left-hand-side of the drawing tool is minimized by default. Clicking the arrow expands the menu.
  2. Click New Flow.
  3. Select Box from the dropdown menu Which Service should be used for authentication.
  4. Click Continue.
  5. Let’s enter a name for the flow in the Name field. Say, Listeners Demo.
  6. Select Any user that can login with the selected identity service can run this flow in the Access menu.
  7. Select None from the Social feed for collaboration menu.
  8. Click Start Building! This opens the canvas where we will build our flow.
  9. Drag a Load element from the sidebar to the canvas.

    This opens a configuration panel.
  10. Copy-paste the text File load in the Name field.
  11. Click New Data Action.
  12. Click Select or create a new Value.
  13. Click Create a new Value.

    This opens the value creation dialog box.
  14. Copy-paste the text File load in the Name field.
  15. Select Object for the What kind of Value is this field.
  16. Click Select a Type.
  17. Select the File from the Box service from the list.
  18. Click Save.
  19. Select File from the Where will be the data be sourced from field.
  20. Click Edit Filter.
  21. Expand the options for Which type of filter should be used and select Get the data based on an unique identifier.

    This brings up the option for loading the data with an identifier.
  22. Click Select or create a new Value.
  23. Click Create a new Value.
  24. Copy-paste Box File ID in the Name field.
  25. The what kind of value is this option should be String.
  26. Let’s enter the ID of the document we want to keep track of in Box, in the Default Value field. This number is available in the URL of the document in Box. For example:
  27. Click Save.
  28. Click Apply Filter.
  29. Click Apply Data Action.
  30. Click Save Database Load.

    This is what the canvas looks like now:
  31. Hover your mouse on StartThe mouse pointer changes from a crossbar to a hand.
  32. Drag an arrow from Start to File upload.
  33. In the Configuration Panel, type Go in the Name text field.
  34. Click Save Outcome. This is what the canvas looks like now:
  35. Drag a Messenger element to the canvas. This opens a configuration panel.
  36. Copy-paste Configuring listener in the Name field.
  37. Click the + sign to expand the Advanced options.
  38. Click New Listener.
  39. Type Listening in the Name field.
  40. Copy-paste FILE.DOWNLOADED in the Listen to events of type field.
  41. Select Box as the Service implementing this listener.
  42. Click Select or create a new value.
  43. Select the File load value which is the Object of File from Box.
  44. Click Apply Listener.
  45. Click Save Message.

    This is what the canvas looks like now:

  46. Hover your mouse on File loadThe mouse pointer changes from a crossbar to a hand.
  47. Drag an arrow from File load to Configuring listener. This opens a configuration panel on the right-hand side.
  48. Type Go in the Name field.
  49. Click Save Outcome. This is what the canvas looks like now:
  50. Drag a Step element to the canvas. This opens a configuration panel.
  51. Type File in the Name field.
  52. Copy-paste The file was downloaded in the content editor.
  53. Click Save Step.

    This is what the canvas looks like now:
  54. Hover your mouse on Configuring listenerThe mouse pointer changes from a crossbar to a hand.
  55. Drag an arrow from Configuring listener to File. This opens a configuration panel on the right-hand side.
  56. Type Go in the Name field.
  57. Click Save Outcome.

That was fast!

It took us around 20 minutes to build an app that uses listeners.

This is what the screen looks like:

Let’s run the flow now.


Appchievement!

Remember, we used Box for authentication? The first thing the app asks us to do, is log in to Box.

Let’s sign in and click Authorize.

The next thing we are asked to do is grant ManyWho access to Box. Okay, sure.

We see the spinner now, as the flow is waiting for the file in Box to be downloaded.

Let’s head over to Box now, and download the file.

The app now moves on to the next step.. which alerts us that the file was downloaded.

Note // 

For the sake of illustration, we are using a message element here. We can also add a listener to the load element, and remove the message action altogether.


Check out the glossary for a definition of terms and key concepts that appear in the Boomi Flow website, drawing tool, technical documentation, blogs, and marketing communications.

If you need to take a closer look, click on the images to enlarge them. Have a question? Click the Help button on the bottom right-hand corner of this page to ask.