AI-Powered Transform Generation
Generate transform code from natural language descriptions using Hookbase's built-in AI.
Overview
Instead of writing a transform from scratch, describe what you want in plain English and let AI generate the code for you.
AI generation supports every transform language except XSLT:
| Language | transformType | Notes |
|---|---|---|
| JSONata | jsonata | |
| JavaScript | javascript | Generates a function transform(data) { ... } |
| TypeScript | typescript | Generates a typed transform(data) function. Types are stripped before it runs, not checked |
| Liquid | liquid | |
| JMESPath | jmespath | Generates a single expression |
| JSON Logic | jsonlogic | Generates a single JSON rule. Rules are declarative and execute no code |
| jq | jq | Generation works, but jq transforms can only be tested and saved where transform isolation is enabled. The dashboard greys jq out until then |
XSLT is not offered for AI generation. Write XSLT stylesheets by hand.
Available on: Starter, Pro, and Business plans.
How It Works
- Click AI Generate in the Transforms page
- Describe what the transform should do
- Optionally provide a sample input payload
- Select the target language (any of the languages above)
- Review the generated code
- Apply it to a new or existing transform
Using the AI Generator
Via Dashboard
Navigate to Tools → Transforms and click the AI Generate button. Fill in:
| Field | Required | Description |
|---|---|---|
| Description | Yes | Plain English description of the transform |
| Transform Type | Yes | Any language in the table above. Languages this deployment cannot run are shown disabled |
| Sample Input | No | Example webhook payload for better accuracy |
Via API
curl -X POST https://api.hookbase.app/api/organizations/{orgId}/transforms/generate \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"description": "Extract customer email and order total from Stripe checkout.session.completed",
"transformType": "jsonata",
"sampleInput": {
"type": "checkout.session.completed",
"data": {
"object": {
"customer_email": "jane@example.com",
"amount_total": 4999,
"currency": "usd"
}
}
}
}'The response is streamed via SSE:
data: {"type":"token","token":"{\n"}
data: {"type":"token","token":" \"email\": $.data.object.customer_email,\n"}
data: {"type":"token","token":" \"total\": $.data.object.amount_total / 100\n"}
data: {"type":"token","token":"}"}
data: {"type":"done","code":"{\n \"email\": $.data.object.customer_email,\n \"total\": $.data.object.amount_total / 100\n}","valid":true}Example Prompts
Here are some effective prompts to try:
| Prompt | Language | Output |
|---|---|---|
| "Extract email and name from a Stripe customer.created event" | JSONata | { "email": $.data.object.email, "name": $.data.object.name } |
| "Convert Shopify order to a Slack message block" | JSONata | Structured Slack Block Kit payload |
| "Filter to only include items over $50 and sum their prices" | JSONata | Filtered and aggregated result |
| "Rename all snake_case keys to camelCase" | JavaScript | JS transform with key mapping |
| "Format as an HTML email template with order details" | Liquid | Liquid template with HTML |
| "Return the repository name and the commit messages from a GitHub push" | JMESPath | {repo: repository.full_name, messages: commits[].message} |
| "Label the order high if the amount is at least 1000, otherwise low" | JSON Logic | {"if": [{">=": [{"var": "amount"}, 1000]}, "high", "low"]} |
| "Typed function that returns the order id and the number of line items" | TypeScript | function transform(data: Order) { ... } |
Tips for Best Results
- Be specific: "Extract customer email from Stripe checkout" works better than "get email"
- Provide sample data: Including a sample payload dramatically improves accuracy
- Specify the output shape: If you know what the output should look like, describe it
- Iterate: Generate, review, and regenerate with a refined description if needed
- Always review: AI-generated code should be tested before using in production
Rate Limits
AI transform generation is rate-limited to 10 requests per minute per organization.
See Also
- Transforms Guide — Manual transform creation
- Transforms API — Full API reference
- Pipeline Architecture — How transforms fit in the pipeline