Spaces:
Runtime error
Confluence Integration Setup Guide
This guide walks you through setting up Confluence integration for the Fraud Model Explainability Assistant.
Prerequisites
- Access to a Confluence instance (Atlassian Cloud or Data Center)
- Permission to create API tokens
- Permission to read the Confluence spaces you want to search
Step 1: Get Confluence API Credentials
Option A: Atlassian Cloud (Most Common)
Get your Confluence URL:
- Go to your Confluence instance
- Copy the URL (e.g.,
https://yourcompany.atlassian.net)
Create an API Token:
- Go to https://id.atlassian.com/manage-profile/security/api-tokens
- Click "Create API token"
- Give it a label (e.g., "Fraud Assistant")
- Copy the token (you won't be able to see it again!)
Get your email:
- Use the email address associated with your Atlassian account
- Recommendation: Create a service account (e.g.,
fraud-bot@yourcompany.com)
Option B: Confluence Data Center (Self-Hosted)
Get your Confluence URL:
- Your internal Confluence URL (e.g.,
https://confluence.yourcompany.com)
- Your internal Confluence URL (e.g.,
Create a Personal Access Token:
- Go to Confluence β Profile β Personal Access Tokens
- Click "Create token"
- Give it a name and select appropriate permissions
- Copy the token
Authentication:
- For Data Center, you may use username/password or PAT
- See confluence-ingestor documentation for details
Step 2: Configure Environment Variables
Create .env File
cd fraud_model_explainability_assistant
# Copy the example file
cp .env.example .env
# Edit with your credentials
nano .env # or use your preferred editor
Edit .env File
# Confluence Configuration
CONFLUENCE_URL=https://yourcompany.atlassian.net # YOUR Confluence URL
CONFLUENCE_EMAIL=your.email@company.com # YOUR email
CONFLUENCE_API_TOKEN=ATATT3xFfGF0... # YOUR API token
# Embedding Provider (free, local)
EMBEDDING_PROVIDER=huggingface
# Vector Store
VECTOR_STORE_TYPE=chroma
CHROMA_PERSIST_DIRECTORY=./chroma_db
# Optional: OpenAI (if not using Bedrock)
OPENAI_API_KEY=sk-... # YOUR OpenAI key (optional)
Important: Never commit .env to git! It contains secrets.
Step 3: Install Dependencies
# Make sure you're in the fraud assistant directory
cd fraud_model_explainability_assistant
# Install confluence-ingestor with Strands adapter
pip install confluence-ingestor[strands,huggingface,chroma]
# Verify installation
python -c "from confluence_ingestor import ConfluenceRAG; print('β
Installation successful')"
Step 4: Identify Confluence Spaces to Ingest
Find Your Spaces
- Go to Confluence β Spaces β View All Spaces
- Identify spaces with relevant documentation:
- Model governance documentation
- Compliance policies
- Fraud investigation procedures
- Training materials
- Regulatory guidelines
Recommended Spaces for Fraud Assistant
| Space Purpose | Example Space Key | Priority |
|---|---|---|
| Model Governance | fraud-model-governance |
βββββ |
| Compliance Policies | compliance-policies |
βββββ |
| Investigation Playbooks | fraud-investigation |
ββββ |
| Regulatory Prep | regulatory-compliance |
ββββ |
| Team Procedures | fraud-analytics-team |
βββ |
Get Space Keys
- Go to a Confluence space
- Look at the URL:
https://yourcompany.atlassian.net/wiki/spaces/SPACEKEY/ - The
SPACEKEYis what you need
Step 5: Test Confluence Connection
Quick Connection Test
cd fraud_model_explainability_assistant
# Test Confluence connection
python -c "
from confluence_ingestor import ConfluenceClient
client = ConfluenceClient.from_env()
spaces = client.list_spaces()
print('β
Connected to Confluence!')
print(f'Found {len(spaces)} spaces')
for space in spaces[:5]:
print(f' - {space.key}: {space.name}')
"
Expected Output:
β
Connected to Confluence!
Found 15 spaces
- FMG: Fraud Model Governance
- CP: Compliance Policies
- FI: Fraud Investigation
...
If you see errors:
401 Unauthorized: Check your email and API token404 Not Found: Check your Confluence URL403 Forbidden: You don't have permission to access Confluence
Step 6: Ingest Confluence Spaces
Initial Ingestion (One-Time Setup)
This downloads your Confluence content and creates a searchable vector database.
cd fraud_model_explainability_assistant
python << 'EOF'
from confluence_ingestor import ConfluenceRAG
# Initialize RAG pipeline
print("Initializing Confluence RAG...")
rag = ConfluenceRAG.from_env(
embedding_provider="huggingface",
vector_store_type="chroma"
)
# Ingest spaces (this may take 5-10 minutes)
spaces = {
"fraud-model-governance": 100, # Adjust space keys and limits
"compliance-policies": 50,
"fraud-investigation": 75,
}
for space_key, max_pages in spaces.items():
print(f"\nIngesting {space_key} (max {max_pages} pages)...")
try:
stats = rag.ingest_space(space_key, max_pages=max_pages, force=False)
if stats.get("skipped"):
print(f" β {stats['reason']}")
else:
print(f" β
Ingested {stats['pages']} pages")
print(f" Created {stats['chunks']} chunks")
except Exception as e:
print(f" β Error: {e}")
print("\nβ
Ingestion complete!")
print("Vector database saved to: ./chroma_db/")
EOF
Expected Output:
Initializing Confluence RAG...
Downloading model... (first time only, ~400MB)
Ingesting fraud-model-governance (max 100 pages)...
β
Ingested 87 pages
Created 1,245 chunks
Ingesting compliance-policies (max 50 pages)...
β
Ingested 42 pages
Created 628 chunks
β
Ingestion complete!
Vector database saved to: ./chroma_db/
Time: 5-10 minutes for ~300 pages (first time only)
Step 7: Test the Integration
Test Search Functionality
python << 'EOF'
from confluence_ingestor import ConfluenceRAG
rag = ConfluenceRAG.from_env()
# Test search
results = rag.search("fair lending policy synthetic ID", k=3)
print(f"Found {len(results)} results:\n")
for i, result in enumerate(results, 1):
print(f"{i}. {result.title}")
print(f" Space: {result.space_key}")
print(f" Score: {result.score:.4f}")
print(f" Content: {result.content[:150]}...")
print(f" Source: {result.source}\n")
EOF
Expected Output:
Found 3 results:
1. Fair Lending Policy - Synthetic Identity Detection
Space: compliance-policies
Score: 0.8523
Content: Our fair lending policy addresses synthetic identity detection through the following guidelines...
Source: https://yourcompany.atlassian.net/wiki/spaces/CP/pages/12345
2. Model Validation Report - XGBoost v3.2
Space: fraud-model-governance
Score: 0.7891
Content: The model validation for XGBoost v3.2 includes fair lending compliance testing...
Source: https://yourcompany.atlassian.net/wiki/spaces/FMG/pages/67890
3. Investigation Playbook - Synthetic ID Fraud
Space: fraud-investigation
Score: 0.7654
Content: When investigating synthetic identity fraud, follow these procedures...
Source: https://yourcompany.atlassian.net/wiki/spaces/FI/pages/11111
Step 8: Run the Enhanced Fraud Assistant
# Run the Confluence-integrated version
python confluence_integration_example.py
The app will:
- Initialize Confluence RAG (reads from
./chroma_db/) - Create the Confluence search tool
- Add it to the Strands agent
- Launch the Gradio UI
Test it:
- Open http://localhost:7860
- Ask: "What does our fair lending policy say about phone type features?"
- The agent should search Confluence and cite specific policy documents!
Troubleshooting
Error: "3 validation errors for ConfluenceConfig"
Cause: Environment variables not loaded
Fix:
# Check if .env exists
ls -la .env
# If missing, create it from .env.example
cp .env.example .env
# Edit with your credentials
nano .env
# Verify variables are set
python -c "import os; from dotenv import load_dotenv; load_dotenv(); print('URL:', os.getenv('CONFLUENCE_URL'))"
Error: "401 Unauthorized"
Cause: Invalid email or API token
Fix:
- Re-generate your API token at https://id.atlassian.com/manage-profile/security/api-tokens
- Double-check your email is correct
- Make sure there are no extra spaces in
.env
Error: "404 Not Found"
Cause: Incorrect Confluence URL
Fix:
- Check your Confluence URL format
- For Atlassian Cloud:
https://yourcompany.atlassian.net(no/wikisuffix) - For Data Center:
https://confluence.yourcompany.com
Error: "403 Forbidden"
Cause: User doesn't have permission to access Confluence
Fix:
- Log into Confluence with the same email/token
- Verify you can view the spaces you're trying to ingest
- Contact your Confluence admin to grant read access
Error: "Module not found: confluence_ingestor"
Cause: Package not installed
Fix:
pip install confluence-ingestor[strands,huggingface,chroma]
Error: "Slow search queries"
Cause: Large vector database or slow embeddings
Fix:
- Reduce
max_pageswhen ingesting - Consider using OpenAI embeddings (faster but costs money)
- Filter searches to specific spaces
Error: "Out of disk space"
Cause: Vector database and model cache are large
Fix:
- Vector database: ~150 MB per 100 pages
- HuggingFace model: ~400 MB (one-time)
- Free up space or use a smaller corpus
Maintenance
Update Confluence Content (Daily/Weekly)
# Re-ingest spaces to pick up new content
python << 'EOF'
from confluence_ingestor import ConfluenceRAG
rag = ConfluenceRAG.from_env()
# Force re-ingestion
for space in ["fraud-model-governance", "compliance-policies"]:
print(f"Updating {space}...")
stats = rag.ingest_space(space, max_pages=100, force=True)
print(f" β
Updated {stats['pages']} pages")
EOF
Automated Updates (Optional)
Add to your deployment:
from apscheduler.schedulers.background import BackgroundScheduler
def refresh_confluence():
rag = ConfluenceRAG.from_env()
for space in ["fraud-model-governance", "compliance-policies"]:
rag.ingest_space(space, max_pages=100, force=True)
scheduler = BackgroundScheduler()
scheduler.add_job(refresh_confluence, 'cron', hour=2) # 2 AM daily
scheduler.start()
Security Best Practices
1. Use a Service Account
Create a dedicated Confluence user:
- Email:
fraud-bot@yourcompany.com - Name: "Fraud Model Assistant"
- Purpose: Read-only access to specific spaces
2. Limit Permissions
Grant minimal access:
- β Read access to relevant spaces
- β No write access
- β No admin access
3. Secure Credentials
- β
Store in
.env(never commit to git) - β Use environment variables in production
- β Rotate API tokens regularly
- β Never hard-code credentials
4. Add to .gitignore
# Add to .gitignore
echo ".env" >> .gitignore
echo "chroma_db/" >> .gitignore
echo "*.log" >> .gitignore
Next Steps
Once setup is complete:
- β Test with simple queries
- β Add more Confluence spaces as needed
- β Customize space filters for different use cases
- β Share with your team
- β Monitor usage and performance
- β Set up automated updates
Support
Documentation
- confluence-ingestor: See
/confluence-ingestor/README.md - Strands Agents: https://strandsagents.com/latest/documentation/docs/
Common Issues
Check CONFLUENCE_INTEGRATION_ANALYSIS.md for:
- Architecture details
- Performance optimization
- Advanced configuration
- ROI analysis
Summary Checklist
- Create Confluence API token
- Create
.envfile with credentials - Install
confluence-ingestor[strands,huggingface,chroma] - Test Confluence connection
- Identify relevant Confluence spaces
- Ingest spaces (5-10 minutes)
- Test search functionality
- Run enhanced fraud assistant
- Add to
.gitignore - Share with team
Estimated Time: 30-60 minutes (including ingestion)
Need Help? Check the troubleshooting section or review the detailed analysis in CONFLUENCE_INTEGRATION_ANALYSIS.md.