# Snowflake Intelligence

## Installation Options

There are two ways to set up the Euno Snowflake Intelligence agent:

| Method               | Best For                                    | Documentation                                                                                             |
| -------------------- | ------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| **Terraform Module** | Teams with infrastructure-as-code practices | [Terraform Module Guide](https://docs.euno.ai/ai-assistant/snowflake-intelligence-setup/terraform-module) |
| **Manual SQL Setup** | Quick one-time setup                        | This page + [Setup SQL](https://docs.euno.ai/ai-assistant/snowflake-intelligence-setup/setup-sql)         |

> **Recommended**: If your team uses Terraform, we recommend the [Terraform Module](https://docs.euno.ai/ai-assistant/snowflake-intelligence-setup/terraform-module) for easier version control and updates.

***

### Introduction to Snowflake Cortex Agents

Snowflake Cortex Agents are AI-powered orchestration systems that work across both structured and unstructured data sources to deliver insights. They operate through a sophisticated workflow of planning tasks, executing them through various tools (such as Cortex Analyst for SQL generation, Cortex Search for unstructured data, and custom functions), reflecting on results, and generating intelligent responses based on your enterprise data.

Agents eliminate the need for client-side context management by persisting conversation threads, and they can be configured with custom tools to extend their capabilities. In this setup, we're creating an agent that integrates with the Euno.ai platform to provide comprehensive data pipeline intelligence directly within your Snowflake environment.

### What We're Setting Up

This setup script creates a complete Snowflake Intelligence Agent that integrates with Euno.ai's data pipeline platform. Specifically, it configures:

1. **Network Access & Security**
   * External network rule for secure API communication with Euno.ai
   * Encrypted secrets storage for API credentials
   * External access integration for controlled egress traffic
2. **Euno Tools (External Functions) & Tool Wrappers**
   * `euno_instructions`: Get detailed instructions in using Euno MCP Server
   * `euno_count_resources`: Count resources matching a query with optional grouping
   * `euno_fetch_single_resource`: Retrieve a single resource by URI
   * `euno_find_resource_by_name`: Find resources by name using similarity matching
   * `euno_find_resources_for_topic`: Find resources related to a topic using semantic search
   * `euno_get_upstream_lineage`: Get upstream lineage/dependencies for a resource
   * `euno_resrouce_impact_analysis`: Analyze downstream impacts of changes to a resource
   * `euno_search_resources`: Advanced search with EQL or natural language queries
   * `euno_documentation_search`: Search Euno Documentation
   * `euno_documentation_get_full_document`: Retrieve full documentation by URL
   * `euno_documentation_get_surrounding_context`: Get context around a documentation chunk
3. **Snowflake Intelligence Agent**
   * Pre-configured agent (`EUNO_AGENT`) with all four tools
   * Custom instructions optimized for data pipeline queries
   * Budget controls and orchestration settings
4. **Access Control**
   * Role-based permissions (`EUNO_AGENT_USER`) for team access
   * Proper grants for databases, schemas, functions, and warehouses

### Required Customizations

Before running this setup script, you **MUST** customize the following values:

#### 1. Euno Account ID - **REQUIRED**

Replace `<YOUR_ACCOUNT_ID>` with your actual Euno.ai account identifier. You can find this in your Euno.ai dashboard or contact your Euno.ai administrator.

#### 2. Warehouse Name - REQUIRED

Replace `<WAREHOUSE_NAME>` with your actual Euno.ai account identifier. Note that this is case sensitive.

**To check available warehouses**, run:

```
SHOW WAREHOUSES;
```

#### 3. Euno API Key - REQUIRED

{% hint style="info" %}
To obtain an API token, head to Euno -> Click the user card in the bottom of the sidebar -> "Personal API Keys"
{% endhint %}

### Optional Customizations

#### 1. Agent Budget & Limits - **OPTIONAL**

```
orchestration:
  budget:
    seconds: 300
    tokens: 160000
```

Adjust these values based on your use case:

* `seconds`: Maximum execution time per agent request (default: 300 seconds / 5 minutes)
* `tokens`: Maximum token budget per request (default: 16,000 tokens)

#### 2. Orchestration Model - **OPTIONAL**

```
Models:
    orchestration: claude-sonnet-4-5
```

The type of model selected has a direct impact on the speed and accuracy of the results. We suggest choosing leading models, and updating them over time.

### Step-by-Step Setup Instructions

#### Step 1: Prerequisites Check

Before running the setup script, ensure you have:

1. **Account Permissions**: You must have the `ACCOUNTADMIN` role or equivalent privileges to create network rules, secrets, and external access integrations.
2. **Cortex Access**: Verify that your Snowflake account has access to Cortex features:

   ```
   -- Check if CORTEX_USER role exists
   SHOW ROLES LIKE 'CORTEX_USER';
   ```
3. **Warehouse Availability**: Confirm you have an available warehouse (the script uses `CORE` by default):

   ```
   SHOW WAREHOUSES;
   ```
4. **Euno Account Details**: Obtain your Euno.ai account ID and API key.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>To obtain an API token, head to Euno -> Click the user card in the bottom of the sidebar -> "Personal API Keys"</p></div>

#### Step 2: Prepare the Script

1. Download or copy the [SETUP.sql](https://docs.euno.ai/ai-assistant/snowflake-intelligence-setup/setup-sql) script.
2. Open the script in your preferred SQL editor (Snowsight, SnowSQL, or any SQL IDE).
3. Make the required customizations outlined in the previous section

#### Step 3: Execute the Setup Script

1. **Connect to Snowflake** with an account that has `ACCOUNTADMIN` privileges.
2. **Run the entire script** in a single execution. The script is designed to run top-to-bottom without interruption.

   **Via Snowsight (Recommended):**

   * Sign in to your Snowflake account and access Snowsight
   * In the navigation menu, select **Projects** » **Worksheets**
   * Click the **+** button and select **SQL Worksheet** to create a new worksheet, or use **Create Worksheet from SQL File** to import the SETUP.sql file directly
   * If you created a blank worksheet, paste the entire customized SETUP.sql script into the editor
   * In the worksheet context selector (top right), ensure you're using a role with **ACCOUNTADMIN** privileges
   * Select a warehouse to use for execution (any warehouse will work, as the script switches roles internally)
   * Click **Run All** (or press Cmd/Ctrl + Enter to run all statements)
   * Monitor the results pane at the bottom for successful execution messages

   **Via SnowSQL CLI:**

   ```
   snowsql -a <your_account> -u <your_user> -r ACCOUNTADMIN -f SETUP.sql
   ```
3. **Verify Execution**: You should see successful completion messages for:
   * Network rule creation
   * Secret creation
   * External access integration
   * Function definitions
   * Agent creation
   * Role and permission grants

#### Step 4: Verify Installation

Run the following verification queries:

1. **Check the agent exists:**

   ```
   SHOW AGENTS IN SCHEMA SNOWFLAKE_INTELLIGENCE.AGENTS;
   ```
2. **Verify functions are created:**

   ```
   SHOW FUNCTIONS IN SCHEMA SNOWFLAKE_INTELLIGENCE.AGENTS;
   ```

   You should see: `euno_api_caller`, `euno_impact_analysis`, `euno_sql_planner`, `euno_ask_data_pipeline`, and `euno_search_data_pipeline_resources`.
3. **Test basic connectivity:**

   ```
   USE ROLE EUNO_AGENT_USER;
   SELECT SNOWFLAKE_INTELLIGENCE.AGENTS.euno_search_data_pipeline_resources('Find all production tables');
   ```

   This should return a JSON response from the Euno.ai API.

#### Step 5: Grant Access to Users

1. **Switch to ACCOUNTADMIN role:**

   ```
   USE ROLE ACCOUNTADMIN;
   ```
2. **Grant the agent role to specific users** (if not already done in the script):

   ```
   GRANT ROLE EUNO_AGENT_USER TO USER alice;
   GRANT ROLE EUNO_AGENT_USER TO USER bob;
   -- Add more users as needed
   ```
3. **Verify user access:** Have a user log in and run:

   ```
   USE ROLE EUNO_AGENT_USER;
   SHOW AGENTS;
   ```

### Troubleshooting

#### Error: "Network rule validation failed"

**Cause**: Your Snowflake account may not have egress access enabled or there's a firewall blocking outbound connections.

**Solution**: Contact your Snowflake account administrator to enable external network access. Verify that `api.app.euno.ai` is allowed in your organization's network policies.

#### Error: "Object does not exist, or operation cannot be performed"

**Cause**: Missing permissions or incorrect role assignment.

**Solution**:

1. Verify you're using the correct role: `USE ROLE EUNO_AGENT_USER;`
2. Check grants: `SHOW GRANTS TO ROLE EUNO_AGENT_USER;`
3. Ensure ACCOUNTADMIN granted the necessary permissions

#### Error: "HTTP 401" or "HTTP 403" in function responses

**Cause**: Invalid or missing Euno.ai API credentials.

**Solution**:

1. Verify your account ID is correct in the secret
2. Contact Euno.ai support to confirm your API key is active

#### Error: "Warehouse not found"

**Cause**: The selected warehouse doesn't exist in your account.

**Solution**: Update the warehouse name in in the setup script to an existing warehouse in your account.

#### Agent responses are slow or timing out

**Cause**: Warehouse size may be too small, or budget limits are too restrictive.

**Solution**:

1. Use a larger warehouse for the agent functions
2. Increase the `seconds` budget in the agent specification
3. Increase the `tokens` budget if responses are being truncated

#### Cannot see the agent in Snowsight

**Cause**: Database role `SNOWFLAKE.CORTEX_USER` not granted.

**Solution**: The script includes this grant (lines 225-226), but verify with:

```
SHOW GRANTS TO ROLE EUNO_AGENT_USER;
```

If missing, run:

```
USE ROLE ACCOUNTADMIN;
GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE EUNO_AGENT_USER;
```

### Additional Resources

For more information about Snowflake Cortex Agents, refer to the official documentation:

* [Cortex Agents Overview](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents)
* [Configure and Manage Agents](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-manage)
* [Getting Started with Cortex Agents](https://www.snowflake.com/en/developers/guides/getting-started-with-cortex-agents/)

For Euno.ai-specific support:

* Contact your Euno.ai account representative
* Visit the Euno.ai documentation portal
* Email <support@euno.ai> for technical assistance

### Sources

* [Cortex Agents | Snowflake Documentation](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents)
* [Configure and interact with Agents | Snowflake Documentation](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-manage)
* [Getting Started with Cortex Agents](https://www.snowflake.com/en/developers/guides/getting-started-with-cortex-agents/)
* [Optimize Snowflake Intelligence Cortex Agent Setup | Medium](https://medium.com/snowflake/optimize-snowflake-intelligence-cortex-agent-setup-a-complete-ai-powered-guide-f01383ac6969)
