Getting Started from Scratch
This guide walks you through setting up a new project from scratch. If you’d just like to get started quickly, check out the Quickstart guide which gets you up and running with a basic template.
Create a project
Install the latest dependencies
Create an API key
Navigate to C1 Console and create a new API key.
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:
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:
If you would like to customize the UI instead of using the pre-built C1Chat
component, see Customizing Crayon
UI.