Skip to content

Commit 986ef7e

Browse files
committed
2 parents c4a4cee + f0313a4 commit 986ef7e

25 files changed

Lines changed: 333 additions & 398 deletions
Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const EmailCampaignAgent: Agent = {
1+
/** Email Campaign Agent — creates and optimizes email campaigns */
2+
export const EmailCampaignAgent = {
43
name: 'email_campaign',
54
label: 'Email Campaign Agent',
6-
description: 'AI agent to create and optimize email campaigns',
75
role: 'creator',
8-
6+
97
instructions: `You are an email marketing AI that creates and optimizes email campaigns.
108
119
Your responsibilities:
@@ -19,18 +17,15 @@ Your responsibilities:
1917
Follow email marketing best practices and maintain brand voice.`,
2018

2119
model: { provider: 'anthropic', model: 'claude-3-opus', temperature: 0.8, maxTokens: 2000 },
22-
20+
2321
tools: [
24-
{ name: 'generate_email_copy', description: 'Generate email campaign copy', parameters: { campaign_id: 'string', audience: 'string', goal: 'string' } },
25-
{ name: 'optimize_subject_line', description: 'Optimize email subject line', parameters: { subject: 'string' } },
26-
{ name: 'personalize_content', description: 'Personalize email content', parameters: { template: 'string', recipient_data: 'object' } },
22+
{ type: 'action' as const, name: 'generate_email_copy', description: 'Generate email campaign copy' },
23+
{ type: 'action' as const, name: 'optimize_subject_line', description: 'Optimize email subject line' },
24+
{ type: 'action' as const, name: 'personalize_content', description: 'Personalize email content' },
2725
],
28-
26+
2927
knowledge: {
30-
sources: [
31-
{ type: 'object', objectName: 'campaign', fields: ['*'] },
32-
{ type: 'document', path: '/knowledge/brand-guidelines.md' },
33-
{ type: 'document', path: '/knowledge/email-templates/**/*.html' },
34-
],
28+
topics: ['email_marketing', 'brand_guidelines', 'campaign_templates'],
29+
indexes: ['sales_knowledge'],
3530
},
3631
};
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const LeadEnrichmentAgent: Agent = {
1+
/** Lead Enrichment Agent — automatically enriches lead data from external sources */
2+
export const LeadEnrichmentAgent = {
43
name: 'lead_enrichment',
54
label: 'Lead Enrichment Agent',
6-
description: 'AI agent to automatically enrich lead data from external sources',
75
role: 'worker',
8-
6+
97
instructions: `You are a lead enrichment AI that enhances lead records with additional data.
108
119
Your responsibilities:
@@ -19,22 +17,21 @@ Your responsibilities:
1917
Always use reputable data sources and maintain data quality.`,
2018

2119
model: { provider: 'openai', model: 'gpt-3.5-turbo', temperature: 0.3, maxTokens: 1000 },
22-
20+
2321
tools: [
24-
{ name: 'lookup_company', description: 'Look up company information', parameters: { company_name: 'string', domain: 'string' } },
25-
{ name: 'enrich_contact', description: 'Enrich contact information', parameters: { email: 'string', linkedin_url: 'string' } },
26-
{ name: 'validate_email', description: 'Validate email address', parameters: { email: 'string' } },
22+
{ type: 'action' as const, name: 'lookup_company', description: 'Look up company information' },
23+
{ type: 'action' as const, name: 'enrich_contact', description: 'Enrich contact information' },
24+
{ type: 'action' as const, name: 'validate_email', description: 'Validate email address' },
2725
],
28-
26+
2927
knowledge: {
30-
sources: [
31-
{ type: 'object', objectName: 'lead', fields: ['company', 'email', 'phone', 'website'] },
32-
],
28+
topics: ['lead_enrichment', 'company_data'],
29+
indexes: ['sales_knowledge'],
3330
},
34-
31+
3532
triggers: [
3633
{ type: 'object_create', objectName: 'lead' },
3734
],
38-
35+
3936
schedule: { type: 'cron', expression: '0 */4 * * *', timezone: 'UTC' },
4037
};
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const RevenueIntelligenceAgent: Agent = {
1+
/** Revenue Intelligence Agent — analyzes pipeline and provides revenue insights */
2+
export const RevenueIntelligenceAgent = {
43
name: 'revenue_intelligence',
54
label: 'Revenue Intelligence Agent',
6-
description: 'AI agent to analyze pipeline and provide revenue insights',
75
role: 'analyst',
8-
6+
97
instructions: `You are a revenue intelligence AI that analyzes sales data and provides insights.
108
119
Your responsibilities:
@@ -19,20 +17,17 @@ Your responsibilities:
1917
Use statistical analysis and machine learning to provide data-driven insights.`,
2018

2119
model: { provider: 'openai', model: 'gpt-4', temperature: 0.2, maxTokens: 3000 },
22-
20+
2321
tools: [
24-
{ name: 'analyze_pipeline', description: 'Analyze sales pipeline health', parameters: { user_id: 'string', time_period: 'string' } },
25-
{ name: 'identify_at_risk', description: 'Identify at-risk opportunities', parameters: { threshold: 'number' } },
26-
{ name: 'forecast_revenue', description: 'Generate revenue forecast', parameters: { time_period: 'string', method: 'string' } },
22+
{ type: 'query' as const, name: 'analyze_pipeline', description: 'Analyze sales pipeline health' },
23+
{ type: 'query' as const, name: 'identify_at_risk', description: 'Identify at-risk opportunities' },
24+
{ type: 'query' as const, name: 'forecast_revenue', description: 'Generate revenue forecast' },
2725
],
28-
26+
2927
knowledge: {
30-
sources: [
31-
{ type: 'object', objectName: 'opportunity', fields: ['*'] },
32-
{ type: 'object', objectName: 'account', fields: ['*'] },
33-
{ type: 'analytics', dashboardName: 'sales_dashboard' },
34-
],
28+
topics: ['pipeline_analytics', 'revenue_forecasting', 'deal_risk'],
29+
indexes: ['sales_knowledge'],
3530
},
36-
31+
3732
schedule: { type: 'cron', expression: '0 8 * * 1', timezone: 'America/Los_Angeles' },
3833
};

examples/app-crm/src/agents/sales.agent.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const SalesAssistantAgent: Agent = {
1+
/** Sales Assistant — helps reps with lead qualification and opportunity management */
2+
export const SalesAssistantAgent = {
43
name: 'sales_assistant',
54
label: 'Sales Assistant',
6-
description: 'AI agent to help sales reps with lead qualification and opportunity management',
75
role: 'assistant',
8-
6+
97
instructions: `You are a sales assistant AI helping sales representatives manage their pipeline.
108
119
Your responsibilities:
@@ -19,23 +17,18 @@ Your responsibilities:
1917
Always be professional, data-driven, and focused on helping close deals.`,
2018

2119
model: { provider: 'openai', model: 'gpt-4', temperature: 0.7, maxTokens: 2000 },
22-
20+
2321
tools: [
24-
{ name: 'analyze_lead', description: 'Analyze a lead and provide qualification score', parameters: { lead_id: 'string' } },
25-
{ name: 'suggest_next_action', description: 'Suggest next best action for an opportunity', parameters: { opportunity_id: 'string' } },
26-
{ name: 'generate_email', description: 'Generate a personalized email template', parameters: { recipient_id: 'string', context: 'string', tone: 'string' } },
22+
{ type: 'action' as const, name: 'analyze_lead', description: 'Analyze a lead and provide qualification score' },
23+
{ type: 'action' as const, name: 'suggest_next_action', description: 'Suggest next best action for an opportunity' },
24+
{ type: 'action' as const, name: 'generate_email', description: 'Generate a personalized email template' },
2725
],
28-
26+
2927
knowledge: {
30-
sources: [
31-
{ type: 'object', objectName: 'lead', fields: ['*'] },
32-
{ type: 'object', objectName: 'opportunity', fields: ['*'] },
33-
{ type: 'object', objectName: 'account', fields: ['*'] },
34-
{ type: 'document', path: '/knowledge/sales-playbook.md' },
35-
{ type: 'document', path: '/knowledge/product-catalog.md' },
36-
],
28+
topics: ['sales_playbook', 'product_catalog', 'lead_qualification'],
29+
indexes: ['sales_knowledge'],
3730
},
38-
31+
3932
triggers: [
4033
{ type: 'object_create', objectName: 'lead', condition: 'rating = "hot"' },
4134
{ type: 'object_update', objectName: 'opportunity', condition: 'ISCHANGED(stage)' },

examples/app-crm/src/agents/service.agent.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const ServiceAgent: Agent = {
1+
/** Customer Service Agent — assists with case triage and resolution */
2+
export const ServiceAgent = {
43
name: 'service_agent',
54
label: 'Customer Service Agent',
6-
description: 'AI agent to assist with customer support cases',
75
role: 'assistant',
8-
6+
97
instructions: `You are a customer service AI agent helping support representatives resolve customer issues.
108
119
Your responsibilities:
@@ -19,22 +17,18 @@ Your responsibilities:
1917
Always be empathetic, solution-focused, and customer-centric.`,
2018

2119
model: { provider: 'openai', model: 'gpt-4', temperature: 0.5, maxTokens: 1500 },
22-
20+
2321
tools: [
24-
{ name: 'triage_case', description: 'Analyze case and assign priority', parameters: { case_id: 'string' } },
25-
{ name: 'search_knowledge', description: 'Search knowledge base for solutions', parameters: { query: 'string' } },
26-
{ name: 'generate_response', description: 'Generate customer response', parameters: { case_id: 'string', tone: 'string' } },
22+
{ type: 'action' as const, name: 'triage_case', description: 'Analyze case and assign priority' },
23+
{ type: 'vector_search' as const, name: 'search_knowledge', description: 'Search knowledge base for solutions' },
24+
{ type: 'action' as const, name: 'generate_response', description: 'Generate customer response' },
2725
],
28-
26+
2927
knowledge: {
30-
sources: [
31-
{ type: 'object', objectName: 'case', fields: ['*'] },
32-
{ type: 'object', objectName: 'account', fields: ['*'] },
33-
{ type: 'document', path: '/knowledge/support-kb/**/*.md' },
34-
{ type: 'document', path: '/knowledge/sla-policies.md' },
35-
],
28+
topics: ['support_kb', 'sla_policies', 'case_resolution'],
29+
indexes: ['support_knowledge'],
3630
},
37-
31+
3832
triggers: [
3933
{ type: 'object_create', objectName: 'case' },
4034
{ type: 'object_update', objectName: 'case', condition: 'priority = "critical"' },

examples/app-crm/src/flows/campaign-enrollment.flow.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const CampaignEnrollmentFlow: Flow = {
1+
/** Campaign Enrollment — scheduled flow to bulk enroll leads */
2+
export const CampaignEnrollmentFlow = {
43
name: 'campaign_enrollment',
54
label: 'Enroll Leads in Campaign',
65
description: 'Bulk enroll leads into marketing campaigns',
76
type: 'autolaunched',
87
triggerType: 'scheduled',
98
schedule: '0 9 * * 1', // Monday at 9am
10-
9+
1110
variables: [
12-
{ name: 'campaignId', type: 'text', required: true },
13-
{ name: 'leadStatus', type: 'text', defaultValue: 'new' },
11+
{ name: 'campaignId', type: 'text', isInput: true, isOutput: false },
12+
{ name: 'leadStatus', type: 'text', isInput: true, isOutput: false },
1413
],
15-
14+
1615
steps: [
1716
{
1817
id: 'get_campaign',

examples/app-crm/src/flows/case-escalation.flow.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const CaseEscalationFlow: Flow = {
1+
/** Case Escalation — auto-escalate high-priority cases */
2+
export const CaseEscalationFlow = {
43
name: 'case_escalation',
54
label: 'Case Escalation Process',
65
description: 'Automatically escalate high-priority cases',
76
type: 'autolaunched',
87
triggerType: 'on_create',
98
objectName: 'case',
109
criteria: 'priority = "critical" OR (priority = "high" AND account.type = "customer")',
11-
10+
1211
variables: [
13-
{ name: 'caseId', type: 'text', required: true },
12+
{ name: 'caseId', type: 'text', isInput: true, isOutput: false },
1413
],
15-
14+
1615
steps: [
1716
{
1817
id: 'get_case',

examples/app-crm/src/flows/lead-conversion.flow.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const LeadConversionFlow: Flow = {
1+
/** Lead Conversion — multi-step screen flow to convert qualified leads */
2+
export const LeadConversionFlow = {
43
name: 'lead_conversion',
54
label: 'Lead Conversion Process',
65
description: 'Automated flow to convert qualified leads to accounts, contacts, and opportunities',
76
type: 'screen',
87
triggerType: 'manual',
98
objectName: 'lead',
10-
9+
1110
variables: [
12-
{ name: 'leadId', type: 'text', required: true },
13-
{ name: 'createOpportunity', type: 'boolean', defaultValue: true },
14-
{ name: 'opportunityName', type: 'text' },
15-
{ name: 'opportunityAmount', type: 'currency' },
11+
{ name: 'leadId', type: 'text', isInput: true, isOutput: false },
12+
{ name: 'createOpportunity', type: 'boolean', isInput: true, isOutput: false },
13+
{ name: 'opportunityName', type: 'text', isInput: true, isOutput: false },
14+
{ name: 'opportunityAmount', type: 'text', isInput: true, isOutput: false },
1615
],
17-
16+
1817
steps: [
1918
{
2019
id: 'screen_1',

examples/app-crm/src/flows/opportunity-approval.flow.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const OpportunityApprovalFlow: Flow = {
1+
/** Opportunity Approval — multi-level approval for deals over $100K */
2+
export const OpportunityApprovalFlow = {
43
name: 'opportunity_approval',
54
label: 'Large Deal Approval',
65
description: 'Approval process for opportunities over $100K',
76
type: 'autolaunched',
87
triggerType: 'on_update',
98
objectName: 'opportunity',
109
criteria: 'amount > 100000 AND stage = "proposal"',
11-
10+
1211
variables: [
13-
{ name: 'opportunityId', type: 'text', required: true },
12+
{ name: 'opportunityId', type: 'text', isInput: true, isOutput: false },
1413
],
15-
14+
1615
steps: [
1716
{
1817
id: 'get_opportunity',

examples/app-crm/src/flows/quote-generation.flow.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const QuoteGenerationFlow: Flow = {
1+
/** Quote Generation — screen flow to create a quote from an opportunity */
2+
export const QuoteGenerationFlow = {
43
name: 'quote_generation',
54
label: 'Generate Quote from Opportunity',
65
description: 'Create a quote based on opportunity details',
76
type: 'screen',
87
triggerType: 'manual',
98
objectName: 'opportunity',
10-
9+
1110
variables: [
12-
{ name: 'opportunityId', type: 'text', required: true },
13-
{ name: 'quoteName', type: 'text' },
14-
{ name: 'expirationDays', type: 'number', defaultValue: 30 },
15-
{ name: 'discount', type: 'percent', defaultValue: 0 },
11+
{ name: 'opportunityId', type: 'text', isInput: true, isOutput: false },
12+
{ name: 'quoteName', type: 'text', isInput: true, isOutput: false },
13+
{ name: 'expirationDays', type: 'number', isInput: true, isOutput: false },
14+
{ name: 'discount', type: 'number', isInput: true, isOutput: false },
1615
],
17-
16+
1817
steps: [
1918
{
2019
id: 'screen_1',

0 commit comments

Comments
 (0)