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 21, 03:37 UTC
| 1 | import { Check, Share2 } from 'lucide-react'; |
| 2 | import type { ReactNode } from 'react'; |
| 3 | |
| 4 | const LOGO_CDN = 'https://logos.composio.dev/api'; |
| 5 | |
| 6 | const CONNECTIONS: { slug: string; name: string; owner: string; shared?: boolean }[] = [ |
| 7 | { slug: 'slack', name: 'Slack', owner: 'workspace bot', shared: true }, |
| 8 | { slug: 'github', name: 'GitHub', owner: 'Alice' }, |
| 9 | { slug: 'gmail', name: 'Gmail', owner: 'Alice' }, |
| 10 | ]; |
| 11 | |
| 12 | /** |
| 13 | * SlackBotFlow — branded replacement for the plain `slack → server → agent` |
| 14 | * mermaid diagram on the Slack bot example page. |
| 15 | * |
| 16 | * Reads left-to-right as the request loop: a Slack message arrives as a trigger |
| 17 | * webhook, your server hands it to the Pi agent, and the agent works through a |
| 18 | * per-user session that pins one shared workspace Slack connection alongside the |
| 19 | * user's own connected apps. The reply flows back to Slack as the bot. |
| 20 | * |
| 21 | * Server component, no client JS. Adapts to light/dark via fd-* tokens. |
| 22 | */ |
| 23 | export function SlackBotFlow() { |
| 24 | return ( |
| 25 | <div className="not-prose my-6 overflow-hidden rounded-sm border border-fd-border bg-fd-background"> |
| 26 | {/* header strip — mono, matches the other branded flow visuals */} |
| 27 | <div className="flex items-center justify-between border-b border-fd-border px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.06em] text-fd-foreground/45"> |
| 28 | <span>slackbot.runtime</span> |
| 29 | <span className="inline-flex items-center gap-1.5 text-fd-foreground/55"> |
| 30 | <span className="relative inline-flex"> |
| 31 | <span className="size-1.5 rounded-full bg-[var(--composio-brand)]" /> |
| 32 | <span className="absolute inset-0 animate-ping rounded-full bg-[var(--composio-brand)] opacity-60" /> |
| 33 | </span> |
| 34 | listening in Slack |
| 35 | </span> |
| 36 | </div> |
| 37 | |
| 38 | <div className="grid items-stretch gap-px bg-fd-border md:grid-cols-[minmax(0,0.9fr)_minmax(0,0.95fr)_minmax(0,1.3fr)]"> |
| 39 | {/* ── Slack ──────────────────────────────────────────────── */} |
| 40 | <Column> |
| 41 | <Lane label="Slack" /> |
| 42 | <div className="flex flex-1 items-center"> |
| 43 | <div className="w-full border border-fd-border bg-fd-card p-3"> |
| 44 | <div className="flex items-center gap-2"> |
| 45 | <img |
| 46 | alt="" |
| 47 | aria-hidden="true" |
| 48 | className="size-7 rounded-sm object-contain p-0.5" |
| 49 | draggable={false} |
| 50 | src={`${LOGO_CDN}/slack`} |
| 51 | /> |
| 52 | <div className="min-w-0"> |
| 53 | <div className="truncate text-[12px] font-medium leading-tight text-fd-foreground"> |
| 54 | Message |
| 55 | </div> |
| 56 | <div className="truncate font-mono text-[10px] text-fd-foreground/45"> |
| 57 | @mention or DM |
| 58 | </div> |
| 59 | </div> |
| 60 | </div> |
| 61 | <p className="mt-2.5 inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.05em] text-[var(--composio-brand)]"> |
| 62 | trigger <Arrow /> webhook |
| 63 | </p> |
| 64 | </div> |
| 65 | </div> |
| 66 | <Connector /> |
| 67 | </Column> |
| 68 | |
| 69 | {/* ── Your server / agent ────────────────────────────────── */} |
| 70 | <Column> |
| 71 | <Lane label="Your server" /> |
| 72 | <div className="flex flex-1 items-center"> |
| 73 | <div className="w-full border border-fd-border bg-fd-card p-3"> |
| 74 | <div className="flex items-center gap-2"> |
| 75 | <span className="flex size-7 items-center justify-center rounded-sm bg-fd-foreground/[0.06] font-mono text-[13px] text-fd-foreground/70"> |
| 76 | {'{ }'} |
| 77 | </span> |
| 78 | <div className="min-w-0"> |
| 79 | <div className="truncate text-[12px] font-medium leading-tight text-fd-foreground"> |
| 80 | Pi agent |
| 81 | </div> |
| 82 | <div className="truncate font-mono text-[10px] text-fd-foreground/45"> |
| 83 | verifies + loops |
| 84 | </div> |
| 85 | </div> |
| 86 | </div> |
| 87 | <p className="mt-2.5 text-[11px] leading-snug text-fd-foreground/55"> |
| 88 | Verifies the webhook signature, then calls the session's tools. |
| 89 | </p> |
| 90 | </div> |
| 91 | </div> |
| 92 | <Connector accent /> |
| 93 | </Column> |
| 94 | |
| 95 | {/* ── Session (the hub) ──────────────────────────────────── */} |
| 96 | <Column> |
| 97 | <Lane label="Session" accent /> |
| 98 | <div className="flex flex-1 flex-col"> |
| 99 | <div className="relative flex-1 border border-[var(--composio-brand)]/30 bg-[var(--composio-brand)]/[0.04] p-3"> |
| 100 | <span |
| 101 | aria-hidden="true" |
| 102 | className="pointer-events-none absolute inset-y-0 left-0 w-[2px] bg-[var(--composio-brand)]" |
| 103 | /> |
| 104 | <div className="flex items-center justify-between"> |
| 105 | <span className="font-mono text-[10px] uppercase tracking-[0.06em] text-[var(--composio-brand)]"> |
| 106 | scoped to user |
| 107 | </span> |
| 108 | <span className="font-mono text-[10px] text-fd-foreground/45"> |
| 109 | slack:T09:alice |
| 110 | </span> |
| 111 | </div> |
| 112 | |
| 113 | {/* The shared workspace connection + the user's own apps */} |
| 114 | <ul className="mt-2.5 overflow-hidden rounded-sm border border-fd-border bg-fd-card"> |
| 115 | {CONNECTIONS.map((conn, i) => ( |
| 116 | <li |
| 117 | key={conn.slug} |
| 118 | className={ |
| 119 | 'flex items-center gap-2 px-2.5 py-1.5' + |
| 120 | (i < CONNECTIONS.length - 1 ? ' border-b border-fd-border' : '') |
| 121 | } |
| 122 | > |
| 123 | <img |
| 124 | alt="" |
| 125 | aria-hidden="true" |
| 126 | className="size-3.5 object-contain" |
| 127 | draggable={false} |
| 128 | src={`${LOGO_CDN}/${conn.slug}`} |
| 129 | /> |
| 130 | <span className="text-[11px] text-fd-foreground/75">{conn.name}</span> |
| 131 | <span className="font-mono text-[9px] text-fd-foreground/40">{conn.owner}</span> |
| 132 | <span |
| 133 | className={ |
| 134 | 'ml-auto inline-flex items-center gap-1 font-mono text-[9px] uppercase tracking-[0.05em] ' + |
| 135 | (conn.shared ? 'text-[var(--composio-brand)]' : 'text-fd-foreground/45') |
| 136 | } |
| 137 | > |
| 138 | {conn.shared ? ( |
| 139 | <> |
| 140 | <Share2 aria-hidden="true" className="size-2.5" /> |
| 141 | shared |
| 142 | </> |
| 143 | ) : ( |
| 144 | <> |
| 145 | <Check aria-hidden="true" className="size-2.5" /> |
| 146 | linked |
| 147 | </> |
| 148 | )} |
| 149 | </span> |
| 150 | </li> |
| 151 | ))} |
| 152 | </ul> |
| 153 | |
| 154 | <p className="mt-2.5 text-[11px] leading-snug text-fd-foreground/60"> |
| 155 | Posts to Slack as the workspace bot; acts in every other app as the |
| 156 | user. |
| 157 | </p> |
| 158 | </div> |
| 159 | </div> |
| 160 | </Column> |
| 161 | </div> |
| 162 | |
| 163 | {/* footer caption */} |
| 164 | <div className="border-t border-fd-border px-3 py-2 text-center font-mono text-[10px] text-fd-foreground/45"> |
| 165 | message <Arrow /> trigger <Arrow /> agent <Arrow /> session (shared slack + |
| 166 | user apps) <Arrow /> reply |
| 167 | </div> |
| 168 | </div> |
| 169 | ); |
| 170 | } |
| 171 | |
| 172 | function Column({ children }: { children: ReactNode }) { |
| 173 | return <div className="relative flex flex-col gap-2 bg-fd-background p-3">{children}</div>; |
| 174 | } |
| 175 | |
| 176 | function Lane({ label, accent = false }: { label: string; accent?: boolean }) { |
| 177 | return ( |
| 178 | <div className="flex items-center gap-1.5"> |
| 179 | <span |
| 180 | className={'size-1.5 rounded-full ' + (accent ? 'bg-[var(--composio-brand)]' : 'bg-fd-foreground/30')} |
| 181 | aria-hidden="true" |
| 182 | /> |
| 183 | <span |
| 184 | className={ |
| 185 | 'font-mono text-[10px] font-medium uppercase tracking-[0.07em] ' + |
| 186 | (accent ? 'text-[var(--composio-brand)]' : 'text-fd-foreground/55') |
| 187 | } |
| 188 | > |
| 189 | {label} |
| 190 | </span> |
| 191 | </div> |
| 192 | ); |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Directional connector shown between columns. Horizontal arrow on desktop, |
| 197 | * vertical on stacked mobile so the flow still reads top-to-bottom. |
| 198 | */ |
| 199 | function Connector({ accent = false }: { accent?: boolean }) { |
| 200 | const color = accent ? 'bg-[var(--composio-brand)]/40' : 'bg-fd-border'; |
| 201 | const tip = accent ? 'border-l-[var(--composio-brand)]/50' : 'border-l-fd-border'; |
| 202 | return ( |
| 203 | <div |
| 204 | aria-hidden="true" |
| 205 | className="pointer-events-none absolute z-10 hidden md:block" |
| 206 | style={{ right: '-7px', top: '50%' }} |
| 207 | > |
| 208 | <div className="flex items-center"> |
| 209 | <span className={'h-px w-3 ' + color} /> |
| 210 | <span className={'size-0 border-y-[3px] border-l-[5px] border-y-transparent ' + tip} /> |
| 211 | </div> |
| 212 | </div> |
| 213 | ); |
| 214 | } |
| 215 | |
| 216 | function Arrow() { |
| 217 | return ( |
| 218 | <span aria-hidden="true" className="text-[var(--composio-brand)]"> |
| 219 | {'→'} |
| 220 | </span> |
| 221 | ); |
| 222 | } |