Most RevOps teams still rely on Salesforce reports and dashboards that take forever to configure and never look quite right. With Python, you can build a live pipeline dashboard in under an hour that pulls directly from your Salesforce org and displays exactly what leadership wants to see.
What You Need¶
Before you start, install the two key libraries:
pip install simple-salesforce streamlit pandas
You will also need your Salesforce credentials: username, password, and security token. Store these as environment variables to keep them out of your codebase.
Connecting to Salesforce¶
The simple_salesforce library makes authentication straightforward. Here is the connection setup:
import os
from simple_salesforce import Salesforce
sf = Salesforce(
username=os.environ["SF_USERNAME"],
password=os.environ["SF_PASSWORD"],
security_token=os.environ["SF_TOKEN"],
)
Once connected, you can run any SOQL query against your org.
Pulling Pipeline Data¶
The core query grabs open opportunities with the fields your leadership team cares about:
import pandas as pd
query = """
SELECT Name, StageName, Amount, CloseDate,
Owner.Name, Account.Name
FROM Opportunity
WHERE IsClosed = false
AND Amount > 0
ORDER BY CloseDate ASC
"""
results = sf.query_all(query)
df = pd.DataFrame(results["records"]).drop(columns=["attributes"])
You may need to flatten nested fields like Owner.Name depending on how your org is structured. A quick helper handles that:
df["OwnerName"] = df["Owner"].apply(lambda x: x["Name"])
df["AccountName"] = df["Account"].apply(lambda x: x["Name"])
Building the Streamlit Dashboard¶
Streamlit turns your data into an interactive web app with minimal code. Here is the full dashboard layout:
import streamlit as st
st.set_page_config(page_title="Pipeline Dashboard", layout="wide")
st.title("Sales Pipeline Dashboard")
# Summary metrics
col1, col2, col3 = st.columns(3)
col1.metric("Total Pipeline", f"${df['Amount'].sum():,.0f}")
col2.metric("Open Deals", len(df))
col3.metric("Avg Deal Size", f"${df['Amount'].mean():,.0f}")
# Pipeline by stage
st.subheader("Pipeline by Stage")
stage_summary = df.groupby("StageName")["Amount"].sum().sort_values(ascending=False)
st.bar_chart(stage_summary)
# Deal table with filters
st.subheader("Deal Details")
selected_stage = st.selectbox("Filter by Stage", ["All"] + list(df["StageName"].unique()))
if selected_stage != "All":
df = df[df["StageName"] == selected_stage]
st.dataframe(df[["Name", "AccountName", "OwnerName", "StageName", "Amount", "CloseDate"]])
Run it with:
streamlit run dashboard.py
Adding Auto-Refresh¶
To keep the dashboard current throughout the day, add a refresh interval at the top of your script:
st.cache_data(ttl=300) # Cache data for 5 minutes
def load_pipeline():
results = sf.query_all(query)
return pd.DataFrame(results["records"]).drop(columns=["attributes"])
This ensures fresh data every five minutes without hammering the Salesforce API.
Key Takeaways¶
- You can build a fully functional Salesforce pipeline dashboard with Python, simple_salesforce, and Streamlit in under 60 minutes
- Streamlit handles the entire frontend so you never have to write HTML, CSS, or JavaScript
- Caching with a TTL keeps the dashboard responsive while respecting Salesforce API limits
- This approach gives RevOps teams complete control over layout, metrics, and filtering that native Salesforce dashboards make difficult