@iriseller/mcp-server
Version:
Model Context Protocol (MCP) server providing access to IRISeller's AI sales intelligence platform with 7 AI agents, multi-CRM integration, advanced sales workflows, email automation (detection/sending/campaigns), and robust asynchronous agent execution h
430 lines (418 loc) • 18.7 kB
JavaScript
export class FallbackService {
/**
* Fallback for company research when primary endpoints fail
*/
static async fallbackCompanyResearch(companyName, industry) {
try {
// Generate pattern-based research data
const mockResearchData = {
company_overview: {
name: companyName,
industry: industry || 'Unknown',
description: `${companyName} is a company operating in the ${industry || 'business'} sector. This is pattern-based research data generated when live research services are unavailable.`,
employee_count: 'Unknown',
revenue: 'Unknown',
founded: 'Unknown',
headquarters: 'Unknown'
},
market_position: {
competitive_position: 'Unable to determine - research services unavailable',
market_share: 'Unknown',
key_competitors: [],
differentiation: 'Research required when services are available'
},
recent_activity: {
news: [],
press_releases: [],
social_media: [],
note: 'Live research data unavailable - this is fallback information'
},
technology_stack: {
known_technologies: [],
website_analysis: 'Unable to analyze - research services unavailable',
integration_opportunities: []
},
pain_points: {
identified_challenges: [
'Standard industry challenges may apply',
'Specific pain points require live research'
],
opportunity_areas: [
'Process optimization',
'Technology integration',
'Efficiency improvements'
]
},
engagement_recommendations: [
'Schedule discovery call to understand specific needs',
'Research company website and recent news manually',
'Connect with decision makers on LinkedIn',
'Prepare industry-specific value proposition'
],
confidence_score: 0.3,
research_method: 'Pattern-based fallback (live research unavailable)',
limitations: [
'Live research services are currently unavailable',
'This data is generated based on common patterns',
'Manual research recommended for accurate insights'
]
};
return {
success: true,
data: mockResearchData,
message: `Fallback research data generated for ${companyName}. Live research services are currently unavailable.`
};
}
catch (error) {
return {
success: false,
error: `Fallback research failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
data: null
};
}
}
/**
* Fallback for personalization when primary endpoints fail
*/
static async fallbackPersonalization(prospectName, companyName, messageType, tone = 'professional') {
try {
const templates = {
email: {
professional: `Subject: Exploring Partnership Opportunities with ${companyName}
Hi ${prospectName},
I hope this message finds you well. I've been following ${companyName}'s progress and am impressed by your work in the industry.
I'd love to explore how we might be able to support ${companyName}'s continued growth and success. Our solutions have helped similar companies achieve significant improvements in their operations.
Would you be open to a brief conversation to discuss potential collaboration opportunities?
Best regards,
[Your Name]
Note: This is a template-based message. Personalization services are currently unavailable.`,
casual: `Hi ${prospectName},
Hope you're doing well! I've been checking out what ${companyName} is up to and really like what I see.
I think there might be some cool ways we could work together to help ${companyName} grow even more.
Would you be up for a quick chat sometime this week?
Cheers,
[Your Name]
Note: This is a template-based message. Personalization services are currently unavailable.`
},
linkedin: {
professional: `Hi ${prospectName}, I've been following ${companyName}'s journey and would love to connect. I believe there are some interesting opportunities we could explore together. Would you be open to connecting?`,
casual: `Hey ${prospectName}! Love what ${companyName} is doing. Would be great to connect and maybe chat about some opportunities!`
},
phone_script: {
professional: `Hi ${prospectName}, this is [Your Name] from [Company]. I've been researching ${companyName} and am impressed by your work. I'd love to discuss how we might be able to support your goals. Do you have a few minutes to chat?`,
casual: `Hi ${prospectName}, it's [Your Name] from [Company]. I've been following ${companyName} and think there might be some great opportunities for us to work together. Got a few minutes to chat?`
}
};
const messageTemplate = templates[messageType]?.[tone] ||
templates.email.professional;
const fallbackData = {
personalized_message: messageTemplate,
personalization_elements: [
`Prospect name: ${prospectName}`,
`Company name: ${companyName}`,
`Message type: ${messageType}`,
`Tone: ${tone}`
],
recommendations: [
'Research the prospect\'s recent LinkedIn activity',
'Look up company news and recent announcements',
'Find common connections or interests',
'Customize the message with specific company details'
],
confidence_score: 0.4,
method: 'Template-based fallback',
limitations: [
'Live personalization services are currently unavailable',
'This is a generic template that should be customized',
'Manual research recommended for better personalization'
]
};
return {
success: true,
data: fallbackData,
message: `Fallback personalization generated for ${prospectName} at ${companyName}. Live personalization services are currently unavailable.`
};
}
catch (error) {
return {
success: false,
error: `Fallback personalization failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
data: null
};
}
}
/**
* Fallback for agent execution when primary endpoints fail
*/
static async fallbackAgentExecution(agentName, inputData) {
try {
const executionId = `fallback_${Date.now()}`;
const fallbackResults = {
agent_name: agentName,
execution_mode: 'fallback',
input_data: inputData,
status: 'completed_with_limitations',
message: `Agent ${agentName} is currently unavailable. This is fallback information.`,
recommendations: [
'Retry when agent services are available',
'Use manual processes as interim solution',
'Check system status for service availability'
],
limitations: [
'Live agent services are currently unavailable',
'This is simulated output for continuity',
'Results may not reflect actual agent capabilities'
],
next_steps: [
'Monitor service status',
'Retry agent execution when services are restored',
'Consider manual alternatives for urgent tasks'
]
};
return {
execution_id: executionId,
status: 'completed_with_fallback',
agent_name: agentName,
results: fallbackResults,
execution_time: 0.5,
error: 'Primary agent services unavailable - fallback response provided'
};
}
catch (error) {
return {
execution_id: `error_${Date.now()}`,
status: 'error',
agent_name: agentName,
error: `Fallback agent execution failed: ${error instanceof Error ? error.message : 'Unknown error'}`
};
}
}
/**
* Fallback for workflow execution when primary endpoints fail
*/
static async fallbackWorkflowExecution(workflowType, inputData) {
try {
const workflowId = `fallback_workflow_${Date.now()}`;
const fallbackResults = {
workflow_type: workflowType,
execution_mode: 'fallback',
input_data: inputData,
status: 'completed_with_limitations',
message: `Workflow ${workflowType} is currently unavailable. This is fallback information.`,
workflow_steps: [
'Step 1: Service unavailable - manual process recommended',
'Step 2: Fallback data generated',
'Step 3: Recommendations provided'
],
recommendations: [
'Break down workflow into manual steps',
'Use individual tools when available',
'Retry full workflow when services are restored'
],
limitations: [
'Live workflow services are currently unavailable',
'This is simulated output for continuity',
'Manual intervention may be required'
]
};
return {
workflow_id: workflowId,
status: 'completed_with_fallback',
workflow_type: workflowType,
results: fallbackResults,
execution_time: 1.0,
agents_executed: [],
error: 'Primary workflow services unavailable - fallback response provided'
};
}
catch (error) {
return {
workflow_id: `error_${Date.now()}`,
status: 'error',
workflow_type: workflowType,
error: `Fallback workflow execution failed: ${error instanceof Error ? error.message : 'Unknown error'}`
};
}
}
/**
* Fallback for CRM queries when primary endpoints fail
*/
static async fallbackCRMQuery(entityType, filters) {
try {
const mockData = {
leads: [
{
id: 'fallback_lead_1',
name: 'Sample Lead',
company: 'Sample Company',
email: 'sample@company.com',
status: 'Open',
source: 'Fallback Data',
created_date: new Date().toISOString(),
note: 'This is fallback data - CRM services are currently unavailable'
}
],
opportunities: [
{
id: 'fallback_opp_1',
name: 'Sample Opportunity',
account: 'Sample Account',
stage: 'Prospecting',
amount: 50000,
close_date: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(),
note: 'This is fallback data - CRM services are currently unavailable'
}
],
contacts: [
{
id: 'fallback_contact_1',
name: 'Sample Contact',
email: 'contact@company.com',
company: 'Sample Company',
title: 'Sample Title',
note: 'This is fallback data - CRM services are currently unavailable'
}
]
};
const fallbackResults = mockData[entityType] || [];
return {
success: true,
data: fallbackResults,
message: `Fallback ${entityType} data provided. CRM services are currently unavailable.`
};
}
catch (error) {
return {
success: false,
error: `Fallback CRM query failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
data: []
};
}
}
/**
* Fallback for sales forecasting when primary endpoints fail
*/
static async fallbackSalesForecast(timePeriod = '90d') {
try {
const mockForecast = {
period: timePeriod,
forecast_data: {
total_pipeline: 500000,
weighted_pipeline: 200000,
expected_close: 150000,
confidence_level: 'Low - Fallback Data',
scenarios: {
optimistic: 250000,
realistic: 150000,
pessimistic: 100000
}
},
breakdown: {
new_business: 100000,
existing_accounts: 50000,
renewals: 0
},
note: 'This is fallback forecast data - live forecasting services are currently unavailable',
recommendations: [
'Update forecast manually based on current pipeline',
'Review individual opportunities for accuracy',
'Retry when forecasting services are available'
],
limitations: [
'Data is not based on current CRM information',
'Forecasting algorithms are not applied',
'Manual review and adjustment recommended'
]
};
return {
success: true,
data: mockForecast,
message: `Fallback sales forecast generated for ${timePeriod}. Live forecasting services are currently unavailable.`
};
}
catch (error) {
return {
success: false,
error: `Fallback sales forecast failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
data: null
};
}
}
/**
* Get fallback agents list when primary service is unavailable
*/
static async fallbackAgentsList() {
try {
const fallbackAgents = [
{
name: 'rosa_sdr',
description: 'Lead qualification specialist (Currently Unavailable)',
capabilities: ['lead_qualification', 'bant_analysis', 'qualification_scoring'],
status: 'unavailable',
note: 'Service temporarily unavailable'
},
{
name: 'prospecting',
description: 'Account-based prospecting (Currently Unavailable)',
capabilities: ['company_research', 'stakeholder_identification', 'contact_finding'],
status: 'unavailable',
note: 'Service temporarily unavailable'
},
{
name: 'personalization',
description: 'Prospect research and personalization (Currently Unavailable)',
capabilities: ['social_analysis', 'trigger_events', 'personalization_hooks'],
status: 'unavailable',
note: 'Service temporarily unavailable'
}
];
return {
success: true,
data: fallbackAgents,
message: 'Fallback agents list provided. Agent services are currently unavailable.'
};
}
catch (error) {
return {
success: false,
error: `Fallback agents list failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
data: []
};
}
}
/**
* Get fallback workflows list when primary service is unavailable
*/
static async fallbackWorkflowsList() {
try {
const fallbackWorkflows = [
{
name: 'full_sdr_workflow',
description: 'Complete SDR process (Currently Unavailable)',
agents_involved: ['prospecting', 'personalization', 'sequence'],
status: 'unavailable',
note: 'Service temporarily unavailable'
},
{
name: 'lead_qualification_enhancement',
description: 'Enhanced lead qualification (Currently Unavailable)',
agents_involved: ['rosa_sdr', 'personalization'],
status: 'unavailable',
note: 'Service temporarily unavailable'
}
];
return {
success: true,
data: fallbackWorkflows,
message: 'Fallback workflows list provided. Workflow services are currently unavailable.'
};
}
catch (error) {
return {
success: false,
error: `Fallback workflows list failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
data: []
};
}
}
}