Coordination
How to integrate your Butler with The Butler's coordination system. The Butler manages routing, deep links, and context sharing so Butlers work together instead of in silos.
Overview
The Butler acts as a coordination layer between all Butlers, managing routing, deep links, and context sharing. This enables Butlers to work together seamlessly—for example, an expense can link to a contact, a trip, and a receipt image, all managed through The Butler's coordination system.
Deep Link Routing
The Butler manages routing between Butlers using deep links. Your Butler can navigate to other Butlers and receive navigation requests from other Butlers.
Navigate to Other Butlers
// Navigate to another Butler
await window.lifeButler.navigateToButler({
butlerId: 'expense-butler',
path: '/expenses/create',
params: {
amount: 25.50,
category: 'groceries',
linkedContactId: 'contact-123'
}
});
// Navigate with context
await window.lifeButler.navigateToButler({
butlerId: 'socials-butler',
path: '/contacts/view',
params: { contactId: 'contact-123' },
context: {
sourceButler: 'my-butler',
sourceScreen: 'expense-detail'
}
});Handle Incoming Navigation
// Listen for navigation from other Butlers
window.lifeButler.onNavigate((path, params, context) => {
// Handle navigation to specific screens
if (path === '/my-butler/details') {
const { id, sourceButler } = params;
showDetailsScreen(id, { sourceButler });
}
});
// Get initial navigation context on load
window.lifeButler.onReady((context) => {
if (context.initialPath) {
handleNavigation(context.initialPath, context.initialParams, context.sourceContext);
}
});Context Sharing
Butlers can share context with each other through The Butler's coordination system. This enables workflows that span multiple Butlers.
Share Context
// Share context with other Butlers
await window.lifeButler.shareContext({
targetButlers: ['expense-butler', 'socials-butler'],
context: {
type: 'expense-created',
expenseId: 'exp-123',
amount: 25.50,
contactId: 'contact-123'
}
});
// Listen for shared context
window.lifeButler.onContextShared((context, sourceButler) => {
if (context.type === 'expense-created') {
// Update UI or trigger actions based on shared context
refreshRelatedData(context.expenseId);
}
});Cross-Butler Data Linking
The Butler enables linking data across Butlers. For example, an expense can link to a contact, a trip, and a receipt image.
Link Entities
// Link entities across Butlers
await window.lifeButler.linkEntities({
sourceEntity: {
butlerId: 'my-butler',
entityType: 'Expense',
entityId: 'exp-123'
},
targetEntities: [
{
butlerId: 'socials-butler',
entityType: 'Contact',
entityId: 'contact-123'
},
{
butlerId: 'travel-butler',
entityType: 'Trip',
entityId: 'trip-456'
}
]
});
// Query linked entities
const linkedEntities = await window.lifeButler.getLinkedEntities({
entityType: 'Expense',
entityId: 'exp-123'
});
// Returns all entities linked to this expense across all ButlersRequirements
- Handle deep links: Support navigation to specific screens within your Butler via deep links from other Butlers.
- Share context: Use context sharing to enable workflows that span multiple Butlers.
- Link entities: Link your Butler's entities to entities in other Butlers when relevant.
- Respect permissions: Only navigate to or share context with Butlers that the user has granted access to.