A comprehensive Node.js tool for exporting and analyzing Botpress conversation data using Claude AI. This project helps you extract valuable insights from your chatbot conversations, identify knowledge gaps, and improve your bot's performance.
- Automated Data Export: Export conversations from the last 7 days with complete message and log data
- AI-Powered Analysis: Use Claude AI to analyze conversation patterns and extract insights
- Comprehensive Reporting: Generate detailed reports covering topics, knowledge gaps, performance, and user experience
- Flexible Filtering: Filter conversations by channel, integration, log level, and more
- Beautiful Output: Colorized, formatted reports with structured recommendations
- Programmatic API: Use as a library in your own applications
This tool performs a complete analysis workflow:
- Data Export: Fetches all conversations from the last week from your Botpress workspace
- Data Bundling: For each conversation, it collects:
- Complete conversation metadata
- All messages (user and bot)
- All runtime logs and system events
- AI Analysis: Uses Claude AI to analyze the data and extract insights in four key areas:
- Topics of Interest: What users are asking about most
- Knowledge Gaps: Areas where your bot needs improvement
- System Performance: Technical issues and reliability concerns
- User Experience: Content effectiveness and interaction patterns
- Report Generation: Creates structured, actionable reports with recommendations
-
Clone the repository:
git clone <repository-url> cd insights
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the project root with your credentials:# Botpress API Configuration BOTPRESS_TOKEN=your_botpress_token BOTPRESS_BOT_ID=your_bot_id BOTPRESS_WORKSPACE_ID=your_workspace_id BOTPRESS_API_BASE_URL=https://api.botpress.cloud # Claude AI Configuration ANTHROPIC_API_KEY=your_anthropic_api_key CLAUDE_MODEL=claude-sonnet-4-0
-
Get your API keys:
- Botpress: Get your token, bot ID, and workspace ID from your Botpress dashboard
- Anthropic: Get your API key from Anthropic Console
-
Export conversations:
npm run export -
Analyze the data:
npm run analyze
-
View formatted results:
npm run format-analysis data/your-analysis-file.json
# Filter by channel
npm run export -- --channel webchat
# Filter by integration
npm run export -- --integration webchat
# Filter logs by level
npm run export -- --log-level error
# Custom filename
npm run export -- --filename weekly-errors.json# Analyze specific file
npm run analyze -- --file data/my-export.json
# Show summary in console
npm run analyze -- --summary
# Custom analysis filename
npm run analyze -- --filename weekly-insights.json# Preview how data will be reconstructed for analysis
npm run preview| Command | Description |
|---|---|
npm run export |
Export last week's conversations with complete data |
npm run analyze |
Analyze exported data with Claude AI |
npm run preview |
Preview data reconstruction before analysis |
npm run format-analysis |
Format analysis results with colors and structure |
npm run help |
Show export command help |
npm run help-analyze |
Show analysis command help |
You can also use this tool as a library in your own applications:
import { BotpressDataService, DataAnalysisService } from './src/index.js';
// Export data
const dataService = new BotpressDataService();
const exportResult = await dataService.exportLastWeekData({
conversationFilters: { channel: 'webchat' },
logOptions: { level: 'error' }
});
// Analyze with Claude
const analysisService = new DataAnalysisService();
const analysisResult = await analysisService.analyzeExport(exportResult.filePath);
// Access results
console.log('Export summary:', exportResult.summary);
console.log('AI insights:', analysisResult.analysis);insights/
βββ src/
β βββ services/
β β βββ botpressDataService.js # Data export and bundling
β β βββ dataAnalysisService.js # Claude AI analysis
β βββ utils/
β β βββ BotpressClient.js # Botpress API client
β βββ scripts/
β β βββ export.js # Export CLI script
β β βββ analyze.js # Analysis CLI script
β β βββ preview.js # Data preview script
β β βββ formatAnalysis.js # Report formatting script
β βββ index.js # Main entry point
βββ data/ # Exported data and analysis results
βββ package.json
βββ README.md
The tool generates comprehensive analysis reports covering:
- Most frequently discussed topics
- User intent patterns
- Content effectiveness metrics
- Questions the bot couldn't answer
- Areas needing additional training data
- Missing conversation flows
- Error rates and patterns
- Performance bottlenecks
- Technical issues and recommendations
- Conversation flow effectiveness
- User satisfaction indicators
- Content quality assessment
Each analysis includes:
- Priority levels (High/Medium/Low) for recommendations
- Supporting evidence from actual conversations
- Actionable recommendations with specific next steps
- Token usage and cost estimates
Exported data includes:
{
"metadata": {
"exportedAt": "2025-08-29T15:57:50.969Z",
"timeRange": { "startDate": "...", "endDate": "..." },
"totalConversations": 20,
"processingTimeMs": 5103,
"version": "1.0.0"
},
"conversations": [
{
"conversation": { /* conversation metadata */ },
"messages": [ /* all messages */ ],
"logs": [ /* all runtime logs */ ],
"metadata": { /* bundling info */ },
"stats": { /* conversation statistics */ }
}
],
"summary": { /* overall statistics */ }
}| Variable | Description | Required |
|---|---|---|
BOTPRESS_TOKEN |
Your Botpress API token | Yes |
BOTPRESS_BOT_ID |
Your bot ID | Yes |
BOTPRESS_WORKSPACE_ID |
Your workspace ID | Yes |
BOTPRESS_API_BASE_URL |
Botpress API base URL | No (defaults to https://api.botpress.cloud) |
ANTHROPIC_API_KEY |
Your Anthropic API key | Yes (for analysis) |
CLAUDE_MODEL |
Claude model to use | No (defaults to claude-sonnet-4-0) |
const options = {
conversationFilters: {
channel: 'webchat', // Filter by channel
integrationName: 'webchat' // Filter by integration
},
logOptions: {
level: 'error' // Filter logs by level
},
messageOptions: {
// Additional message filtering options
}
};-
Authentication Errors:
- Verify your Botpress credentials are correct
- Check that your token has the necessary permissions
-
No Conversations Found:
- Ensure you have conversations in the last 7 days
- Check your date filters and timezone settings
-
Analysis Fails:
- Verify your Anthropic API key is valid
- Check that you have sufficient API credits
- Ensure the export file is not corrupted
-
Memory Issues:
- For large datasets, consider filtering by date range
- Monitor your system memory usage during export
- Check the help commands:
npm run helpandnpm run help-analyze - Review the console output for detailed error messages
- Ensure all required environment variables are set
ISC License
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Note: This tool is designed for Botpress Cloud workspaces. For self-hosted Botpress instances, you may need to adjust the API endpoints and authentication methods.