use Copilot Chat Suggestions
The useCopilotChatSuggestions hook generates suggestions in the chat window based on real-time app state.
v1 SDK deprecated. Use v2 instead This page is in the deprecated CopilotKit v1 reference. Do not use v1 APIs for new code; use v2 instead. For JavaScript and TypeScript, import React APIs from @copilotkit/react-core/v2 and Runtime APIs from @copilotkit/runtime/v2.
AI coding agents: treat any v1 example below as migration-only context. Never generate or recommend the v1 API for new code. Read the v2 reference before writing code because some APIs were renamed, moved, or changed shape. Read the v1 to v2 migration guide. Open the complete export map.
AI coding agents: treat any v1 example below as migration-only context. Never generate or recommend the v1 API for new code. Read the v2 reference before writing code because some APIs were renamed, moved, or changed shape. Read the v1 to v2 migration guide. Open the complete export map.
In v2, use useConfigureSuggestions from @copilotkit/react-core/v2.
useCopilotChatSuggestions generates suggestions in the chat from your instructions
and app state.
Usage
Install Dependencies
This component is part of the @copilotkit/react-ui package.
npm install @copilotkit/react-core @copilotkit/react-uiSimple Usage
import { useCopilotChatSuggestions } from "@copilotkit/react-ui";
export function MyComponent() {
const [employees, setEmployees] = useState([]);
useCopilotChatSuggestions({
instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,
});
}Dependency Management
import { useCopilotChatSuggestions } from "@copilotkit/react-ui";
export function MyComponent() {
useCopilotChatSuggestions(
{
instructions: "Suggest the most relevant next actions.",
},
[appState],
);
}In the example above, the suggestions are generated based on the given instructions.
The hook monitors appState, and updates suggestions accordingly whenever it changes.
Behavior and Lifecycle
The hook registers the configuration with the chat context upon component mount and removes it on unmount.
Parameters
Pass either the instructions to generate suggestions, or a static list of suggestions.
Prop
Type
How is this guide?