Modern organizations face the challenge of managing both structured data (like metrics and KPIs) and unstructured data (such as customer conversations, emails, and meeting transcripts). The ability to analyze and derive insights from both types of data is crucial for understanding customer needs, improving processes, and driving business growth.

In this quickstart, you'll learn how to build an Intelligent Sales Assistant that leverages Snowflake's capabilities for analyzing sales conversations and metrics. Using Cortex Agents and Streamlit, we'll create an interactive and intuitive assistant.

What is Snowflake Cortex?

The platform leverages three powerful Snowflake Cortex capabilities:

Cortex Analyst

Cortex Search

Cortex Agents

The Cortex Agents is a stateless REST API endpoint that:

Snowflake Intelligence

Snowflake Intelligence uses agents, which are AI models that are connected to one or more semantic views, semantic models, Cortex search services, and tools. Agents can answer questions, provide insights, and show visualizations. Snowflake Intelligence is powered by Cortex AISQL, Cortex Analyst, and Cortex Search.

These capabilities work together to:

  1. Search through sales conversations for relevant context
  2. Go from Text to SQL to answer analytical questions
  3. Combine structured and unstructured data analysis
  4. Provide natural language interactions with your data

What You'll Learn

What You'll Build

A full-stack application that enables users to:

What You'll Need

Before you begin, make sure you have the following:

Step 1. In Snowsight, create a SQL Worksheet and open setup.sql to execute all statements in order from top to bottom.

This script will:

Step 2. Upload the semantic model:

Step 1. In Snowsight, Click on AI ML > Agents. Step 2. Click on Create Agents.

This agent orchestrates between Sales data for analyzing sales conversations using cortex search service (SALES_CONVERSATION_SEARCH) and metrics (sales_metrics_model.yaml)
Agent Setup step 3

Step 4. Click on the left pane for Instructions and enter the following response instructions: You are a specialized analytics assistant focused on providing concise responses about sales metrics and sales conversations. Your primary objectives are For structured data queries (metrics, KPIs, sales figures) Use the Cortex Analyst api which is YAML-based functionality. Provide direct, numerical answers with minimal explanation. Format responses clearly with relevant units and time periods. Only include essential context needed to understand the metric. For unstructured content from PDF reports. Utilize the cortex search service "SALES_INTELLIGENCE.DATA.SALES_CONVERSATION_SEARCH. Extract relevant information from conversations. Summarize findings in brief, focused responses. Maintain context from the original sales conversations. Operating guidelines - Always identify whether you're using cortex analyst or cortexsearch for each response. Keep responses under 3-4 sentences when possible. Present numerical data in a structured formatDon't speculate beyond available data

Agent Setup step 4

You can also add a Sample Question:

Step 5. Click on the left pane for Tools to add. This is where you can add the Cortex Analyst semantic yaml file that was uploaded to the stage or the semantic view.

Agent Setup step 5

Step 6. Click on Cortex Search Services - this is the unstructured data retrieval of the sales conversations by clicking on the +Add Give it a name Sales_conversation_search, Give it a description Cortex Search Sales Service.

Agent Setup step 6

Step 7. Click save on top right to save any changes. Now click on Orchestration in the left pane and leave the orchestration to auto. This is where we can use other models to choose the orchestration from but for this hol will leave it to auto.

Agent Setup step 7

Step 8. Click on access to ensure SALES_INTELLIGENCE_RL has access. This is where we control which role has access to run this agent. Click on Save

Agent Setup step 8

With the Agent created, we can now chat with it via Snowflake Intelligence. Click on AI ML > Snowflake Intelligence. Let's ask the questions to test:

You can also interact with the Agent by calling the Snowflake REST API at /api/v2/databases/{DATABASE}/schemas/{SCHEMA}/agents/{AGENT}:run. We created a simple streamlit app that interacts with the REST API here. You can use it as a building block to build your own applications. Let's run the streamlit and call the API locally:

Step 1. To authenticate to the API, let's create a Personal Access Token.

Step 2. Clone the repo: git clone git@github.com:Snowflake-Labs/sfguide-getting-started-with-cortex-agents.git

Step 3. Find your account URL in Snowsight: Click on your profile (bottom left corner) » Account » View account details.

Step 4. In the cloned repo run the following commands (replacing the PAT and ACCOUNT_URL):

python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt

CORTEX_AGENT_DEMO_PAT=<PAT> \
CORTEX_AGENT_DEMO_HOST=<ACCOUNT_URL> \
CORTEX_AGENT_DEMO_DATABASE="SNOWFLAKE_INTELLIGENCE" \
CORTEX_AGENT_DEMO_SCHEMA="AGENTS" \
CORTEX_AGENT_DEMO_AGENT="SALES_INTELLIGENCE_AGENT" \
streamlit run data_agent_demo.py

Congratulations! You've successfully built an Intelligent Sales Assistant using Snowflake Cortex capabilities. This application demonstrates the power of combining structured and unstructured data analysis through:

What You Learned

Related Resources