Generative BI Agentic Assistant
This hands-on lab guides you through building an intelligent assistant that converts natural language into Structured Query Language (SQL) queries using database schemas. You'll create a powerful agentic chatbot that provides precise data insights on the basis of autonomous reasoning.
Use Case
Build a sophisticated Enterprise Sales Advisor chatbot that analyzes ticket sales data for various events and performances.
Prerequisites
Access to the Redshift catalog for enterprise sales data.
Basic familiarity with the platform interface.
Step 1: Catalog Creation
Navigate to Catalog Schema in menu bar on the left side.
Click on Add new in the top corner on the right side.
Configure the catalog:
Name: "Enterprise-Sale-Data".
Connector type: Redshift.
Enter the required credentials provided separately.
Save the catalog.
Open the saved catalog.
Browse and select all the tables and click on Import schema on the right side.
Within Catalog explorer, generate business metadata for each table:
Select each table individually.
Enable checkboxes to generate metadata.
Click Generate Metadata on the right side.
Publish the catalog.
Refer the video tutorial for creating catalog.
Step 2: Create an Agent Prompt
Navigate to Prompt Playground on the left side.
Click on Add new in top corner on the right side.
Click on Prompt templates on the right side.
Select the Enterprise Sales Agent-Redshift template.
Increase the Max State Updates from 3 to 20 for complex reasoning.
Scroll down to Agent input box to add the following test query : "What is the total sales amount for each seller?"
Ensure that you scroll up to rename your prompt before saving.
You will be directed to the Prompt Playground and select your prompt:
Click on the Tools tab to configure the following tools:
Catalog Tool
Click on Add new in tools.
Enter name as “Enterprise Sales Catalog”.
Enter the Description as “The catalog tool uses natural language questions to search relevant tables and columns to create a SQL query”.
Select Type: Catalog.
Select the catalog created in Step 1 from the dropdown menu.
Save the tool.
Database Tool
Click Add new in tools.
Enter name as “Sales Performance Datawarehouse”.
Enter the Description as “This tool lets you run SQL queries on a specified database and table, then retrieve the results.”.
Select Type: Database.
Select Connector: Redshift.
Enter the Redshift Datawarehouse credentials provided.
Save the tool.
Test & Compare :
Click on Test and compare tab.
Select different models [Hint: Compare Claude Sonnet 3.7, Claude Sonnet 3.5 v2, Amazon Nova Pro].
Click on Test right below.
Compare the output of the selected Models.
Click on Select as best answer to select the best-performing model as the Primary Model.
Optionally Select as best answer to assign a Fallback Model.
Click Save prompt run in the right corner.
Save and publish the prompt.
Step 3: Create Agent 2.0 Recipe
Navigate to Recipe on the left side.
Click Add New in the top corner.
Configure recipe details:
Name: "Enterprise Sales Advisor".
Description: "Intelligent assistant for sales data analysis".
Type: Agent 2.0
Set up the workflow :
Drag and drop Chat node:
In the Conversation history dropdown, select 4 messages.
Enable Generate follow-up questions.
Drag and drop Start node:
Connect the Chat node to the Start node.
Drag and drop Agent node:
Select your created Agent prompt at step 2.
Scroll down and Set the Messages dropdown to All Messages to maintain conversation context.
Connect the Start node to the Agent node.
Drag and drop End node:
Connect the Agent node to the End node.
On the right side, set the Number of state updates to a higher value such as 75.
Click on the canvas, then select Save.
Select your recipe from the recipe table.
Ensure you click on Publish the recipe.
Click the Test button on the right side to verify functionality.
Test with sample questions:
What is the average sales amount among top 10 sellers?
What is the total sales amount for top 10 sellers?
What is the total sales amount for each seller?
Refer the video to create and test recipe:
Step 4: Deploy Your Copilot
Click the Export button located at the top-right corner of the recipe interface.
Click Add new to create a deployment configuration.
Complete the export form:
Name: "Enterprise Sales Assistant"
Add Welcome message, as preferred.
Description: "The Enterprise Sales Advisor Copilot is designed to help you analyze and optimize your sales data."
Add Seed Questions:
What is the average sales amount among top 10 sellers?
What is the total sales amount for the top 10 sellers?
What is the total sales amount for each seller?
Add Error message, as preferred.
Enable positive (thumbs up) and negative (thumbs down) feedback.
Users can also add custom feedback.
Select Show traces.
Click on Save.
Your Copilot will appear in the Copilots section on the left side.
Step 5: Test Your Sales Advisor
Navigate to the Copilot on the left side and open your chatbot.
Ask sample questions:
How much total revenue was generated from ticket sales for events in the "Shows" category by each seller?
Which events have generated the most revenue, based on sales from associated listings?
What is the total sales amount by each user, including their name and email?
Refer the video to test copilot:
All the best!
Last updated