AI-powered legislative analysis for Salesforce SEs. Deploy a complete Texas bill analysis system with Agentforce in 20 minutes.
For Demos: Show customers how AI agents can analyze complex government documents, extract fiscal data, and structure information for business use.
For SEs: Get a demo-ready demo environment that:
- β Analyzes ANY Texas legislative house bill.
- β Extracts fiscal impacts automatically with Claude AI and performs financial calculations
- β Returns natural language summaries for Agentforce
- β Provides structured data for Salesforce records (and creation of Salesforce records)
- β Caches results for fast repeat queries (45%+ cache hit rate)
- β Handles large bills (500+ pages) with background processing
Click the purple button above βοΈ
Heroku will:
- Create a new app
- Install Python and dependencies
- Provision Redis cache ($15/month)
- Provision Claude AI via Heroku Managed Inference ($0.30 per 1M tokens)
- Start web and worker dynos ($7/month each)
Copy your app URL: https://your-app-name.herokuapp.com
1. Legislation__c (Parent)
API Name: Legislation__c
Fields:
- Bill_Number__c (Text, 20)
- Legislative_Session__c (Text, 10)
- Bill_URL__c (URL, 255)
- Name (Auto-Number: LG-{00000})
2. Bill_Analysis__c (Child of Legislation)
API Name: Bill_Analysis__c
Relationship: Master-Detail to Legislation__c
Fields:
- Analysis_Summary__c (Long Text Area, 32000)
- Fiscal_Note_Summary__c (Long Text Area, 32000)
- Total_Fiscal_Impact__c (Currency, 18, 2)
- Fiscal_Note_URL__c (URL, 255)
- Analysis_Date__c (Date)
- Name (Auto-Number: BA-{00000})
That's it! Just 2 objects.
- Setup β External Services β New External Service
- Name:
TexasBillAnalyzer - Paste this OpenAPI spec:
{
"openapi": "3.0.0",
"info": {
"title": "Texas Bill Analyzer API",
"version": "9.2.0"
},
"servers": [
{
"url": "https://YOUR-APP-NAME.herokuapp.com"
}
],
"paths": {
"/analyzeBillForAgentforce": {
"post": {
"summary": "Analyze Texas Bill for Agentforce",
"operationId": "analyzeBillForAgentforce",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"bill_number": {
"type": "string",
"description": "Bill number (e.g., HB 150, SB 2)"
}
},
"required": ["bill_number"]
}
}
}
},
"responses": {
"200": {
"description": "Analysis complete",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"response": {
"type": "string",
"description": "Formatted natural language response"
},
"success": {
"type": "boolean"
}
}
}
}
}
}
}
}
}
}
}Replace YOUR-APP-NAME with your actual Heroku app name!
- Save and Test the connection
-
Agentforce Studio β New Agent
- Name:
Legislative Analysis Agent - Description:
Analyzes Texas legislative bills
- Name:
-
Add Topic: "Bill Analysis"
-
Classification Descriptions:
- "User asks to analyze a bill"
- "User asks about legislation"
- "User wants bill summary"
- "User asks for fiscal impact"
-
Instructions:
When the user asks about a Texas bill, extract the bill number and call the analyzeBillForAgentforce action. Bill numbers follow these patterns: - HB 150 (House Bill) - SB 2 (Senate Bill) - HJ 1 (House Joint Resolution) - SJ 5 (Senate Joint Resolution) After analysis, present the results clearly to the user. If they want to save the bill, ask for confirmation.
-
-
Add Action:
analyzeBillForAgentforce- Select your External Service
- Map
bill_numberinput - Action instructions: "Extract bill number from user query and analyze"
-
Activate Agent
In Agentforce chat:
"Analyze HB 150"
"What's the fiscal impact of SB 2?"
"Summarize House Bill 216"
Expected response:
π BILL ANALYSIS: HB00150
SUMMARY
[Clear 2-3 sentence summary]
π° FISCAL IMPACT
[3 paragraphs: bottom line, year-by-year breakdown, implementation details]
Five-Year Total: -$X.X billion
π View the full fiscal note: [URL]
Would you like to save this bill to Salesforce for tracking?
| Component | Cost | Notes |
|---|---|---|
| Eco Dynos (2) | $14/mo | Web + Worker ($7 each) |
| Redis Mini | $15/mo | Caching layer |
| Heroku Inference | ~$20-50/mo | Usage-based (Claude API) |
| Total | $49-79/mo | Per SE instance |
Cost Savings: Redis caching achieves 45%+ hit rate, reducing Claude API costs significantly.
- Problem: Staff overwhelmed reading hundreds of bills per session
- Solution: AI analyzes bills, extracts fiscal data, flags high-impact legislation
- ROI: hours saved annually (example metric from docs)
heroku config:set TX_LEGISLATURE_SESSION=90R --app your-app-nameEdit app.py line ~88:
cache_analysis(bill_number, session, result, ttl=86400) # 24 hoursEdit generate_bill_summary() and extract_fiscal_data_with_claude() functions in app.py
Fork the repo and modify URL patterns in try_bill_url_patterns() for your state's legislature website.
Health check with system status
curl https://your-app.herokuapp.com/healthSimple endpoint for Agentforce (returns formatted text)
curl -X POST https://your-app.herokuapp.com/analyzeBillForAgentforce \
-H "Content-Type: application/json" \
-d '{"bill_number": "HB 150"}'Response:
{
"response": "π BILL ANALYSIS: HB00150\n\nSUMMARY\n...",
"success": true
}Full analysis endpoint (returns structured data)
curl -X POST https://your-app.herokuapp.com/analyzeBill \
-H "Content-Type: application/json" \
-d '{"bill_number": "HB 150"}'Response:
{
"bill_number": "HB00150",
"session": "89R",
"bill_url": "https://...",
"fiscal_note_url": "https://...",
"bill_text": "first 3000 chars...",
"fiscal_note_summary": "3 paragraph summary...",
"total_fiscal_impact": -88715399.00,
"formatted_response": "natural language version...",
"success": true
}View cache performance
curl https://your-app.herokuapp.com/cache/statsClear cache for specific bill
curl -X POST https://your-app.herokuapp.com/cache/invalidate \
-H "Content-Type: application/json" \
-d '{"bill_number": "HB 150"}'Cause: Bill doesn't exist or session is wrong
Fix: Verify bill number on Texas Legislature and check session config (89th)
Cause: Telicon.com is down or URL pattern changed
Fix: Check Heroku logs: heroku logs --tail --app your-app-name
Cause: Redis addon not provisioned
Fix: Run heroku addons --app your-app-name to verify Redis is installed
Cause: Heroku Inference credentials missing
Fix: Run heroku config --app your-app-name and verify INFERENCE_URL and INFERENCE_KEY are set
Cause: Using /analyzeBill instead of /analyzeBillForAgentforce
Fix: Update External Service to use /analyzeBillForAgentforce endpoint
For SEs:
Architecture Patterns:
- This app demonstrates: Microservices, Caching, Background Jobs, AI Integration
- Reusable pattern for: Contracts, Reports, Medical Records, any PDF workflow
Have improvements? Found a bug? Want to add another state?
- Fork this repo
- Create a feature branch
- Submit a pull request
MIT License - use this however you want! Build cool demos and make SEs look good. π
Built by a Salesforce SE after a pattern of legislative analysis was coming up in customer conversations. Special thanks to:
- Agentforce team for the amazing platform
- Heroku team for Managed Inference
- Claude AI for actually understanding fiscal notes
- Texas Legislature for having (mostly) consistent PDF URLs
- Issues: GitHub Issues
- SE Slack: DM Robert Smith (rsmith2@salesforce.com)
- Heroku Support: #heroku-ai on Slack and #heroku-support global
Click the deploy button at the top! π