> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xpander.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Visual Agent Builder to Code

> Build an AI agent visually in the workbench, test it, then download the code to your IDE for custom development.

<Info>
  **Time to complete:** 5 minutes\
  **What you'll get:** A working AI agent built visually + full source code in your IDE ready for customization
</Info>

Start with zero code using the visual Agent Workbench, then seamlessly transition to full development control with downloadable source code.

<Frame>
  <img src="https://mintcdn.com/xpanderai-099931d1/g6McITA7efa0FP22/images/workbench.png?fit=max&auto=format&n=g6McITA7efa0FP22&q=85&s=263107063b52642e8570f7ee08d3d806" alt="Agent Workbench" width="2762" height="1706" data-path="images/workbench.png" />
</Frame>

## Quick Build-to-Code Process

<Steps>
  <Step title="Create Agent Visually" titleIcon="desktop">
    Go to [app.xpander.ai](https://app.xpander.ai) and click **+ New Agent**.

    The workbench has two main sections:

    * **Left**: Agent configuration (tools, instructions, settings)
    * **Right**: Agent preview (chat testing and visual graph)

    <Tip>No coding required - build everything through the UI!</Tip>
  </Step>

  <Step title="Auto-Generate Instructions" titleIcon="sparkles">
    In the **Instructions** tab:

    1. Click **"Write instructions with AI"**
    2. Enter a simple prompt like: `AI Agent that can get the latest news about any topic from Google News, and send those news via email`
    3. Watch as the system automatically populates:
       * System prompt
       * Agent rules
       * Goals and behavior guidelines

    <Success>AI-optimized prompts generated automatically!</Success>
  </Step>

  <Step title="Add Tools Visually" titleIcon="wrench">
    In the **Tools** tab, click **+ Add tools** and select:

    * **Google News** → Retrieve News Articles By Topic
    * **Built-in actions** → Send Email
    * Add any other tools you need from the gallery
  </Step>

  <Step title="Test in Workbench" titleIcon="play">
    Use the Chat module in the Agent Preview panel to test your agent.

    Test with: `Get the latest news about LLM reasoning models, and send them to me over email`
  </Step>

  <Step title="Download Your Code" titleIcon="download">
    Ready to add custom logic? Click the **Download code** button in the top right.

    Or use the CLI:

    ```bash theme={"dark"}
    # Install CLI
    npm install -g xpander-cli

    # Download your agent code
    xpander agent init "your-agent-name"
    ```

    You'll get a complete project with:

    * Pre-configured Python/Node.js code
    * All your workbench settings
    * Environment variables ready
    * Your tools and instructions baked in
  </Step>
</Steps>

## What You Get in Your IDE

🎉 **Complete codebase** with everything from the workbench:

<CodeGroup>
  ```python Python Agent Structure theme={"dark"}
  from xpander_sdk import Backend, on_task, Task, register_tool
  from agno.agent import Agent

  # Your workbench tools are automatically available
  # Add custom tools here:

  @register_tool
  def my_custom_function(data: str) -> str:
      """Your custom business logic"""
      # Add your own logic here
      return f"Processed: {data}"

  @on_task
  def handle_request(task: Task):
      backend = Backend(task.configuration)
      agent = Agent(**backend.get_args())
      
      # Your workbench instructions are already configured
      result = agent.arun(message=task.to_message())
      task.result = result.content
      return task
  ```

  ```bash Development Workflow theme={"dark"}
  # Test locally (routes all requests to your machine)
  xpander dev

  # Deploy when ready
  xpander deploy
  ```
</CodeGroup>

## Key Benefits of This Approach

<CardGroup cols={2}>
  <Card title="Visual Prototyping" icon="palette">
    Build and test ideas quickly without writing code
  </Card>

  <Card title="AI-Generated Instructions" icon="robot">
    Get optimized prompts and configurations automatically
  </Card>

  <Card title="Seamless Transition" icon="arrow-right">
    Download includes all your visual configurations
  </Card>

  <Card title="Full Development Control" icon="code">
    Add custom functions, APIs, and business logic
  </Card>
</CardGroup>

## Advanced Customization Ideas

<AccordionGroup>
  <Accordion title="Add Custom Business Logic">
    ```python theme={"dark"}
    @register_tool
    def validate_customer(email: str) -> dict:
        """Check customer status in your CRM"""
        # Connect to your database/CRM
        return {"status": "premium", "tier": "gold"}

    @register_tool
    def process_payment(amount: float, customer_id: str) -> str:
        """Process payment via your payment gateway"""
        # Custom payment processing logic
        return "Payment processed successfully"
    ```
  </Accordion>

  <Accordion title="Transform Incoming Data">
    ```python theme={"dark"}
    @on_task
    def handle_slack_message(task: Task):
        # Custom preprocessing of Slack messages
        if task.source == "slack":
            # Add user context, filter sensitive data, etc.
            task.metadata["user_role"] = get_user_role(task.user_id)
        
        # Continue with agent processing
        backend = Backend(task.configuration)
        agent = Agent(**backend.get_args())
        result = agent.arun(message=task.to_message())
        return task
    ```
  </Accordion>

  <Accordion title="External API Integrations">
    ```python theme={"dark"}
    @register_tool
    def check_inventory(product_id: str) -> dict:
        """Check real-time inventory from your system"""
        import requests
        response = requests.get(f"https://api.yourcompany.com/inventory/{product_id}")
        return response.json()
    ```
  </Accordion>
</AccordionGroup>

## Testing Your Custom Code

<Steps>
  <Step title="Local Development">
    ```bash theme={"dark"}
    xpander dev --debug
    ```

    All Slack messages, webhook calls, and UI interactions route to your local machine.
  </Step>

  <Step title="Real-time Testing">
    * Test through the workbench chat UI
    * Send Slack messages (if connected)
    * Trigger webhooks from external systems
    * See debug logs in your terminal
  </Step>

  <Step title="Deploy When Ready">
    ```bash theme={"dark"}
    xpander deploy
    ```

    Your customizations go live instantly with automatic scaling.
  </Step>
</Steps>

## Next Steps

Now that you have both visual design and code control:

1. **[AI Models](/guides/agents/ai-models-intelligence)** - Advanced agent settings
2. **[API Reference](/api-reference)** - Full SDK documentation
3. **[Examples](/Examples)** - See more complex agent implementations

***
