Copying a Wufoo attachment to Box

Learn how to use App Connect to create an event-driven flow that copies a Wufoo file attachment from a submitted form and adds it as a Box file.

Note: This tutorial assumes that:
  • You have signed up for a free account for Box or you have a business account.
  • You have a paid Wufoo account. A paid plan is required for the File Upload capability that is used in this tutorial. (If you don't have a paid account, you can still read this page to see how App Connect can help.)

Scenario

You work in the Accounts department and receive expense reports as a Wufoo form that employees complete and attach their expense reports to. When a form is submitted, you want to copy the Wufoo attachment to Box so that you can collate and process the submitted expense reports on a monthly basis.

Figure 1. Event-driven flow for the Wufoo to Box scenario

First, find or create everything you need:

  1. Obtain an App Connect on IBM Cloud®® service. You can use an App Connect service that you already have or can sign up for App Connect.

    In this example, we use a new free App Connect - Lite plan service.

  2. Obtain account details for connecting App Connect to your integrating applications:
    • (If you haven't already connected App Connect to your Box account) The email address and password of your Box account
    • (If you haven't already connected App Connect to your Wufoo account) The API key and subdomain of your Wufoo account
      To find your Wufoo API key, go to the Wufoo Form Manager, open the More drop-down menu for any of your forms, and click API information. (The same 16-digit API key is used for all your forms.) You can copy and paste this API key into App Connect.
      Figure 2. Finding your Wufoo API key
      Finding your Wufoo API key
      To find your Wufoo subdomain, go to the Wufoo Account Manager. The subdomain value is included in the URL shown. You can copy and paste this value into App Connect.
      Figure 3. Finding your Wufoo subdomain
      Finding your Wufoo subdomain

    If you haven't already connected App Connect to Box and Wufoo, complete these steps in App Connect Designer:

    1. Open the App Connect Catalog page
    2. If Not connected is shown for Box or Wufoo, click to expand that row and then click the Connect button to enter the account information.
    3. If prompted, be sure to allow IBM App Connect to access the application's account.
    Tip: Alternatively, you can connect to applications when you add it to a flow.
  3. Create a Wufoo form to which expense reports can be attached:
    1. Log in to your Wufoo UI using the account that you configured in App Connect.
    2. Create a Wufoo form with the following settings:
      • Form Name: Expense Report Submission
      • Description: Fill me in to get your cash back.
      Click the Add Field button. From the Add a Field tab, click Section Break and configure these settings:
      • Field Label: Expense report for:
      • Instructions for User: Select the month and year.
      Add the following fields to the section with these field settings: (To save time, create these fields as text boxes rather than as drop-down lists that contain month/year values.)
      • Month (Field Type = Single Line Text)
      • Year (Field Type = Single Line Text)
      From the Add a Field tab, click Section Break and configure these settings:
      • Field Label: Details:
      • Instructions for User: Complete your details.
      Add the following fields to the section with these field settings:
      • Click Name (to add fields for the first and last name).
      • Click Email (to add an email field).
      • Click File Upload (to add a Browse button) and then change the Field Label value to Attach expense report.
      Figure 4. New Wufoo form sample for the Box tutorial
      New Wufoo form sample for the Box tutorial
    3. Click Save Form and then go back to the Form Manager.
    4. Click Start sharing next to the form name.
      Figure 5. Share your Wufoo form (Box tutorial)
      Share your Wufoo form (Box tutorial)
    5. From the Share page, make a note of the permanent link that references your form. (You will be required to enter this link later when you test the flow.) Remain logged in.
      Figure 6. Permanent link for the Wufoo form (Box tutorial)
      Permanent link for the Wufoo form (Box tutorial)
      Tip: App Connect supports the use of embedded Wufoo forms. So you could, if preferred, copy the embed code from the Share page and use it to display the form within your own web page. For example, to embed within a WordPress website, all you'll need to do is copy the code on the Embed on WordPress tab and then paste it into a WordPress doc. And then once you publish the doc, you can send users the link to the published doc that contains the embedded form.
  4. Create a text file that can be attached to the Wufoo form. Using a text editor, create a simple text file named expense_jdoe01.txt with the contents:
    Jane Doe: My Expense Report for Sept 2017
    1234
  5. In your Box instance, create a folder named ExpenseReports (with Editor permission) into which the Wufoo attachments should be copied.
    Figure 7. New folder named ExpenseReports in Box
    New folder named ExpenseReports in Box

Next, create your flow:

Using the IBM App Connect Designer authoring experience, complete the following steps to create your flow from scratch.

  1. From the Dashboard, click New > Event-driven flow.
  2. Complete the following steps. As you progress, App Connect automatically saves your changes. If you navigate away from the flow at any stage, the flow is saved as a draft flow that you can complete at another time.
    1. Enter a name that identifies the purpose of your flow; for example: Add expense reports to Box.
    2. Select Wufoo > New form entry as the event that is to trigger the flow.
    3. Select the Wufoo form (Expense Report Submission) that you created earlier. This selection can be interpreted as "When someone fills in and submits the Expense Report Submission form, [perform the action that I'm about to add]". (You will fill in this form later to test the flow.)
      Figure 8. Wufoo / New form entry event to trigger the flow
      Wufoo / New form entry event to trigger the flow
    4. Click the (+) and then select Box > Show More > File > Create file as the action that App Connect should use to add the Wufoo file attachment to Box.
    5. Specify the Box folder that you want to copy the Wufoo attachment to and then configure the remaining fields by mapping their values to those from Wufoo:
      • Folder: Select ExpenseReports from the list of folders in your Box instance.
      • File name: To help with collation in Box, you want the file names of all your submitted expense reports to be prefixed with the month and year for which expenses are being claimed in Wufoo.
        1. Click within the field, click Insert a mapping Insert a mapping icon, and then select Month from the list of available inputs.
        2. Click Insert a mapping Insert a mapping icon again and then select Year.
        3. Type an underscore (_), and then click Insert a mapping Insert a mapping icon for the third time to select File Name.
        Note: The list of available inputs is auto-populated with the fields you added to your Expense Report Submission Wufoo form; for example, Month, Year, Email. A set of date and ID fields that are auto-generated in Wufoo are also included.
      • File content: Type fi and then select File Content from the list (to indicate that the file contents of the Wufoo attachment should be copied to the Box file).
      • Type of file: Select Text from the list.
      Figure 9. Entries for the Box / Create file action
      Entries for the Create file action in Box
  3. Click Start flow on the toolbar, then click Dashboard to exit the flow. Your flow is displayed on your Dashboard as Running, and is listening for your event – a submitted form in Wufoo.
    Figure 10. Dashboard tile for the running flow
    Dashboard tile for the running flow

Finally, test your flow:

To test the flow, you can assume various roles: that of an Accounting team member, and an employee who wants to submit an expense report.

  1. [Employee]:
    1. From a new browser tab or window, paste in the permanent link of the Wufoo form that you created earlier.
    2. Complete the form as follows:
      • Month: September
      • Year: 2017
      • Name: Jane Doe
      • Email: jane_doe@example.com
      • Attach expense report: Click Browse and select the expense_jdoe01.txt file that you created earlier.
    3. Click Submit.
    Figure 11. Completed Wufoo form
    Completed Wufoo form
  2. [Accounting team member]:
    1. Go back to the browser tab or window where you created the form.
    2. Go to the Form Manager and verify you can see that an entry has been submitted.
    Figure 12. Entry for completed Wufoo form
    Entry for completed Wufoo form
  3. [Accounting team member]:
    1. If necessary, log in to Box using the account that you configured in App Connect. If already logged in, simply refresh your browser. (You might have to wait a few minutes for the file transfer to complete.)
    2. Open the ExpenseReports folder and verify that you can see a file named September2017_expense_jdoe01.txt file.
    Figure 13. Wufoo attachment added to Box
    Wufoo attachment added to Box

Conclusion

Congratulations, you have successfully created a flow that copies Wufoo attachments to a folder in your Box account.

Growth icon for stretch exercises
Stretch exercise – Try something a little different:

In the preceding exercise, you successfully created a flow that copies Wufoo attachments to a folder in your Box account. Now, imagine you want to ensure that the files (typically attached as expense.txt) are uniquely renamed in the Box folder, for each user submission per month. To help you do this, we'll delve a little further into a couple of other features that App Connect provides: flow management and transform functions.

Run through these steps to update and retest the flow.

  1. Create a text file named expense.txt, which can be attached to the Wufoo form. (You can just make a copy of the previous file and rename it.)
  2. Now, stop the flow so you can edit it.
    1. From the Dashboard, locate the flow. A quick way for you to locate a flow is to enter the first few characters of the flow's name in the search box (in this case, Add), or to sort your flows by name or date.
      Figure 14. Tools for locating or sorting flows
      Tools for locating or sorting flows
    2. Open the flow menu, and then click Stop. (Notice that there are other options that you can use to view the flow while it's running, manage errors, export the flow for sharing, and delete the flow if no longer needed. For more information, see Managing flows.)
      Figure 15. Flow menu options
      Flow menu options
  3. To edit the flow, click anywhere on the tile.
  4. From the flow editor, click the Box node.

    We will now update the fields for the "Create file" action to specify a different naming convention for the file attachments.

  5. Update the File name field by applying transform functions to define a file naming convention of mmmyyyy_username_filename.txt.
    1. In the File name field, click Month and then select Apply a function from the context menu. Then select $substring() from the Functions list. The Month value is then shown as: {{$substring(Month, start, length)}}
    2. Click start and then type 0 (that is, zero). Click length and then type 3. This function lets us extract the first three characters in a month's name.
      Figure 16. Updated Month value in the File name field
      Updated Month value in the File name field
    3. Click after the underscore (_). Then click Insert a reference Insert a mapping icon, and then select Email from the list of available inputs. Then type another underscore.
    4. Click Email and then select Apply a function from the context menu. Then select $substringBefore() from the Functions list. The Email value is then shown as: {{$substringBefore(Email, "chars")}}
    5. Click chars and then type @. This function lets us extract the user name from an email address username@domain, by using the ampersand (@) as the delimiting character.

      The completed entries for the "Create file" action should be similar to this:

      Figure 17. Updated Box fields
      Updated Box fields
  6. To restart the flow, open the options menu [⋮] in the banner and then click Start flow. Then click Dashboard to exit the flow. In the Dashboard, the flow is shown as Running again.
  7. From a new browser tab or window, paste in the permanent link of the Wufoo form that you created earlier, and then complete the form as follows:
    • Month: September
    • Year: 2017
    • Name: Huck Finn
    • Email: huckfinn@example.com
    • Attach expense report: Click Browse and select the expense.txt file that you created earlier.

      Click Submit.

  8. If necessary, log in to Box using the account that you configured in App Connect. If already logged in, simply refresh your browser. (You might have to wait a few minutes for the file transfer to complete.)
  9. Open the ExpenseReports folder and verify that you can see a file named Sep2017_huckfinn_expense.txt file.
    Figure 18. File in Box folder
    File in Box folder