Home
Support Forums

Form notifications via webhooks and how to include data

Hello,

I have a Netlify form on my website-- right now I have it set to alert an app on my phone via a webhook whenever the form has been filled out.

Is it possible to parse information from the form, such as the name or email address into the webhook url? I currently have the option to designate a “message” but I have no idea how I’d extrapolate that from the form in Netlifys setting area.

I’d be more than happy to elaborate further if necessary, and I truly appreciate any help you may provide! Thanks!

Hi @RT_Hinkel

A webhook for a form notification is a post request of which the body includes the form data. Using Request Catcher or other webhook test shows the following.

Headers

POST / HTTP/1.1
Host: <REDACTED-HOST-EVENT-POSTED-TO>
Content-Length: 1073
Content-Type: application/json
X-Datadog-Parent-Id: REDACTED-
X-Datadog-Sampling-Priority: 1
X-Datadog-Trace-Id: REDACTED-
X-Netlify-Event: submission_created

Body:

{
  "number": 8,
  "title": "Test",
  "email": "test@example.com",
  "name": "Test",
  "first_name": "Test",
  "last_name": null,
  "company": null,
  "summary": "\u003cstrong\u003eTest\u003c/strong\u003e This is a test message.",
  "body": "This is a test message.",
  "data": {
    "name": "Test",
    "email": "test@example.com",
    "role": ["leader"],
    "message": "This is a test message.",
    "ip": "[REDACTED]",
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:95.0) Gecko/20100101 Firefox/95.0",
    "referrer": "https://netlify-drop-example.netlify.app/contact"
  },
  "created_at": "2022-01-06T01:27:32.570Z",
  "human_fields": {
    "Name": "Test",
    "Email": "test@example.com",
    "Role": "[\"leader\"]",
    "Message": "This is a test message."
  },
  "ordered_human_fields": [{
    "title": "Name",
    "name": "name",
    "value": "Test"
  }, {
    "title": "Email",
    "name": "email",
    "value": "test@example.com"
  }, {
    "title": "Role",
    "name": "role",
    "value": "[\"leader\"]"
  }, {
    "title": "Message",
    "name": "message",
    "value": "This is a test message."
  }],
  "id": "[REDACTED]",
  "form_id": "[REDACTED]",
  "site_url": "https://netlify-drop-example.netlify.app",
  "form_name": "contact"
}

So depending on how the app you are posting to work, you could process the application/json body to retrieve further information.

1 Like

Coelmay, thank you!

Is it possible to parse those terms into a webhook? For instance, on Netlify’s side on the Webhook screen I set the URL to notify, In that URL I can affix “&message=text+goes+here” and it then uses that text as the message for my Push Notifcation. If I wanted to use the text from the “first_name” field for “&message=”, would I be able to do that? If so, could I just use &message=“first_name”?

You will need something to parse the webhook data. You could configure another function perhaps, or look at using the Zapier Integrations.

1 Like