CRM Tools
Access customer data, order history, and send notifications.
Overview
CRM tools provide access to customer profiles, purchase history, and communication channels. They integrate with Salesforce, Firestore customer data, and notification services.
getCustomerProfile
Retrieve comprehensive customer profile:
typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { getCustomerProfile } from '@hyperfold/actions-sdk'; // Get customer profile by IDconst customer = await getCustomerProfile('cust_xyz123'); // Returns:{ customer_id: 'cust_xyz123', email: 'john@example.com', name: 'John Doe', loyalty: { tier: 'gold', points: 2450, tier_expires: '2026-12-31', next_tier: 'platinum', points_to_next: 550, }, purchase_history: { total_orders: 12, total_spent: 2450.00, avg_order_value: 204.17, first_order: '2024-03-15', last_order: '2025-12-10', }, preferences: { favorite_categories: ['footwear', 'sportswear'], favorite_brands: ['AeroRun', 'Nike'], size_preferences: { shoes: '10', shirts: 'L' }, communication: { email: true, sms: false }, }, segments: ['high_value', 'sports_enthusiast', 'discount_seeker'], // CRM integration data salesforce: { account_id: '001xxx', opportunity_count: 3, last_interaction: '2025-12-18', },} // Get with specific fieldsconst basic = await getCustomerProfile('cust_xyz123', { fields: ['name', 'loyalty', 'purchase_history'],}); // Get by emailconst byEmail = await getCustomerProfile({ email: 'john@example.com' });getOrderHistory
Access customer purchase history:
typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { getOrderHistory } from '@hyperfold/actions-sdk'; // Get customer's order historyconst orders = await getOrderHistory('cust_xyz123'); // Returns:{ customer_id: 'cust_xyz123', total_orders: 12, orders: [ { order_id: 'order_789', date: '2025-12-10T14:30:00Z', status: 'delivered', total: 162.00, items: [ { product_id: 'prod_aero_x2', name: 'AeroRun X2', quantity: 1, price: 162.00 }, ], payment_method: 'card_visa_4242', shipping_address: { city: 'San Francisco', state: 'CA' }, }, // ... more orders ], stats: { total_spent: 2450.00, avg_order_value: 204.17, orders_last_30_days: 2, orders_last_90_days: 5, }, frequent_products: [ { product_id: 'prod_aero_x2', times_purchased: 3 }, { product_id: 'prod_socks_wp', times_purchased: 5 }, ],} // Get with filtersconst recent = await getOrderHistory('cust_xyz123', { limit: 5, since: '2025-01-01', status: 'delivered',}); // Get orders for specific productconst productOrders = await getOrderHistory('cust_xyz123', { product_id: 'prod_aero_x2',});Order history includes full details for personalization. Use the
frequent_products field to suggest repurchases.updateCustomer
Update customer profiles and sync with CRM:
typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { updateCustomerProfile, updateLoyaltyTier, addCustomerTag,} from '@hyperfold/actions-sdk'; // Update customer profileawait updateCustomerProfile('cust_xyz123', { preferences: { size_preferences: { shoes: '10.5' }, // Updated shoe size },}); // Update loyalty tierawait updateLoyaltyTier('cust_xyz123', { new_tier: 'platinum', reason: 'Reached 3000 points threshold', notify_customer: true,}); // Add customer tags/segmentsawait addCustomerTag('cust_xyz123', 'vip_2025');await addCustomerTag('cust_xyz123', 'early_adopter'); // Record customer interactionimport { recordInteraction } from '@hyperfold/actions-sdk'; await recordInteraction('cust_xyz123', { type: 'negotiation', channel: 'agent', outcome: 'purchase', value: 162.00, notes: 'Negotiated 10% Gold discount on AeroRun X2', agent_id: 'sales-bot-01',}); // Sync to Salesforceimport { syncToSalesforce } from '@hyperfold/actions-sdk'; await syncToSalesforce('cust_xyz123', { update_account: true, create_activity: true, activity_type: 'Agent Purchase',});Notification Tools
Send emails, SMS, and internal notifications:
typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { sendEmail, sendSMS, postToSlack,} from '@hyperfold/actions-sdk'; // Send transactional emailawait sendEmail({ to: 'customer@example.com', template: 'order_confirmation', data: { order_id: 'order_789', items: [{ name: 'AeroRun X2', price: 162.00 }], total: 162.00, tracking_url: 'https://...', },}); // Send SMS notificationawait sendSMS({ to: '+14155551234', template: 'shipping_update', data: { order_id: 'order_789', status: 'Out for delivery', eta: '2:00 PM - 6:00 PM', },}); // Post to Slack (internal notifications)await postToSlack({ channel: '#sales-wins', message: '🎉 New conversion! $162 from Gold member', blocks: [ { type: 'section', text: { type: 'mrkdwn', text: '*New Sale*\nCustomer: John Doe (Gold)\nProduct: AeroRun X2\nPrice: $162 (10% discount)', }, }, ],}); // Send alert for high-value transactionsimport { sendAlert } from '@hyperfold/actions-sdk'; await sendAlert({ severity: 'info', title: 'High-value negotiation', message: 'Customer negotiating $500+ purchase', channels: ['slack', 'email'], recipients: ['sales-manager@company.com'],});Usage in Agent
Complete example using CRM tools for personalization:
typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { HyperfoldAgent, OnACPEvent, getCustomerProfile, getOrderHistory, sendEmail, recordInteraction,} from '@hyperfold/actions-sdk'; @HyperfoldAgent({ name: 'crm-aware-agent', type: 'negotiator' })export class CRMAwareAgent { @OnACPEvent('quote') async handleQuote(productId: string, offer: number, context: BuyerContext) { // Load full customer profile const customer = await getCustomerProfile(context.customer_id); // Check purchase history for this product const history = await getOrderHistory(context.customer_id, { product_id: productId, }); // Personalize response based on history if (history.orders.length > 0) { // Returning customer for this product const lastPurchase = history.orders[0]; const daysSinceLastPurchase = this.daysBetween(lastPurchase.date, new Date()); if (daysSinceLastPurchase < 30) { // Recent purchase - might be a replacement return { status: 'info', message: `I see you purchased this item ${daysSinceLastPurchase} days ago. Is there an issue with your order?`, support_link: '/support', }; } } // Calculate personalized pricing const pricing = await this.calculatePrice(productId, { tier: customer.loyalty.tier, lifetime_value: customer.purchase_history.total_spent, favorite_brand: customer.preferences.favorite_brands.includes('AeroRun'), }); // Record this interaction await recordInteraction(context.customer_id, { type: 'quote_request', product_id: productId, offered_price: pricing.suggested, buyer_offer: offer, }); return { status: 'quote', price: pricing.suggested, personalization: `As a ${customer.loyalty.tier} member with ${customer.purchase_history.total_orders} orders, you qualify for our best pricing.`, }; }}Ready to build custom agents? See the Negotiator Agent reference.