Beginner’s Guide to Sending Data Between Gravity Forms and n8n Using API Alchemist

Learn the basics of sending API data between Gravity Forms and n8n with a simple use case where we extract the contents of an attached PDF. No coding magic required.

  1. Build overview
  2. Step 1 — Add trigger node to n8n
  3. Step 2 — Connect the n8n webhook to Gravity Forms
  4. Step 3 — Configure Gravity Forms’ request
  5. Step 4 — Preparing callback URL
  6. Step 5 — Send test data to n8n
  7. Step 6 — GET the PDF
  8. Step 7 — Extract PDF text
  9. Step 8 — Send PDF text back to Gravity Forms
  10. n-6-7-8-n ⛓️

API Alchemist is our very own Gravity Forms API hub. You can push, pull, and even populate data to and from Gravity Forms using most REST APIs on the web. This allows you to integrate Gravity Forms with the tools you already use and magically expand automation capabilities.

Speaking of automation, the API we’re focusing on today is n8n, an AI automation platform where you can create workflows with multiple steps, including receiving data from an API request, using tools like AI bots and file extractors, and sending it over to other services like Slack.

Let’s explore this connection by creating a simple PDF text extraction workflow. Unfortunately, PDFs are still used everywhere. Attaching them to a submission is one thing, but wouldn’t it be great if your forms could extract the information within them?

Well, with API Alchemist + n8n, they can. 😉

This article requires the Gravity Connect API Alchemist plugin.

Buy Gravity Connect to get this plus other premium Gravity Forms plugins!

View Plugin Buy Now

Build overview

We’ll connect Gravity Forms and n8n using API Alchemist to:

  • Send an uploaded PDF from the form to n8n.
  • Use n8n’s tools to extract text from the PDF.
  • Send the extracted text back from n8n to the form.

Both API Alchemist and n8n offer drag-n-drop interfaces for you to perform complex tasks without writing any code. They also make the code you need to interact with manageable even if you don’t have a background in development.

We recommend following this tutorial in test mode. You can even use my test form for simplicity.

Quick word on JSON

Since we’ll be dealing with API requests, there is a little bit of JSON in this tutorial. I’ll be guiding you every step of the way, and if you have any questions, leave them in the comments below.

If you want to get more familiar with JSON and API requests in general, check out our Wizard’s Pocket Guide to APIs.

Step 1 — Add trigger node to n8n

Here’s what our full workflow will look like:

Showing full n8n workflow with all nodes (steps) in place: Webhook, HTTP Request, Extract from File, and Callback

Each step you see there is called a node, and we’ll add them one at a time. For starters, add your first node: Webhook (“On webhook call”). We’ll need it to set up API Alchemist.

Step 2 — Connect the n8n webhook to Gravity Forms

Rapid-fire:

  1. Open the Webhook node.
  2. Set its HTTP Method to POST.
  3. Copy the URL right above by clicking on it.
  4. Head over to your form.
  5. Go to Form Settings API Alchemist.
  6. Add a new feed by clicking on Add New.

Under the Webhook Settings, paste the URL from the Webhook node into Webhook URL and set the HTTP Method to POST. This is telling the API Alchemist feed to send POST requests to that URL.

Pasting n8n URL into the Webhook URL setting under Webhook Settings

Step 3 — Configure Gravity Forms’ request

Going down to Request Configuration, choose Customize request body so we can control the JSON response that will be sent over to n8n. Let’s name its key “pdf” under the Field Name and set the Value to the File Upload field merge tag.

Creating "pdf" key under the JSON Field Mappings in the Request Configuration

If you want to see what this looks like in JSON, just toggle Advanced Mode.

Step 4 — Preparing callback URL

Next, let’s prepare the feed to also receive the extracted PDF text back from n8n. Go to Response Handling, click on Enable Response Handling and select Advanced.

The difference between Simple and Advanced here is that your server won’t wait on a response from n8n — it will give it a callback URL instead, so that n8n can let your server know when it’s finished doing its thing.

A bit down below, click on Open Response Mapping Editor. Set the JSONPath Expression to $.text and choose the form field you want the text to be output to.

Adding "$.text" to the JSONPath Expression setting in the Response Data & Field Mapping modal

Close the modal and save the feed. Time to finish our n8n setup.

Step 5 — Send test data to n8n

Open the Webhook node and click on Listen for test event. Go back to your form and submit a PDF. This will give n8n all the information we need to build our workflow, which appears on the Output (right) side.

Submitting a PDF to Gravity Forms and having it sent to n8n

Step 6 — GET the PDF

n8n has received the PDF from Gravity Forms via POST, but to prepare for the text extraction step, it needs to perform a GET request to make the PDF accessible to its other tools.
Add an HTTP Request node and a modal will appear. On the Input side, scroll all the way down to find the request’s body. From there, drag and drop the pdf key (this one) into the URL field.

Dragging the "pdf" key from input into the URL setting

Step 7 — Extract PDF text

Add an Extract from File node and choose Extract from PDF. Click on Execute Previous Nodes on the Input side and you’ll see the output appear on the Output side.

Executing HTTP Request node from Extract from File node and highlighting the extracted text

Step 8 — Send PDF text back to Gravity Forms

With our PDF text ready in our robotic hands, it’s time to add another HTTP Request node.

  1. Set its HTTP Method to POST.
  2. In the Input side, navigate to the Webhook step and scroll down to the original request body.
  3. Drag and drop the _gcapi_callback_url to the URL setting.

Next, enable Send body and change Specify Body to Using JSON. Then, use this template:

{
  "token": "{{ $('Webhook').item.json.body._gcapi_callback_token }}",
  "data": {
    "text": {{ JSON.stringify($json.text) }}
  }
}

How I got here

  • I manually wrote all of the JSON keys.
  • Dragged and dropped the _gcapi_callback_token from the Webhook step and the text from the Extract from File step. Both are available in the Input side.
  • Added the JSON.stringify function to the text value to convert it from JavaScript to JSON.

Time to execute the last step!

Executing the last step and having the PDF text sent to the original entry

n-6-7-8-n ⛓️

That’s it! Now you can click on Execute workflow, upload a PDF again, and see n8n doing the magic by itself.

Have any questions? Drop them down below.

If you want to make the output more readable, you can add an AI step in n8n with your model of choice (e.g. OpenAI) and format the text before sending it back to Gravity Forms.

PS—I was not expecting this to have exactly eight steps. Magic works in wonderful ways. 🧙‍♂️

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.


This field is for validation purposes and should be left unchanged.
Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.