@devries-cameron20 / composio Mirror · read-only / commits / d53b5446a
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 12:00 UTC

feat(docs): Add trigger type, config, and payload to toolkit pages

- Fetch detailed trigger info from API (config, payload, type, instructions) - Display trigger type badge (webhook/poll) in list - Show Configuration and Payload tables when expanded - Update Trigger type to include new fields - Fetch tools and triggers in parallel for better performance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 28, 2026 at 11:30 UTC d53b5446a2a2e18a3e7a6c7873163e67525cd414
5 files changed +123 -7
docs/app/(home)/toolkits/[[...slug]]/page.tsx
+80 -5
@@ -7,7 +7,7 @@ import { PageActions } from '@/components/page-actions';
7 import { readFile } from 'fs/promises';
8 import { join } from 'path';
9 import type { Metadata } from 'next';
10 -import type { Toolkit, Tool } from '@/types/toolkit';
10 +import type { Toolkit, Tool, Trigger } from '@/types/toolkit';
11
12 const API_BASE = process.env.COMPOSIO_API_BASE || 'https://backend.composio.dev/api/v3';
13 const API_KEY = process.env.COMPOSIO_API_KEY;
@@ -84,6 +84,77 @@ async function fetchDetailedTools(toolkitSlug: string): Promise<Tool[] | null> {
84 }
85 }
86
87 +// Fetch detailed trigger info from Composio API (server-side only)
88 +// Returns null on failure, empty array if toolkit has no triggers
89 +async function fetchDetailedTriggers(toolkitSlug: string): Promise<Trigger[] | null> {
90 + if (!API_KEY) {
91 + console.warn('[Toolkits] COMPOSIO_API_KEY not set, skipping detailed trigger fetch');
92 + return null;
93 + }
94 +
95 + try {
96 + const response = await fetch(
97 + `${API_BASE}/triggers_types?toolkit_slugs=${toolkitSlug.toUpperCase()}&limit=1000`,
98 + {
99 + headers: {
100 + 'Content-Type': 'application/json',
101 + 'x-api-key': API_KEY,
102 + },
103 + next: { revalidate: 3600 }, // Cache for 1 hour
104 + }
105 + );
106 +
107 + if (!response.ok) {
108 + console.warn(`[Toolkits] Failed to fetch triggers for ${toolkitSlug}: ${response.status}`);
109 + return null;
110 + }
111 +
112 + const data = await response.json();
113 + const rawItems = data.items || data;
114 + const items = Array.isArray(rawItems) ? rawItems : [];
115 +
116 + return items.filter((trigger: any) => trigger && typeof trigger === 'object').map((trigger: any) => {
117 + // Extract config and payload schemas
118 + const configSchema = trigger.config;
119 + const payloadSchema = trigger.payload;
120 +
121 + // Get properties and required array from JSON Schema
122 + const configProps = configSchema?.properties || configSchema;
123 + const configRequired = configSchema?.required || [];
124 + const payloadProps = payloadSchema?.properties || payloadSchema;
125 + const payloadRequired = payloadSchema?.required || [];
126 +
127 + // Add required flag to each property based on the required array
128 + const processParams = (props: any, requiredList: string[]) => {
129 + if (!props || typeof props !== 'object') return undefined;
130 + const result: Record<string, any> = {};
131 + for (const [key, value] of Object.entries(props)) {
132 + if (typeof value === 'object' && value !== null) {
133 + result[key] = {
134 + ...(value as object),
135 + required: requiredList.includes(key),
136 + };
137 + }
138 + }
139 + return Object.keys(result).length > 0 ? result : undefined;
140 + };
141 +
142 + return {
143 + slug: trigger.slug || '',
144 + name: trigger.name || trigger.display_name || trigger.slug || '',
145 + description: trigger.description || '',
146 + type: trigger.type || undefined,
147 + config: processParams(configProps, configRequired),
148 + payload: processParams(payloadProps, payloadRequired),
149 + instructions: trigger.instructions || undefined,
150 + };
151 + });
152 + } catch (error) {
153 + console.error(`[Toolkits] Error fetching detailed triggers for ${toolkitSlug}:`, error);
154 + return null;
155 + }
156 +}
157 +
158 async function getToolkits(): Promise<Toolkit[]> {
159 const filePath = join(process.cwd(), 'public/data/toolkits.json');
160
@@ -204,17 +275,21 @@ export default async function ToolkitsPage({ params }: { params: Promise<{ slug?
275 const toolkit = toolkits.find((t) => t.slug === toolkitSlug);
276
277 if (toolkit) {
207 - // Fetch detailed tool info from API (includes input/output params)
208 - const detailedTools = await fetchDetailedTools(toolkitSlug);
278 + // Fetch detailed tool and trigger info from API (includes input/output params)
279 + const [detailedTools, detailedTriggers] = await Promise.all([
280 + fetchDetailedTools(toolkitSlug),
281 + fetchDetailedTriggers(toolkitSlug),
282 + ]);
283
210 - // Use detailed tools if fetch succeeded, otherwise fall back to static data
284 + // Use detailed data if fetch succeeded, otherwise fall back to static data
285 const tools = detailedTools !== null ? detailedTools : toolkit.tools;
286 + const triggers = detailedTriggers !== null ? detailedTriggers : toolkit.triggers;
287
288 return (
289 <ToolkitDetail
290 toolkit={toolkit}
291 tools={tools}
217 - triggers={toolkit.triggers}
292 + triggers={triggers}
293 path={`/toolkits/${toolkit.slug}`}
294 />
295 );
docs/components/toolkits/toolkit-detail.tsx
+37 -1
@@ -67,6 +67,11 @@ function isTool(item: Tool | Trigger): item is Tool {
67 return 'input_parameters' in item || 'output_parameters' in item;
68 }
69
70 +// Check if item is a Trigger with config/payload
71 +function isTrigger(item: Tool | Trigger): item is Trigger {
72 + return 'config' in item || 'payload' in item || 'type' in item;
73 +}
74 +
75 function ToolItem({ item }: { item: Tool | Trigger }) {
76 const [expanded, setExpanded] = useState(false);
77 const [copied, setCopied] = useState(false);
@@ -79,8 +84,12 @@ function ToolItem({ item }: { item: Tool | Trigger }) {
84 };
85
86 const tool = isTool(item) ? item : null;
87 + const trigger = isTrigger(item) ? item : null;
88 +
89 const hasInputParams = tool?.input_parameters && Object.keys(tool.input_parameters).length > 0;
90 const hasOutputParams = tool?.output_parameters && Object.keys(tool.output_parameters).length > 0;
91 + const hasConfig = trigger?.config && Object.keys(trigger.config).length > 0;
92 + const hasPayload = trigger?.payload && Object.keys(trigger.payload).length > 0;
93
94 return (
95 <div className="border-b border-fd-border/50 last:border-0">
@@ -92,7 +101,18 @@ function ToolItem({ item }: { item: Tool | Trigger }) {
101 {expanded ? <ChevronDown className="h-4 w-4" /> : <ChevronRight className="h-4 w-4" />}
102 </span>
103 <span className="flex min-w-0 flex-1 flex-col gap-1 sm:flex-row sm:items-center sm:justify-between sm:gap-2">
95 - <span className="truncate text-sm font-medium text-fd-foreground">{item.name}</span>
104 + <span className="flex items-center gap-2">
105 + <span className="truncate text-sm font-medium text-fd-foreground">{item.name}</span>
106 + {trigger?.type && (
107 + <span className={`shrink-0 rounded px-1.5 py-0.5 text-xs font-medium ${
108 + trigger.type === 'webhook'
109 + ? 'bg-green-500/10 text-green-600 dark:text-green-400'
110 + : 'bg-blue-500/10 text-blue-600 dark:text-blue-400'
111 + }`}>
112 + {trigger.type}
113 + </span>
114 + )}
115 + </span>
116 <span
117 role="button"
118 onClick={copySlug}
@@ -107,6 +127,7 @@ function ToolItem({ item }: { item: Tool | Trigger }) {
127 <div className="space-y-4 bg-fd-muted/20 px-4 py-3 pl-10">
128 <p className="text-sm text-fd-muted-foreground">{item.description}</p>
129
130 + {/* Tool parameters */}
131 {hasInputParams && (
132 <div className="space-y-2">
133 <h4 className="text-xs font-semibold uppercase tracking-wide text-fd-muted-foreground">Input Parameters</h4>
@@ -120,6 +141,21 @@ function ToolItem({ item }: { item: Tool | Trigger }) {
141 <TypeTable type={paramsToTypeTable(tool.output_parameters!)} />
142 </div>
143 )}
144 +
145 + {/* Trigger config/payload */}
146 + {hasConfig && (
147 + <div className="space-y-2">
148 + <h4 className="text-xs font-semibold uppercase tracking-wide text-fd-muted-foreground">Configuration</h4>
149 + <TypeTable type={paramsToTypeTable(trigger.config!)} />
150 + </div>
151 + )}
152 +
153 + {hasPayload && (
154 + <div className="space-y-2">
155 + <h4 className="text-xs font-semibold uppercase tracking-wide text-fd-muted-foreground">Payload</h4>
156 + <TypeTable type={paramsToTypeTable(trigger.payload!)} />
157 + </div>
158 + )}
159 </div>
160 )}
161 </div>
docs/content/docs/triggers.mdx
+1 -1
@@ -26,7 +26,7 @@ To create triggers through the dashboard:
26 2. Select the auth config
27 3. Click "Add Trigger" and navigate to "Active Triggers" tab to fetch the trigger ID
28
29 -<Video src="/videos/enabling-triggers.mp4" caption="Creating a trigger from the dashboard" />
29 +<Video src="/videos/enabling-triggers.mp4" poster="/images/enabling-triggers-poster.png" caption="Creating a trigger from the dashboard" />
30
31 Some triggers require additional configuration. The dashboard will prompt you for any required fields during setup.
32
docs/public/images/enabling-triggers-poster.png
Binary files /dev/null and b/docs/public/images/enabling-triggers-poster.png differ
docs/types/toolkit.ts
+5
@@ -24,6 +24,11 @@ export interface Trigger {
24 slug: string;
25 name: string;
26 description: string;
27 + // Detailed fields fetched on-demand
28 + type?: 'webhook' | 'poll';
29 + config?: Record<string, ParameterSchema>;
30 + payload?: Record<string, ParameterSchema>;
31 + instructions?: string;
32 }
33
34 // Auth config field definition