1
Create a project
2
Install the latest dependencies
3
Create an API key
Navigate to C1 Console and create a new API key.
4
Set up a backend endpoint
First, create a message history store. This is a simple in-memory store for the messages in the chat.Then, setup the backend endpoint using the message history store. In a typical Next.js application using the
App Router, a simple endpoint for an agent may look like this:
app/api/chat/messageStore.ts
app/api/chat/route.ts
5
Set up the frontend
To integrate the frontend, use the
C1Chat component. This component includes a ready-to-use chat interface that manages its own state. All you need to do is pass the apiUrl prop pointing to your backend endpoint.Example implementation:app/page.tsx