Integrating Tako Cards into a Vercel Next.js AI Chatbot
Add interactive knowledge cards to your AI chatbot
Augment an existing Next.js 14 chatbot (built with the Vercel AI SDK) so it can answer questions using real‑time, trusted data from Tako and display rich Knowledge Cards right in the chat UI.
1 · Prerequisites
All steps below assume the canonical nextjs‑ai‑chatbot code base. If you started from scratch, follow Vercel’s Quickstart first, then return here.
2 · Install the Tako SDK
3 · Add a searchTakoKnowledge tool
4 · Wire the tool into the Edge Route
Open app/(chat)/api/chat/route.ts
and make three small edits:
-
Add the import at the top
-
Register the executor in the
tools
map:
That’s it—no other middleware or route changes are necessary.
5 · Render Knowledge Cards in the Chat UI
Inside components/message.tsx
, extend the preview switch so it recognises the new tool:
This simply maps the knowledge_cards
array to a deck of responsive <TakoCard>
components.
With this in place, every time the model invokes searchTakoKnowledge
, the returned array of cards is rendered as a deck of responsive iframes.
6 · Create the TakoCard component
This component embeds each Knowledge Card via Tako’s embed_url, responds to dynamic height messages for a seamless fit, and uses your existing Card UI primitive for consistent styling.
With this in place, every time the model invokes searchTakoKnowledge, the returned array of cards is rendered as a deck of responsive iframes.
7 · Deploy
Ensure TAKO_API_KEY
is added to the Vercel Project’s Environment Variables (Production + Preview).