1. Home
  2. Studio
  3. Advanced features

Word filler template part 1. How to pre-fill Word documents based on Flow responds

With Penbox, it is possible to place the responses that you and your contact have provided in a flow within a Word document. For example, contracts, evaluation forms, or sick notices. This manual will explain you how to set this up.

The Word fill feature is only applicable for flows made in the Studio. This manual will consist of 3 steps. Follow each step in the presented order. 

Step 1. Create the Word document 

You flow contains many elements with keys decide for each elements of which you want the outcome to be represented in the Word document a variable name. For example: {user.given_name} will be named {given_name}. 

In your Word document, enclose the variable name of the elements to which you want responses to be presented within curly brackets { }. 

Note: you can set the variable name the same as the element key. 

Examples: 

  • Element key: user.given_name
    • Varialbe name to be placed in the Word document: {given_name} 
  • Element key: data.what_is_the_name_of_your_doctor
    • Variable name to be placed in the Word document: {doctor_name}

After adding all your variable names to your document will look something like this:

 

Step 2. Add the download element to your flow and upload the Word document 

After completing the Word document, add the download element to your flow. In your flow: 

  • Click on Add Element 
  • Select the File Download element 
    • Edit the title of the element.
  • Upload the Word document 

element wordfill gif

Step 3. In script mode, add a line of code to the File Download element and publish the flow

Make sure to do this step after completing the flow since it needs to be published to save the changes. 

  • Open the File Download element by clicking on it. 
  • Click on the center-column's right corner on Script 
  • Around line 17 you will find the code "fill": { } 
  • In between the curly brackets of "fill"{ } define the variable name and to which key it is assigned to as this:     "variable_name": "{element_key}",
{
  "fill": {
    "family_name": "{user.family_name}",
    "given_name": "{user.given_name}",
    "company_name": "{data.company_name}",
    "is_legal_entity": "{data.is_legal_entity}",
    "legal_representation": "{data.choose_your_legal_representation}",
    "starting_date_contract": "{options.starting_date_contract}"
  }
}

Note: each variable should be separate with a comma (,) except for the last variable

Wordfill3

When the contact opens the flow, fills it in, and clicks on download your Word document will appear with the prefilled information. 

End result 

When your contact completes the flow and downloads the attached document, they will receive a Word document that has been filled in with the information provided by both you and the contact.

Group 170