# FormSG (Multi-Respondent Form) integration

{% hint style="info" %}
**Advanced Feature**

This guide covers Plumber's integration with FormSG Multi-Respondent Forms. Before proceeding, you should:

* Be comfortable using Plumber to create basic pipes
* Understand how Multi-Respondent Forms work in FormSG
* Have already set up and tested an MRF workflow in FormSG

If you're new to MRF, we recommend reading [FormSG's guide on Multi-Respondent Forms](https://guide.form.gov.sg/user-guides/multi-respondent-form-guide) first to understand workflow steps, approval fields, and respondent routing.
{% endhint %}

## What is Multi-Respondent Forms?

Multi-Respondent Forms (MRF) is a FormSG feature that allows multiple people to fill out different parts of the same form in sequence. For example, an employee submits a leave request, then their manager reviews and approves it, then HR processes it, all within a single form submission.

## MRF Integration with Plumber

When you connect an MRF form to Plumber, you can automate actions at each step of the approval process:

* Send notifications when someone submits or approves
* Update spreadsheets with the latest status
* Trigger different actions based on approval or rejection

{% hint style="info" %}
**Requirements** \
\
Before you start, make sure you have:

* A **Multirespondent FormSG form**&#x20;
* Workflow steps configured in FormSG (who fills out what, in what order)
* The form must be **published**
  {% endhint %}

## How to Connect Your MRF Form

1. Click "Choose how you want your workflow to start"
2. Select "FormSG"
3. Click "Choose connection" and add new form
4. Enter your MultiRespondent form URL and secret key
5. Click "Connect"
6. Plumber will detect that your form is a Multirespondent form

## Adding action to each step

{% hint style="info" %}
MRF forms don't always require approvers, but the example in this guide will include approval steps
{% endhint %}

Now you can add actions after each workflow step. Click the + button after any step to add an action. In this example, there are two other approvers in this workflow.

### Understanding Approval Branches

When you add an approval step to your workflow, you can set up two different paths depending on the outcome:

Each approval step shows two tabs:

#### Setting Up Your Branches

1. Click on the **If approved** tab&#x20;
2. Add the actions you want to happen when approved
3. Click on the **If rejected** tab
4. Add the actions you want to happen when rejected

<figure><img src="https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FXuflRC7u9nuHOQ1c8zyn%2Fimage.png?alt=media&#x26;token=558b16d1-be04-4451-9df3-7401d4df2999" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FrbGgjDeAYfgKLnil74Wx%2Fimage.png?alt=media&#x26;token=1ac8ea40-8452-4c43-a9a9-5fa500a93872" alt=""><figcaption></figcaption></figure>

**"If Rejected" is currently selected**, the **Third Submission step is greyed out and will not run**. The automation is essentially **blocked at Step 2**<sub>**,**</sub> nothing downstream will trigger until the rejection is handled or the flow is redesigned.

<table><thead><tr><th width="249">Tab</th><th>What It Does</th></tr></thead><tbody><tr><td>If approved</td><td>Actions that run when someone approves the request</td></tr><tr><td>If rejected</td><td>Actions that run when someone rejects the request</td></tr></tbody></table>

## Example

Imagine you're building a leave request workflow that involves approval from both team lead and manager:

**If approved:**

* Send an email to employee that team has approved
* Send a confirmation email to the employee&#x20;
* Notify HR via email

<figure><img src="https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FLb0R9GaYuSEBmxIkRcvz%2Fimage.png?alt=media&#x26;token=d53b83a3-d65f-471e-929a-148ed02f51ea" alt=""><figcaption></figcaption></figure>

**If rejected:**

* Send a rejection email with the reason

<figure><img src="https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FkVwOkKwZGfZ455QUI2iw%2Fimage.png?alt=media&#x26;token=18028674-8186-4dc8-8949-768e2ac16636" alt=""><figcaption></figcaption></figure>

## **Tips & Good to Know**

1. **Updating step names:** Step names are pulled from FormSG. To rename a step, update it in your FormSG workflow settings, then click "Test step" in Plumber to sync the new name.
2. **MRF steps can only be managed in FormSG.** You cannot reorder, create, delete, or edit them in Plumber. After making changes in FormSG, click "Test step" in Plumber to sync.
   * You can, however, freely reorder action steps within or across MRF steps and branches.

**What Happens When MRF Steps Change**

* **Deleting an MRF step in FormSG:** After syncing via "Test step", all action steps between the deleted step and the next MRF step will also be removed from Plumber.
* **Adding a new MRF step in FormSG:** The new step appears after the last existing MRF step. If the previous last step had a rejection branch that the new step doesn't, the rejection branch will be removed.

**Limitations**

* For-Each and If-Then steps can only be added in the last MRF step, one per branch in approval branches.
* Delay cannot be placed immediately before an MRF step.
* Reconnecting your pipe to a non-MRF form will wipe your entire pipe configuration.

## Common errors when using MRF integration

<details>

<summary>MRF steps didn't appear after testing</summary>

* Make sure your form is set to [**Multirespondent mode**](https://guide.form.gov.sg/user-guides/multi-respondent-form-guide) in FormSG
* Check that you have workflow steps configured in FormSG
* Make sure the form is published
* Try clicking Test step again

</details>

<details>

<summary>The form you are trying to connect is currently being used in another pipe. Continuing with this connection will cause the other pipe to break.</summary>

Ensure that current pipe is no longer in use before proceeding.

</details>

<details>

<summary>'If approved' and 'If rejected' are not showing up</summary>

<figure><img src="https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FA0kj3QF1RKfciCjF1BbG%2Fimage.png?alt=media&#x26;token=b6fbf9a1-c1fe-4c87-b3fb-d8aea0734933" alt=""><figcaption></figcaption></figure>

Ensure the 'Make this step an approval' toggle is enabled in your MRF form's workflow

</details>
