Web TippsUse custom web fonts in Google Sheets charts(08.09.2026 um 17:05 Uhr)
Web TippsIntroducing the new 1Password App for Google Chat(08.09.2026 um 18:02 Uhr)
Web TippsUse custom web fonts in Google Sheets charts(08.09.2026 um 17:05 Uhr)
Web TippsIntroducing the new 1Password App for Google Chat(08.09.2026 um 18:02 Uhr)

🔧 Programmierung 🕛 vor 2 Jahren 9 Min Lesezeit
0

🚀How I integrated an AI copilot into Dub.co (in a few minutes)🤖✨

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

In this article, you'll learn how to add an AI copilot to Dub.co, an open-source link management system. Using CopilotKit, you'll also learn how to easily create and delete short links, improving the overall user experience of the application.



You can use this as a case-study for how to easily add an AI copilot into any open-source application, not just Dub.co. This will easily make you seem like an AI coding master.





- an open-source copilot framework for building custom AI chatbots, in-app AI agents, and text areas.


  • - a software application for defining and running multi-container Docker applications.


  • - to enable us to perform various tasks using the GPT models.









  • How to set up Dub.co on your local computer



    by running the code snippet below.




    CODE
    git clone https://github.com/dubinc/dub.git






    Navigate into the dub folder and install the project dependencies:




    CODE
    pnpm install






    Within the apps/web folder, rename the .env.example file to .env.



    Create a new and copy the following credentials from the REST API section to the .env file:




    CODE
    UPSTASH_REDIS_REST_URL=<your_rest_url>
    UPSTASH_REDIS_REST_TOKEN=<your_rest_token>






    Navigate to the and copy the URL below as its callback URL.




    CODE
    http://localhost:8888/api/auth/callback/github






    Finally, start the development server:




    CODE
    pnpm dev






    Access the web application by navigating to http://localhost:8888 in your browser, create a workspace, and get started. If you encounter any issues, refer to the









    How to integrate CopilotKit to Dub.co



    In this section, you'll learn how to add an AI copilot to Dub.co using CopilotKit.



    Visit the



    Add your newly generated secret key and specify the OpenAI model in your .env file as follows:




    CODE
    OPENAI_API_KEY=<YOUR_OPENAI_SECRET_KEY>
    OPENAI_MODEL=gpt-4-1106-preview






    Navigate into the app/api folder and create a copilotkit directory containing a route.ts file.




    CODE
    cd app/api
    mkdir copilotkit && cd copilotkit
    touch route.ts






    Copy the following the following code snippet into the api/copilotkit/route.ts file:




    CODE
    import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/backend";

    export const runtime = "edge";

    export async function POST(req: Request): Promise<Response> {
    const copilotKit = new CopilotRuntime({});
    const openaiModel = process.env["OPENAI_MODEL"];
    return copilotKit.response(req, new OpenAIAdapter({ model: openaiModel }));
    }






    The









    How to perform various actions using CopilotKit



    CopilotKit provides two hooks that enable us to handle user's request and plug into the application state: .



    The useCopilotAction hook allows you to define actions to be carried out by CopilotKit. It accepts an object containing the following parameters:




    • name - the action's name.

    • description - the action's description.

    • parameters - an array containing the list of the required parameters.

    • render - the default custom function or string.

    • handler - the executable function that is triggered by the action.




    CODE
    useCopilotAction({
    name: "sayHello",
    description: "Say hello to someone.",
    parameters: [
    {
    name: "name",
    type: "string",
    description: "name of the person to say greet",
    },
    ],
    render: "Process greeting message...",
    handler: async ({ name }) => {
    alert(`Hello, ${name}!`);
    },
    });






    The useCopilotReadable hook passes the application state into CopilotKit.




    CODE
    import { useCopilotReadable } from "@copilotkit/react-core";

    const myAppState = "...";
    useCopilotReadable({
    description: "The current state of the app",
    value: myAppState,
    });






    Now, let's plug the application states into CopilotKit to perform various actions, such as creating and deleting the short links.



    Navigate into the ui/links/links-container.tsx folder and update the LinksContainer function as shown below:




    CODE
    export default function LinksContainer({
    AddEditLinkButton,
    }: {
    AddEditLinkButton: () => JSX.Element;
    }) {
    const { viewMode, sort, showArchived } = useContext(LinksDisplayContext);
    const { links, isValidating } = useLinks({ sort, showArchived });
    const { data: count } = useLinksCount({ showArchived });
    //👇🏻 React state for all links
    const [updatedLinks, setUpdatedLinks] = useState<ResponseLink[]>(links || []);

    //👇🏻 update the state with all the links
    useEffect(() => {
    setUpdatedLinks(links || []);
    }, [links]);

    useCopilotReadable({
    description:
    "This is the list of links you have saved. You can click on a link to view it, or use the search bar to find a specific link.",
    value: updatedLinks,
    });

    return (
    <MaxWidthWrapper className="grid gap-y-2">
    <LinksList
    AddEditLinkButton={AddEditLinkButton}
    links={links}
    count={count}
    loading={isValidating}
    compact={viewMode === "rows"}
    />
    <DeleteLinkModal />
    </MaxWidthWrapper>
    );
    }






    The updatedLinks React state stores the links created within the application and the useCopilotReadable passes the links into CopilotKit.



    Below the useCopilotReadable hook, add the following code snippet to allow users to delete links from the application:




    CODE
    useCopilotAction({
    name: "deleteShortLink",
    description: "delete a link from the database via its ID",
    parameters: [
    {
    name: "id",
    type: "string",
    description: "The ID of a short link",
    required: true,
    },
    ],
    render: "Deleting link...",
    handler: async ({ id }) => {
    if (!id) return;
    const link = updatedLinks?.find((link) => link.id === id);
    if (!link) return;
    setSelectedLink(link);
    setShowDeleteLinkModal(true);
    },
    });








    Congratulations! You have successfully integrated CopilotKit into Dub.co. You can access  is an incredible tool that allows you to add AI Copilots to your products within minutes. Whether you're interested in AI chatbots and assistants or automating complex tasks, CopilotKit makes it easy.



    If you need to build an AI product or integrate an AI tool into your software applications, you should consider CopilotKit.



    You can find the source code for this tutorial on GitHub:



    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
    Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    3 Quellen
    Use custom web fonts in Google Sheets charts
    2 Quellen
    Introducing the new 1Password App for Google Chat
    1 Quelle
    Context-aware access controls are available for Gemini Enterprise in the Admin console
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten 🚀How I integrated an AI copilot into Dub.co (in a few minutes)🤖✨

    Thematisch verwandte Begriffe: integrated, copilot, into, Dubco · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...