Sending Numerical Values Through Webhooks

Overview

Would you like to send numerical values through webhooks? By default, when you pass values through webhooks, they are sent as strings and not numbers. With a simple snippet, you can effortlessly convert these strings into numerical values.

In this guide, we’ll share the snippet that allows you to send values as numbers when using the Webhooks addon.


Setup

To ensure the numbers are sent through as numerical values, please copy and paste this code snippet to your site.

If you need assistance in adding snippets to your site, please see this tutorial.

In the code snippet above, we’re specifying an array of numbers and passing two variables: experience and form_id. Then, we loop through the array and assign a type integer to all the variables in the array.

Note: You can add as many variables as you need to the function. Just make sure to wrap each in single quotes and separate them with commas.

After adding the snippet, you’ll need to map the variables to fields in your form. To get started, create a new form or edit an existing one to access the form builder.

In the form builder, make sure your form fields map to the variable name(s) you specified in the snippet. To access the Webhooks settings, go to Webhooks » Settings in the form builder. Then, toggle the Enable Webhooks option to the on position.

Enabling webhooks in WPForms

For this tutorial, we’re passing through two variables. One is experience, and the other is form_id. These variables correspond to the ones specified in the code snippet above.

Mapping webhooks data to fields in WPForms builder

Note: For details on how to set up and use the Webhooks addon in WPForms, be sure to check our guide to using the Webhooks addon.

Make sure to include each variable name in the snippet above wrapped in single quotes and separated by a comma for each variable you want to convert from a string to a number.

That’s it! You can now pass webhooks data as numbers in WPForms.

Next, would you also like to include the Entry ID in your webhook? See our tutorial to learn how to send the entry ID through webhooks.