Zapier Integration
Step 1 - Convert Email Address to MD5
This guide explains how to set up a Code by Zapier task to convert an email address into an MD5 hash. This is the first step in the Zapier workflow for integrating with the GraphQL API.
Step 1: Add a "Code by Zapier" Task
-
Create a New Zap
- Log in to Zapier and create a new Zap.
- Select the desired trigger for the Zap (e.g., "New Lead" or "Form Submission").
-
Add a Code by Zapier Action
- Click on + Add Action.
- Choose Code by Zapier as the app.
- Select Run JavaScript as the event.
-
Configure the JavaScript Code
-
In the Code field, copy and paste the following JavaScript code:
// Import the crypto library
const crypto = require('crypto');
// Input data: email from the previous step
const email = inputData.email;
// Trim and lowercase the email
const cleanEmail = email.trim().toLowerCase();
// Generate MD5 hash of the cleaned email
const md5Hash = crypto.createHash('md5').update(cleanEmail).digest('hex');
// Return the hashed value
return { md5: md5Hash };
-
-
Set Input Data
-
Under the Input Data section,
add a new key-value pair:
-
Key:
email
- Value: Map this to the email field from the trigger step (e.g., "Email Address").
-
Key:
-
Under the Input Data section,
add a new key-value pair:
-
Test the Code
-
Click Test & Review to verify that the MD5 hash is generated correctly.
-
The output will include the MD5 hash of the provided email:
{
"md5": "e13743a7f1db7f4246badd6fd6ff54ff"
}
-
-
Use the MD5 Output in Subsequent Steps
-
In the following steps of your Zap, you can
use the
md5
value as input for other actions, such as enriching the lead with the GraphQL API.
-
In the following steps of your Zap, you can
use the
Step 2 - Custom Webhook Request for GraphQL Mutation
In this step, you will configure a Custom Webhook in Zapier to send a GraphQL mutation to your endpoint. The webhook will pass data through as part of the mutation request.
Url to POST
https://sweet-colt-9750.ddn.hasura.app/graphql
Select Passthrough Data, YES
Raw Request Structure:
Here’s the exact request format that Zapier will use to send the GraphQL mutation:
{
"query": "mutation HeroPixel($event: PagviewEventInput!) { pageview(auth: { appId: \"yourAppId\", appSecret: \"yourAppSecret\" }, event: $event) { message code data } }",
"variables": {
"event": {
"md5": "{{ $md5 }}",
"pixelId": 1,
"domain": "example.com"
}
}
}
Key Notes:
-
Replace
"yourAppId"
with your actualappId
. -
Replace
"yourAppSecret"
with your actualapp secret
. -
The variable
$md5
will be dynamically injected based on previous steps in the workflow.
Zapier Setup:
- Action: Add the Webhooks by Zapier app in the second step of your Zap.
- Method: Choose Custom Request.
- Request Type: Set the request type to POST.
- Data: Paste the above raw JSON structure into the Data section.