Sales Pipeline Template
The sales pipeline template provides a complete CRM (Customer Relationship Management) system for managing deals, tracking opportunities through sales stages, and generating revenue forecasts.
Topic: Sales Pipeline & Deal Management
This template is perfect for:
- Sales teams tracking deals
- Revenue forecasting
- Pipeline management
- Win/loss analysis
- Sales performance reporting
The Code
ADD TOOL "create-deal"
ADD TOOL "update-stage"
ADD TOOL "list-deals"
ADD TOOL "deal-details"
ADD TOOL "pipeline-report"
ADD TOOL "forecast-revenue"
USE KB "sales-pipeline.gbkb"
SET CONTEXT "sales pipeline" AS "You are a sales assistant helping manage the sales pipeline. Help with creating new deals, updating deal stages, viewing pipeline status, generating sales forecasts, and analyzing win/loss rates."
CLEAR SUGGESTIONS
ADD SUGGESTION "newdeal" AS "Create a new deal"
ADD SUGGESTION "pipeline" AS "Show my pipeline"
ADD SUGGESTION "update" AS "Update a deal stage"
ADD SUGGESTION "forecast" AS "View sales forecast"
ADD SUGGESTION "report" AS "Generate pipeline report"
BEGIN TALK
**Sales Pipeline Manager**
I can help you with:
• Create new deals and opportunities
• View and manage your pipeline
• Update deal stages
• Generate sales forecasts
• Pipeline analytics and reports
• Track win/loss rates
Select an option or tell me what you need.
END TALK
BEGIN SYSTEM PROMPT
You are a sales pipeline assistant.
Pipeline stages:
- Lead: Initial contact, not qualified
- Qualified: Budget, authority, need, timeline confirmed
- Proposal: Quote sent
- Negotiation: Active discussions
- Closed Won: Successfully closed
- Closed Lost: Lost or no decision
Always encourage sales reps and provide actionable insights.
Confirm changes before saving.
Use currency format for amounts.
END SYSTEM PROMPT
Sample Dialogs
These conversations show how the sales pipeline template works in real-world scenarios.
Dialog 1: Creating a New Deal
💼
Sales Pipeline
online
Today
Dialog 2: Viewing Pipeline
💼
Sales Pipeline
online
Dialog 3: Update Deal Stage
💼
Sales Pipeline
online
Dialog 4: Revenue Forecast
💼
Sales Pipeline
online
Keywords Used
| Keyword | Purpose |
|---|---|
ADD TOOL | Register pipeline management tools |
USE KB | Load sales methodology knowledge base |
SET CONTEXT | Define sales assistant behavior |
ADD SUGGESTION | Create quick action buttons |
BEGIN TALK | Welcome message with options |
BEGIN SYSTEM PROMPT | Sales stage definitions and guidelines |
Pipeline Stages
| Stage | Win Probability | Description |
|---|---|---|
| Lead | 20% | Initial contact, not yet qualified |
| Qualified | 40% | BANT criteria confirmed |
| Proposal | 50% | Quote or proposal sent |
| Negotiation | 80% | Active deal discussions |
| Closed Won | 100% | Deal successfully closed |
| Closed Lost | 0% | Deal lost or abandoned |
Template Structure
sales-pipeline.gbai/
├── sales-pipeline.gbdialog/
│ ├── start.bas # Main entry point
│ ├── create-deal.bas # New deal creation
│ ├── update-stage.bas # Stage progression
│ ├── list-deals.bas # Pipeline view
│ ├── deal-details.bas # Individual deal info
│ ├── pipeline-report.bas # Analytics reports
│ └── forecast-revenue.bas # Revenue forecasting
├── sales-pipeline.gbdrive/
│ └── templates/ # Proposal templates
├── sales-pipeline.gbkb/
│ └── sales-methodology.md # Sales best practices
└── sales-pipeline.gbot/
└── config.csv # Bot configuration
Create Deal Tool: create-deal.bas
PARAM company AS STRING LIKE "Acme Corp" DESCRIPTION "Company or account name"
PARAM value AS NUMBER LIKE 50000 DESCRIPTION "Deal value in dollars"
PARAM close_date AS DATE LIKE "2025-03-31" DESCRIPTION "Expected close date"
PARAM contact AS STRING DESCRIPTION "Primary contact name" OPTIONAL
PARAM notes AS STRING DESCRIPTION "Deal notes" OPTIONAL
DESCRIPTION "Create a new deal in the sales pipeline"
' Generate deal ID
dealId = "DEAL-" + FORMAT(NOW(), "YYYY") + "-" + FORMAT(RANDOM(1000, 9999))
' Get sales rep info
salesRep = USERNAME
salesRepEmail = FROM
' Create deal record
WITH deal
id = dealId
company = company
value = value
expected_close = close_date
contact_name = contact
notes = notes
stage = "lead"
probability = 20
owner = salesRep
owner_email = salesRepEmail
created_at = NOW()
updated_at = NOW()
END WITH
SAVE "deals.csv", deal
' Log activity
WITH activity
deal_id = dealId
type = "created"
description = "Deal created with value $" + FORMAT(value, "#,##0")
user = salesRep
timestamp = NOW()
END WITH
SAVE "deal_activities.csv", activity
TALK "✅ **Deal Created!**"
TALK "🏢 **Company:** " + company
TALK "💰 **Value:** $" + FORMAT(value, "#,##0")
TALK "📅 **Expected Close:** " + FORMAT(close_date, "MMMM DD, YYYY")
TALK "📊 **Stage:** Lead"
TALK "🎫 **Deal ID:** " + dealId
TALK ""
TALK "Good luck! 🍀"
RETURN dealId
Update Stage Tool: update-stage.bas
PARAM deal_id AS STRING LIKE "DEAL-2025-0142" DESCRIPTION "Deal ID or company name"
PARAM new_stage AS STRING LIKE "qualified" DESCRIPTION "New stage: lead, qualified, proposal, negotiation, closed_won, closed_lost"
PARAM reason AS STRING DESCRIPTION "Reason for stage change" OPTIONAL
DESCRIPTION "Update the stage of a deal in the pipeline"
' Find deal
deal = FIND "deals.csv", "id = '" + deal_id + "' OR LOWER(company) LIKE '%" + LOWER(deal_id) + "%'"
IF NOT deal THEN
TALK "Deal not found. Please check the deal ID or company name."
RETURN NULL
END IF
old_stage = deal.stage
new_stage_lower = LOWER(new_stage)
' Set probability based on stage
SELECT CASE new_stage_lower
CASE "lead"
probability = 20
CASE "qualified"
probability = 40
CASE "proposal"
probability = 50
CASE "negotiation"
probability = 80
CASE "closed_won"
probability = 100
CASE "closed_lost"
probability = 0
END SELECT
' Update deal
deal.stage = new_stage_lower
deal.probability = probability
deal.updated_at = NOW()
IF new_stage_lower = "closed_won" THEN
deal.closed_date = NOW()
deal.closed_value = deal.value
ELSE IF new_stage_lower = "closed_lost" THEN
deal.closed_date = NOW()
deal.lost_reason = reason
END IF
UPDATE "deals.csv", deal
' Log activity
WITH activity
deal_id = deal.id
type = "stage_change"
description = "Stage changed: " + old_stage + " → " + new_stage_lower
user = USERNAME
timestamp = NOW()
END WITH
SAVE "deal_activities.csv", activity
' Format stage names
old_stage_display = PROPER(REPLACE(old_stage, "_", " "))
new_stage_display = PROPER(REPLACE(new_stage_lower, "_", " "))
TALK "✅ **Deal Updated!**"
TALK "🏢 **" + deal.company + "**"
TALK "📊 " + old_stage_display + " → **" + new_stage_display + "**"
TALK "💰 $" + FORMAT(deal.value, "#,##0")
IF new_stage_lower = "closed_won" THEN
TALK ""
TALK "🎉 Congratulations on closing the deal!"
ELSE IF new_stage_lower = "closed_lost" THEN
TALK ""
TALK "📝 Deal marked as lost. Keep pushing on the other opportunities!"
ELSE
TALK ""
TALK "Win probability: " + probability + "%"
END IF
RETURN deal.id
Forecast Revenue Tool: forecast-revenue.bas
PARAM period AS STRING LIKE "this quarter" DESCRIPTION "Forecast period: this month, this quarter, this year"
DESCRIPTION "Generate revenue forecast based on pipeline and probabilities"
' Determine date range
IF INSTR(LOWER(period), "month") > 0 THEN
start_date = DATE(YEAR(NOW()), MONTH(NOW()), 1)
end_date = DATEADD(DATEADD(start_date, 1, "month"), -1, "day")
period_name = FORMAT(NOW(), "MMMM YYYY")
ELSE IF INSTR(LOWER(period), "quarter") > 0 THEN
quarter = INT((MONTH(NOW()) - 1) / 3) + 1
start_date = DATE(YEAR(NOW()), (quarter - 1) * 3 + 1, 1)
end_date = DATEADD(DATEADD(start_date, 3, "month"), -1, "day")
period_name = "Q" + quarter + " " + YEAR(NOW())
ELSE
start_date = DATE(YEAR(NOW()), 1, 1)
end_date = DATE(YEAR(NOW()), 12, 31)
period_name = YEAR(NOW())
END IF
' Get deals closing in period
deals = FIND "deals.csv", "expected_close >= '" + FORMAT(start_date, "YYYY-MM-DD") + "' AND expected_close <= '" + FORMAT(end_date, "YYYY-MM-DD") + "' AND stage NOT IN ('closed_won', 'closed_lost')"
' Calculate forecasts by stage
weighted_total = 0
best_case = 0
committed = 0
stages = ["negotiation", "proposal", "qualified", "lead"]
stage_totals = []
FOR EACH stage IN stages
stage_deals = FILTER(deals, "stage = '" + stage + "'")
stage_value = 0
stage_weighted = 0
FOR EACH deal IN stage_deals
stage_value = stage_value + deal.value
stage_weighted = stage_weighted + (deal.value * deal.probability / 100)
NEXT
best_case = best_case + stage_value
weighted_total = weighted_total + stage_weighted
IF stage = "negotiation" THEN
committed = committed + stage_weighted
END IF
stage_totals[stage] = {value: stage_value, weighted: stage_weighted, prob: deals[1].probability}
NEXT
' Get closed won in period
closed = FIND "deals.csv", "closed_date >= '" + FORMAT(start_date, "YYYY-MM-DD") + "' AND stage = 'closed_won'"
closed_value = 0
FOR EACH deal IN closed
closed_value = closed_value + deal.closed_value
NEXT
' Get quota
quota = GET BOT MEMORY("quota_" + USERNAME)
IF NOT quota THEN quota = 200000
attainment = ((closed_value + weighted_total) / quota) * 100
TALK "📈 **" + period_name + " Revenue Forecast**"
TALK ""
TALK "**By Stage:**"
TALK "• Negotiation (80%): $" + FORMAT(stage_totals["negotiation"].weighted, "#,##0")
TALK "• Proposal (50%): $" + FORMAT(stage_totals["proposal"].weighted, "#,##0")
TALK "• Qualified (40%): $" + FORMAT(stage_totals["qualified"].weighted, "#,##0")
TALK "• Lead (20%): $" + FORMAT(stage_totals["lead"].weighted, "#,##0")
TALK ""
TALK "**Weighted Forecast:** $" + FORMAT(weighted_total, "#,##0")
TALK "**Best Case:** $" + FORMAT(best_case, "#,##0")
TALK "**Committed:** $" + FORMAT(committed, "#,##0")
TALK "**Already Closed:** $" + FORMAT(closed_value, "#,##0")
TALK ""
TALK "**Quota:** $" + FORMAT(quota, "#,##0")
TALK "**Attainment:** " + FORMAT(attainment, "#,##0") + "% (forecasted)"
IF attainment >= 100 THEN
TALK ""
TALK "🎯 You're on track to exceed quota!"
ELSE IF attainment >= 80 THEN
TALK ""
TALK "📊 You're close! Focus on advancing your top deals."
ELSE
TALK ""
TALK "⚠️ You need more pipeline coverage. Time to prospect!"
END IF
RETURN {weighted: weighted_total, best_case: best_case, attainment: attainment}
Customization Ideas
Add Deal Scoring
' Calculate deal score based on various factors
score = 0
' Company size score
IF deal.company_size > 1000 THEN
score = score + 20
ELSE IF deal.company_size > 100 THEN
score = score + 10
END IF
' Budget confirmed
IF deal.budget_confirmed THEN
score = score + 25
END IF
' Decision maker engaged
IF deal.decision_maker THEN
score = score + 25
END IF
' Timeline urgency
IF DATEDIFF(deal.expected_close, NOW(), "days") < 30 THEN
score = score + 20
END IF
' Competitor involved
IF deal.competitor THEN
score = score - 10
END IF
deal.score = score
TALK "Deal Score: " + score + "/100"
Add Activity Tracking
ADD TOOL "log-activity"
PARAM deal_id AS STRING DESCRIPTION "Deal ID"
PARAM activity_type AS STRING LIKE "call" DESCRIPTION "Type: call, email, meeting, demo, proposal"
PARAM notes AS STRING DESCRIPTION "Activity notes"
WITH activity
deal_id = deal_id
type = activity_type
notes = notes
user = USERNAME
timestamp = NOW()
END WITH
SAVE "deal_activities.csv", activity
' Update deal's last activity date
UPDATE "deals.csv" SET last_activity = NOW() WHERE id = deal_id
TALK "✅ Activity logged for deal " + deal_id
Add Win/Loss Analysis
ADD TOOL "win-loss-report"
won = FIND "deals.csv", "stage = 'closed_won' AND closed_date >= '" + start_date + "'"
lost = FIND "deals.csv", "stage = 'closed_lost' AND closed_date >= '" + start_date + "'"
won_count = UBOUND(won)
lost_count = UBOUND(lost)
win_rate = (won_count / (won_count + lost_count)) * 100
won_value = 0
FOR EACH deal IN won
won_value = won_value + deal.value
NEXT
TALK "📊 **Win/Loss Analysis**"
TALK ""
TALK "**Win Rate:** " + FORMAT(win_rate, "#0.0") + "%"
TALK "**Deals Won:** " + won_count + " ($" + FORMAT(won_value, "#,##0") + ")"
TALK "**Deals Lost:** " + lost_count
TALK ""
TALK "**Top Loss Reasons:**"
' Aggregate loss reasons...
Add Email Integration
' Send proposal email from pipeline
ADD TOOL "send-proposal"
PARAM deal_id AS STRING DESCRIPTION "Deal to send proposal for"
deal = FIND "deals.csv", "id = '" + deal_id + "'"
' Generate proposal from template
proposal = FILL "proposal-template.docx", deal
' Send email
SEND MAIL deal.contact_email, "Proposal for " + deal.company,
"Please find attached our proposal.\n\nBest regards,\n" + USERNAME,
proposal
' Update deal stage
deal.stage = "proposal"
deal.proposal_sent = NOW()
UPDATE "deals.csv", deal
TALK "📧 Proposal sent to " + deal.contact_email
TALK "Deal moved to Proposal stage."
Best Practices
- Keep Deals Updated: Update deal stages promptly for accurate forecasting
- Log Activities: Track all customer interactions
- Use BANT: Qualify deals properly before advancing
- Clean Pipeline: Remove stale deals regularly
- Review Weekly: Check pipeline health and forecasts weekly
Related Templates
- crm/contacts.bas - Contact management
- marketing.bas - Lead generation
- store.bas - E-commerce integration