Great! Let’s expand on how to build a multi-user dashboard for sales/support teams that integrates your trained AI agent, stores leads, tracks interactions, and supports collaboration between team members.
🧩 Lesson: Building a Multi-User AI Dashboard for Sales & Support Teams
🎯 Lesson Objective
By the end of this lesson, you’ll be able to:
-
Build a web-based dashboard where multiple team members can log in
-
Access and interact with your AI-powered assistant
-
Track, store, and view lead interactions, responses, and stages
-
Support collaborative updates (notes, replies, handovers)
🔧 Tools You’ll Use
| Tool | Purpose |
|---|---|
🧠 LangChain + Ollama/OpenAI |
AI assistant backend |
💾 SQLite or Firebase |
Store users, leads, interactions |
📊 Streamlit (or React + FastAPI) |
Build UI |
🔐 streamlit-authenticator or JWT |
User login & access control |
🧠 LangChain Memory |
Store chat history per user/lead |
🛠️ Architecture Overview
🔐 Login System → 📊 Dashboard UI → 🤖 AI Agent (trained)
↘
📂 Lead Database (SQL/Firebase)
✅ Step-by-Step: Building the Dashboard
1️⃣ Set Up Authentication
Use streamlit-authenticator for simple password-based login.
pip install streamlit-authenticator
import streamlit as st
import streamlit_authenticator as stauth
# User credentials
users = {
"usernames": {
"alice": {"name": "Alice", "password": stauth.Hasher(["pass123"]).generate()[0]},
"bob": {"name": "Bob", "password": stauth.Hasher(["pass456"]).generate()[0]},
}
}
authenticator = stauth.Authenticate(users, "dashboard", "abcdef", cookie_expiry_days=30)
name, auth_status, username = authenticator.login("Login", "main")
if auth_status:
st.success(f"Welcome {name}")
else:
st.stop()
2️⃣ Build the Dashboard Layout
st.sidebar.title("📊 Dashboard")
view = st.sidebar.selectbox("Choose view", ["Chat", "Leads", "History"])
if view == "Chat":
# Live chat with AI
pass
elif view == "Leads":
# View + filter saved leads
pass
elif view == "History":
# Show previous chats by user or lead
pass
3️⃣ Chat Interface with AI Agent
from langchain.chains import RetrievalQA
from langchain.llms import Ollama
llm = Ollama(model="mistral")
def chat_with_agent(prompt):
result = qa_chain.run(prompt)
return result
user_input = st.text_input("Ask something about a lead, product, or customer issue:")
if user_input:
answer = chat_with_agent(user_input)
st.markdown("### 🤖 AI Response")
st.write(answer)
4️⃣ Track Leads + Save to Database
Use SQLite for simplicity:
import sqlite3
conn = sqlite3.connect("leads.db")
c = conn.cursor()
c.execute("""CREATE TABLE IF NOT EXISTS leads
(name TEXT, email TEXT, notes TEXT, status TEXT, assigned_to TEXT)""")
def save_lead(name, email, notes, status, assigned_to):
c.execute("INSERT INTO leads VALUES (?, ?, ?, ?, ?)", (name, email, notes, status, assigned_to))
conn.commit()
if view == "Leads":
st.title("📁 Add New Lead")
name = st.text_input("Lead name")
email = st.text_input("Email")
notes = st.text_area("Notes or inquiry")
status = st.selectbox("Status", ["New", "Contacted", "Demo Scheduled", "Closed"])
if st.button("Save Lead"):
save_lead(name, email, notes, status, username)
st.success("Lead saved!")
5️⃣ Memory per User or Lead
Store previous conversations per lead in SQLite or JSON.
c.execute("""CREATE TABLE IF NOT EXISTS history
(lead TEXT, user TEXT, message TEXT, response TEXT, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)""")
def save_chat(lead, user, message, response):
c.execute("INSERT INTO history (lead, user, message, response) VALUES (?, ?, ?, ?)", (lead, user, message, response))
conn.commit()
6️⃣ Collaborate Between Users
-
Assign leads to specific team members
-
Add tags or notes visible to all
-
Use filters (e.g., “My Leads”, “Needs Follow-Up”)
🧠 Optional Enhancements
| Feature | Description |
|---|---|
| 🔁 Cron or background task | Auto follow-up reminders |
| 📞 Integrate Twilio / Email | Send outbound messages |
| 🧠 Per-user AI personality | Support team vs. sales tone |
| 📊 Analytics | Show conversion or response rates |
| 🎨 UI Design | Switch to React/FastAPI for more control |
✅ Summary
| Feature | What You Built |
|---|---|
| 🔐 Login system | Authenticated dashboard for team use |
| 🧠 AI assistant | Trained on company data |
| 📁 Lead manager | Add, view, assign, update leads |
| 🧠 Memory + history | Track all conversations per lead/user |
| 💬 Collaborative UI | Sales and support can work together |
🔜 Want to Expand?
Would you like help with:
-
🌍 Deploying this dashboard online (Streamlit Cloud or Hugging Face Spaces)?
-
📤 Integrating WhatsApp, SMS, or Email follow-ups?
-
📈 Adding performance analytics per team member?
60
