# Extracting respondent emails in Zapier

> Extract a respondent's email from your MetaSurvey webhook payload with a small JavaScript snippet in Zapier.

Source: https://getmetasurvey.com/help/extracting-respondent-emails-in-zapier/

MetaSurvey sends response data (like question types and answers) as arrays. To use a respondent's email in later steps like "Create Contact" or "Send Email," you need to extract it using a small script in Zapier.

## Step-by-Step Setup

1. Set up your Webhook Trigger

Select **Webhooks by Zapier** as your trigger and choose **Catch Hook**. Copy your unique Webhook URL and paste it into your MetaSurvey settings. Send a test response to ensure Zapier receives your data.

![Set up your Webhook Trigger](https://getmetasurvey.com/help/extracting-respondent-emails-in-zapier/tgWq3FnaDb7FVykoVQ3uynFpk.webp)(width: 1520, height: 1178)

1. Add the 'Code by Zapier' Action

Add a new step and select **Code by Zapier**. Set the **Action Event** to **Run JavaScript**.

![Add the 'Code by Zapier' Action](https://getmetasurvey.com/help/extracting-respondent-emails-in-zapier/yn2k0jWz8dcKB1vS4SZYvtd8yY.webp)(width: 1520, height: 1143)

1. Map your Input Data

In the **Input Data** section, you must create two specific keys and map them to your webhook data:

- `questionTypes`: Map to **1. Responses Question Type**

- `values`: Map to **1. Responses Value** ![Map your Input Data](https://getmetasurvey.com/help/extracting-respondent-emails-in-zapier/pU3yQS16MrIvkPgIn2gajlUQo.webp)(width: 1520, height: 1119)

1. Insert the Extraction Code

Copy and paste the following code into the **Code** box:

```
// Split the input data into arrays for question types and values
const questionTypes = (inputData.questionTypes || '').split(',');
const values = (inputData.values || '').split(',');

// Initialize an object to hold the extracted email
let emailOutput = { email: null };

// Loop through the question types to find the email value
for (let i = 0; i < questionTypes.length; i++) {
  if (questionTypes[i].trim() === 'email') {
    emailOutput.email = values[i] || null; // Assign value or null
    break; // Exit loop once found
  }
}

// Return the output object
return emailOutput;
```

1. Test and Use

Click **Test Action**. Zapier will return a single `email` field. You can now map this field in your next steps, such as adding a lead to HubSpot, Brevo, or sending a personal "Thank You" email.