Structured Data Examples
Practical examples for using structured data in integrations
Display search results with selectable contacts:
const structuredData: StructuredData = {
displayType: 'list',
templateId: 'contact_search',
data: {
items: [
{
id: 'contact-1',
title: 'John Doe',
subtitle: 'john.doe@company.com',
icon: 'person',
badge: 'Manager',
badgeVariant: 'primary'
},
{
id: 'contact-2',
title: 'Jane Smith',
subtitle: 'jane.smith@company.com',
icon: 'person',
badge: 'Developer',
badgeVariant: 'info'
}
]
},
interactions: {
allowSelection: true,
allowMultiSelect: true
},
metadata: {
totalCount: 2,
query: 'doe',
source: 'contacts'
}
};
Display files with icons and sizes:
const structuredData: StructuredData = {
displayType: 'list',
templateId: 'file_list',
data: {
items: [
{
id: 'file-1',
title: 'Report Q4.pdf',
subtitle: '2.3 MB - Modified yesterday',
icon: 'document'
},
{
id: 'file-2',
title: 'Presentation.pptx',
subtitle: '5.1 MB - Modified 2 days ago',
icon: 'document'
}
]
},
interactions: {
allowSelection: true,
primaryAction: 'open'
}
};
Show step-by-step execution progress:
const structuredData: StructuredData = {
displayType: 'card',
templateId: 'execution_details',
data: {
title: 'Execution Details',
badges: [
{ label: '5 steps', variant: 'default' },
{ label: 'Bash: 3, Read: 2', variant: 'info' }
],
steps: [
{
id: 'step-1',
title: 'Run: npm install',
status: 'success',
detail: 'npm install'
},
{
id: 'step-2',
title: 'Read: package.json',
status: 'success'
},
{
id: 'step-3',
title: 'Run: npm test',
status: 'error',
description: 'Tests failed'
}
],
summary: {
'Bash': 2,
'Read': 1
},
defaultExpanded: false
},
metadata: {
sessionId: 'session-123',
errorCount: 1,
totalSteps: 3
}
};
Display a completed task with summary stats:
const structuredData: StructuredData = {
displayType: 'card',
templateId: 'task_summary',
data: {
title: 'Data Sync Complete',
subtitle: 'Synced contacts from Google',
badges: [
{ label: '150 contacts', variant: 'success' },
{ label: '3 errors', variant: 'error' }
],
summary: {
'Created': 45,
'Updated': 102,
'Errors': 3
},
defaultExpanded: true
}
};
Present selectable options for user approval:
const structuredData: StructuredData = {
displayType: 'list',
templateId: 'permission_prompt',
data: {
items: [
{
id: 'allow',
title: 'Allow',
subtitle: 'Grant permission for this operation',
icon: 'checkmark-circle',
badgeVariant: 'success',
metadata: { action: 'allow' }
},
{
id: 'allow_always',
title: 'Allow Always',
subtitle: 'Trust this tool for the session',
icon: 'shield-checkmark',
badgeVariant: 'primary',
metadata: { action: 'allow_always' }
},
{
id: 'deny',
title: 'Deny',
subtitle: 'Block this operation',
icon: 'close-circle',
badgeVariant: 'error',
metadata: { action: 'deny' }
}
]
},
interactions: {
allowSelection: true,
allowMultiSelect: false
}
};
Include structured data when sending messages:
import { MirraSDK } from '@mirra-messenger/sdk';
const sdk = new MirraSDK({ apiKey: 'your-api-key' });
await sdk.mirraMessaging.sendMessage({
groupId: 'chat-123',
content: 'Here are your search results:',
structuredData: [structuredData]
});
The structuredData field accepts an array, allowing you to include multiple structured data blocks in a single message.