How to build a AI Data Assistant for Sales Reps

Paul Omenaca

Paul Omenaca

@houmland
How to build a AI Data Assistant for Sales Reps

How to build an AI data assistant for sales reps


End
UI

Custom ChatGPT for Sales Representatives to chat with Snowflake Data

Steps:

  1. Connect Snowflake to Stack AI
  2. Set up the data source and AI query
  3. Generate a response with a LLM
  4. Connect more data sources
  5. Set up a chat assistant interface
  6. Share it with your team
  7. Keep track of usage and analytics
  8. Improve your data assistant tool

1. Connect Snowflake to Stack AI

At its core, Snowflake acts as a cloud layer on top of data infrastructure to consolidate, speed up and scale data operations without running into hard limits. It’s not designed to be a user interface to explore data, which makes it a better fit for engineers building systems, not so much for non-technical users.

On the Stack AI dashboard, click Connections at the left side.


Click
Connections

Click Connections

You can connect all your data sources on this screen and they’ll be available in all future projects you create. Click the New connection button at the top right.


Click New
Connection

Click New Connection

Find and click the Snowflake option.


Click
Snowflake

Click Snowflake

Enter the credentials and identifiers in the popup. Here’s a quick breakdown of what you’ll need:

  • User and Password are the same credentials you use to log into your Snowflake account.
  • Account refers to the Snowflake account identifier. This connection will be made via the driver, not as a SQL query, so be sure to separate both parts of this value with a hyphen, not a dot.
  • In Warehouse, type the name of the warehouse you’d like to use. You can see which ones you currently have by heading to the Snowflake dashboard, clicking the Admin tab and selecting Warehouses.
  • Role is the account role used for access control. Type the name of the role and make sure it has enough privileges to access the databases you want to use in Stack AI.
  • Database and Schema identify the data source. Copy the names of each and paste them in the corresponding input fields.

Click Create connection to continue.


Click Create
Connection

Click Create Connection

This Snowflake schema was successfully connected to Stack AI. You need to create new connections for each new schema, so repeat the process for every one you’d like to connect to the sales data assistant. You can label each data source by clicking the 3-dot icon and clicking Edit.


Edit to Rename Data
Source

Edit to Rename Data Source

Once you’ve connected all the Snowflake data sources, create a new Stack AI project: click the All folder at the top left, and then on the New Project button at the top right.


Create a New
Project

Create a New Project

Select New Project to start from scratch.


Start from
Scratch

Start from Scratch

2. Set up the data source and AI query

Set up the SQL query with AI

First, we’ll set up a way to translate the user’s natural language prompt into a SQL query to send to Snowflake. On the left side, expand the LLMs section, drag and drop a Text-to-SQL node onto the canvas.


Drop
Text-to-SQL

Drop Text-to-SQL

Set the SQL language to Snowflake. Notice that Stack AI also supports other languages, such as Postgres, MySQL and Synapse.


Pick SQL
Language

Pick SQL Language

Write an example of the table schema you’re planning to add to the project within the node. You can list the data fields to help the LLM understand what types of queries it can build. Alternatively, you can copy and paste the table definition available in the Snowflake interface here.


Paste Table
Definition

Paste Table Definition

Remember: this node is an LLM node. You can write additional instructions for data handling and formatting here, as well as passing documentation or examples.

Connect the input to the Text-to-SQL node.


Connect Input to
Text-to-SQL

Connect Input to Text-to-SQL

Configure the customer data source node

We’re going to add the Snowflake data source into the project. Expand the Data Loaders section. Then, drag and drop a Snowflake node onto the canvas.


Drop Snowflake onto
Canvas

Drop Snowflake onto Canvas

Click the Connect to Snowflake button within the node.


Connect to
Snowflake

Connect to Snowflake

The settings side tab appears on the right side of the screen. Select a connection through the corresponding dropdown. For this tutorial, we’ll choose the Customers data table we connected in the previous section.


Select a
Connection

Select a Connection

Connect the Text-to-SQL node to the Snowflake node. Make sure the example table schema matches the data source you selected.


Connect SQL to
Snowflake

Connect SQL to Snowflake

Test the connection

Let’s test the functionality before continuing. Connect the Snowflake node to the output node temporarily so we can see the results.


Connect Snowflake to
Output

Connect Snowflake to Output

Write a question about this data source’s data inside the node’s input field. Since our table contains customer data, I’ll ask about the total number of customers.


Write a Test Question in
Input

Write a Test Question in Input

Click the Run button at the top right to test this workflow.


Click Run

Click Run

You’ll see the process unfolding in real time, both on the canvas and on a dedicated report side tab. This is useful for testing and troubleshooting, especially as you build more complex projects.


Test Results

Test Results

3. Generate a Response with an LLM

Before we begin this step: if you connected the Snowflake node to the output node for testing, please disconnect it now.


Disconnect
Output

Disconnect Output

The data retrieved from Snowflake is in JSON format. We can make it easier to read by processing it with an LLM—and, at the same time, we can ask it to summarize, correlate, or report on that data. Expand the LLMs section, drag and drop the Azure LLM onto the canvas.


Drop the Azure
LLM

Drop the Azure LLM

Connect the main input to the Azure LLM.


Connect Input to Azure
LLM

Connect Input to Azure LLM

Then, connect the Snowflake node to the Azure LLM.


Connect Snowflake to Azure
LLM

Connect Snowflake to Azure LLM

The LLM needs guidance on how to handle its inputs. Write the following instructions into the corresponding input field:

You receive a result from a query to the company's data warehouse and a user request related to that query. Answer the user request in natural language. Be brief, clear, and to the point. The user doesn't have access to Snowflake and can't interact with it. Always respond with Markdown formatting for tables and headers.


Paste System
Prompt

Paste System Prompt

The user prompt packs the rest of the information needed to make the generation happen correctly. Copy and paste the following into the corresponding input field:

Data warehouse queries used to respond to the user's request.

<SQL_customers> {snowflake-0} </SQL_customers>

User request: {in-0}


Enter User
Prompt

Enter User Prompt

Notice the values in brackets. These are Stack AI variables:

{in-0} holds the prompt that the user writes into the chat assistant. {snowflake-0} contains the full response coming from the database. For the Snowflake data, we enclosed it in XML brackets (<SQL_customers> </SQL_customers>). While optional, labeling the data improves AI model interpretation and accuracy.

Since the LLM’s responses are likely to contain a lot of table data, it’d be useful to render some of it as charts for better visualization. To activate this feature, click the settings icon at the top right of the Azure LLM.


Click Settings Azure
LLM

Click Settings Azure LLM

Toggle on the Charts option to activate the feature. Also, since we’re building an AI chatbot, it’ll be useful if it remembers the conversation as it unfolds. Turn on the Memory feature.


Memory and
Charts

Finally, connect the Azure LLM to the output.


Connect Azure LLM to
Output

Connect Azure LLM to Output

If you haven’t deleted the question you typed into the input earlier, you can click Run again to see the results in the output node.

4. Connect more data sources

You can connect as many Text-to-SQL plus Snowflake pairs as you want to draw data and build a more detailed report with the Azure LLM. We’ll connect one more data source to show how this works.

Set up another SQL query with AI

Repeat the steps to add a Text-to-SQL node: expand the LLMs section, drag and drop it onto the canvas.


Drop Another Text-to-SQL
Node

Drop Another Text-to-SQL Node

Connect the main input to the Text-to-SQL node.


Connect Input to Text-to-SQL
Node

Connect Input to Text-to-SQL Node

Set the SQL language to Snowflake and paste the table schema into the corresponding input field. You can also add special instructions or documentation to help the LLM generate the query.


Configure Language and Table
Definition

Configure Language and Table Definition

Configure the sales data source node

Next, expand the Data Loaders section, drag and drop another Snowflake node onto the canvas.


Drop Second Snowflake
Node

Drop Second Snowflake Node

Click the Connect to Snowflake button and choose the data source from the dropdown.


Connect the Second
Snowflake

Connect the Second Snowflake

Notice that you can rename the nodes to keep your project organized. Use the Rename button in the settings tab to change the name of the Snowflake node. For our tutorial, we’ll rename ours to Sales.


Rename Snowflake
Node

Rename Snowflake Node

Connect the second Text-to-SQL node to the second Snowflake node.


Connect Text-to-SQL to Second Snowflake
Node

Connect Text-to-SQL to Second Snowflake Node

Notice that you can also rename the Text-to-SQL nodes. Click the edit icon at the top right of the node to do so.


Rename Text-to-SQL
Node

Rename Text-to-SQL Node

Connect to the Azure LLM

Connect the Snowflake node to the Azure LLM.


Connect Snowflake to
LLM

Connect Snowflake to LLM

Every time you add a new data source, you need to update the user prompt to add the variable containing the data. Add the following line to the user prompt in the Azure LLM:

<SQL_sales\> {snowflake-1} \</SQL_sales\>

Add Sales Variable to
Prompt

Add Sales Variable to Prompt

Now, write a new question in the main input field that correlates the data from both data sources. In our case, we’ll ask it to break down sales by customer. Click Run to test.


Add Test Question and
Run

Add Test Question and Run

Take a look at the output node to see the test’s results.


Test Output

Test Output

5. Publish the project

The workflow part of the project is complete. On the top right side of the screen, click Publish. Remember to always do so when making changes to the architecture or settings.


Click Publish

Click Publish

6. Set up a chat assistant interface

It’s time to set up the user interface that your sales team will use. On the top left side of the screen, click the Export tab.


Click Export

Click Export

Stack AI publishes new projects as a form, but we want a chat assistant instead. Click the dropdown and change it to that setting.


Click Chat
Assistant

Click Chat Assistant

You can set a custom domain, add a name and a description to improve the user experience. You can also add a custom AI disclaimer message to remind users what to do about the information they’ll read here.


General
Settings

General Settings

Style lets you customize the image of the tool. You can change it to something that better reflects the functionality or adds your company’s branding.


Style Tab

Style Tab

Configuration offers 4 useful settings:

  • User feedback lets users upvote or downvote answers to help you assess the usefulness of the tool.
  • Related results suggests follow-up questions after the user sends the first prompt.
  • Show steps improves user experience as it shows the current state of the assistant (thinking, searching, and so on).
  • Conversation starters lets you add starter prompts the user can click to easily begin an interaction.

Configuration
Settings

Configuration Settings

Stack AI offers robust security tools to keep this interface safe from unauthorized access. At a basic level, you can set a unique password. If you prefer more granularity, you can instead activate SSO and choose which users have access to the tool. And if you’re planning to embed this interface into your internal tools, you can whitelist the URLs of the target pages to make sure it won’t load anywhere else.


Configuration
Settings

Configuration Settings

Every time you make changes to the interface, click the Save Interface button at the top right.


Configuration
Settings

Configuration Settings

6. Share it with your team

Sharing the AI data assistant with your sales team is easy: simply copy the link at the top of the screen and paste it in an email, text message, or an internal communications channel.


Copy Link

Copy Link

You can also share your project with other builders using Stack AI. Click the Share button at the top right and type in their emails.


Share with
Builders

Share with Builders

This only shares a copy of the project. Any changes others make will not affect your work.

7. Keep track of usage and analytics

On the top left side of the screen, click the Analytics tab.


Click
Analytics

Click Analytics

Here you can see a report of errors, users, tokens, and total runs. Below, you can see a list of recent runs and add extra columns to see less or more data.


Analytics Tab
Overview

Analytics Tab Overview

You can also get an AI-generated report with insights on the most common questions and answers. If you’d like to take this report data elsewhere for analysis, you can download it as a CSV or JSON file.


AI Report Download
Logs

AI Report Download Logs

You can also review the conversations your team is having with the AI assistant by clicking on the Manager tab at the top left.


Click Manager
Tab

Click Manager Tab

You can browse the list on the right and click any of them to read the conversation.

8. Improve your data assistant tool

Take note of feedback about your AI data assistant for sales and use it to improve the architecture and prompts. At the same time, Stack AI makes it easy to keep up with the latest AI technology, as you only need a couple of clicks to upgrade to the best models available. On any LLM node, click the Settings button at the top right to open.


Click Azure LLM
Settings

Click Azure LLM Settings

Use the Provider and Model dropdowns to lock in on your preferred model. Remember to run a test and to publish to save the changes.


Provider and
Model

Provider and Model

Wrapping up

With more data on their hands, your sales team will be able to develop a more strategic view, making better decisions when looking for new leads, qualifying them, and eventually driving them to conversion. All without lengthy and costly technical upskilling programs.

But this is just the beginning of what Stack AI can do for your company. Create a free account and explore our other tutorials: