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

pnpm install 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:

  1. Add the import at the top

    import { searchTakoKnowledge } from '@/lib/ai/tools/tako';
    
  2. Register the executor in the tools map:

    tools: {
      searchTakoKnowledge,
      getWeather,
      // …other tools
    }
    

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

vercel --prod

Ensure TAKO_API_KEY is added to the Vercel Project’s Environment Variables (Production + Preview).