docs/content/docs/reference/v1/classes/CopilotTask.mdx
{ /*
In the simplest case, use CopilotTask in the context of your app by giving it instructions on what to do.
import { CopilotTask, useCopilotContext } from "@copilotkit/react-core";
export function MyComponent() {
const context = useCopilotContext();
const task = new CopilotTask({
instructions: "Set a random message",
actions: [
{
name: "setMessage",
description: "Set the message.",
argumentAnnotations: [
{
name: "message",
type: "string",
description:
"A message to display.",
required: true,
},
],
}
]
});
const executeTask = async () => {
await task.run(context, action);
}
return (
<>
<button onClick={executeTask}>
Execute task
</button>
</>
)
}
Have a look at the Presentation Example App for a more complete example.