Data transformation is a key step in building integrations between services as the schemas of the data expected or returned by these services keeps changing.
To overcome this, you can use the Data transformer tool.
On the tool you can enter a JSON payload in its current and desired format and get a script to perform the transformation.
Here's an example:
Clicking 'Generate code' button will present you with a choice to send either schemas or full JSON data.
Sending full JSON gives OpenAI that extra context which you may have to provide yourself if you only send schemas.
Hence sending full JSON produces more reliable results but ensure there is no sensitive data in the Input/Output JSONs before you choose that option.
Below the function, you will also get a diff-checker view of the JSON produced by the function and the JSON that you expected (Output JSON):
If both look the same as shown above, this means OpenAI was able to generate a good script. You can verify the function's correctness by testing it using more inputs and outputs.
If you notice some differences (highlighted by red, green and yellow colors) on the diff-checker component as shown above, it indicates the script was not good enough and you may need to provide some context in the context box.
For every variable, you need to define the name of the variable, its value and its datatype.
You can add as many variables you want by clicking 'Add More..' button.
Finally, provide some context on what you want the funtion to do and click 'Generate code'