AI Assistant
Explain, refactor, and generate Groovy/JavaScript scripts with GPT-4o — right inside the editor.
Availability: AI features require a Pro or Enterprise licence and an OPENAI_API_KEY environment variable set on your CF deployment.
Setup
cf set-env cpi-developer-studio OPENAI_API_KEY "sk-..."
cf set-env cpi-developer-studio OPENAI_MODEL "gpt-4o" # optional, default: gpt-4o
cf restage cpi-developer-studio Once set, the ✨ AI button appears in the Script Editor toolbar and in the Message Log error panel.
Features
Explain Script
Opens a side panel with a plain-English explanation of what the current Groovy/JS script does — step by step. Useful for understanding code written by others or from old projects.
Generate Script
Describe what you want in plain English and the AI writes the Groovy code. Examples:
- "Read the header X-Sender and set it as a property called senderID"
- "Convert the body from XML to JSON using JsonOutput"
- "Loop through all items in the body and filter where status equals ACTIVE"
The generated code is inserted into the editor where your cursor is. Review before saving.
Refactor Script
Paste or select existing code and ask the AI to refactor it for readability, performance, or to follow CPI best practices (proper stream handling, null checks, etc.).
Fix Error
In the Message Log, click ✨ Fix with AI on any failed message. The AI reads the error stack trace and the iFlow's script, then suggests a specific code fix with an explanation.
Privacy & Data
Script content is sent to the OpenAI API using your own API key. CPI Studio does not store or log script content on its servers. Review OpenAI's privacy policy before using AI features with sensitive integration content.
Cost Estimates
| Model | Cost per ~1000 word script | Best for |
|---|---|---|
| gpt-4o | ~$0.005 | Best quality, recommended |
| gpt-4o-mini | ~$0.0003 | High volume / cost-sensitive |