---
title: "Automatically transform webhook payloads | WebhookRelay"
meta:
  "og:description": "Automatically transform webhook payloads using AI in Webhook Relay. Step-by-step guide to convert webhook data between different formats without coding."
  "og:title": "Automatically transform webhook payloads"
  description: "Automatically transform webhook payloads using AI in Webhook Relay. Step-by-step guide to convert webhook data between different formats without coding."
---

![Stripes](https://webhookrelay.com/blog/auto-transform-webhook/images/stripes.svg)

# **Automatically transform webhook payloads**

Automatically transform webhook payloads using AI in Webhook Relay. Step-by-step guide to convert webhook data between different formats without coding.

In Webhook Relay you can automatically transform webhook payloads using [functions](https://webhookrelay.com/blog/auto-transform-webhook/docs/webhooks/functions) that is basically a Lua code snippet to manipulate the payload. While powerful, it requires you to write the code yourself. Now, we are introducing a new feature that allows you to automatically transform webhook payloads using AI.

## [How it works](#how-it-works)

You will need to provide two examples:

- Input payload (that you want to transform)
- Output payload (that you want to receive)

We will use this to automatically generate the transformation function that will run on every webhook.

## [How to use it](#how-to-use-it)

Go to the [magic transform](https://my.webhookrelay.com/new-transform) page.

![magic transform](https://webhookrelay.com/blog/auto-transform-webhook/images/blog/auto-transform-webhook/cover.png)

Now, you will need to provide input and output payload samples. For this example we will use a simple JSON to demonstrate how it works. You can view more complex examples within the dashboard as well.

## [Do's and Don'ts](#dos-and-donts)

The key thing to remember is that the input and output payload values should match.

Input sample:

```
{
  "name": "John",
  "surname": "Doe",
  "age": 30,
  "city": "London"
}
```

Output sample (good):

```
{ 
  "data_type": "person",
  "person": {
    "name": "John",
    "surname": "Doe",
    "age": 30,
    "city": "London"
  }
}
```

Output sample (bad):

```
{
  "name": "Larry",
  "surname": "Sheet"
}
```

## [Try it out](#try-it-out)

Let's add the samples and click "generate function":

![viewing generated function](https://webhookrelay.com/blog/auto-transform-webhook/images/blog/auto-transform-webhook/transform.png)

Once generated, we can click continue and enter the destination URL. Feel free to grab a new testing endpoint from [https://bin.webhookrelay.com/](https://bin.webhookrelay.com/).

You can either click "send a test request" or use `curl` to ping the endpoint

![send test request](https://webhookrelay.com/blog/auto-transform-webhook/images/blog/auto-transform-webhook/send-test-request.png)

On the receiving end, you should see the transformed payload:

![received webhook](https://webhookrelay.com/blog/auto-transform-webhook/images/blog/auto-transform-webhook/received-webhook.png)

It means we have successfully transformed the payload from our initial payload to the new format.

## [Troubleshooting](#troubleshooting)

If the function generation is failing, try to check the following:

- Input and output payloads should have matching values (names, types, etc.)
- Input and output payloads should be valid JSON. We will introduce support for XML, form-data, and other formats in the future. If you have a use case for it, let us know. You can still use the function editor for that.
- Try different examples if one doesn't work. You can also remove any irrelevant values from JSON structures.