Frontend Actions
Learn how to enable your Copilot to take actions in the frontend.
Let the Copilot Take Action
Specify "use client"
(Next.js App Router)
This is only necessary if you are using Next.js with the App Router.
Like other React hooks such as useState
and useEffect
, this is a client-side hook.
If you're using Next.js with the App Router, you'll need to add the "use client"
directive at the top of any file using this hook.
useCopilotAction
In addition to understanding state, you can empower the copilot to take actions. Use the useCopilotAction
hook to define specific tasks that the copilot can perform based on user input.
Test it out!
After defining the action, ask the copilot to perform the task. For example, you can now ask the copilot to "select an employee" by specifying the employeeId
.
Advanced (Generative UI, and more)
- You can render custom components in the chat while actions execute. For more detail see the Generative UI guide.
- For more advanced use cases, refer to the
useCopilotAction
reference.
Cloud & Backend Actions
Backend Action Hooks
Enable backend services to trigger actions via copilot backend hooks.
Enterprise Integrations
For enterprise-grade action support, including CRM or database actions, please reach out for more details.