#CopilotKit Actions

1 messages · Page 1 of 1 (latest)

silver stirrup
#

So I am looking to build a custom action with a custom component and I can not work out how to do this in the CopilotChat

I have read the documentation but I am not sure how the backend agent will trigger an in chat UI component.

If there are any other resources that explain things better please let me know

sullen pulsar
#

Hey Ethan, just so I fully understand your ask here - do you want a backend action to result in a custom chat UI component being rendered?

silver stirrup
#

Hi @sullen pulsar yes. I want to create a custom state element that is populated by the LLM on the agent side and upon this custom state element being given a value I want the front end to render a card in the UI with the information from the state.

sullen pulsar
#

Likely, you already know that you need useCopilotAction.

You're able to render backend actions in the frontend. This is currently undocumented but will be added soon as we're overhauling our docs.

With that being said, you can render any backend defined action (tool) by giving a render to useCopilotAction where the name matches the backend action.

Say you have a backend action call sayHello. You can have that tool exist in the backend and then render it in the front-end.

// page.tsx
useCopilotAction({
  name: "sayHello"
  available: "disable" // try without this first, and if it isn't working add this
  render: ({state, args}) => {
    return <div>hello</div>
  }
})
silver stirrup
#

Ok, that makes a bit more sense - I will test this out today

#

I am lloking for the code to implement that backend action in python - is there documentation on this?

sullen pulsar
silver stirrup
#

Yes this is what I was looking for. I am looking forward to seeing the new documentation because you are definitely doing some great stuff

#

FYI I’m working on an official AI powered BI system for Tripadvisor using your framework. I will have to speak with someone in your team about rate limits etc because there will be a lot of traffic once this is live. @sullen pulsar

sullen pulsar
#

Absolutely, let's get some time down.

silver stirrup
#

Thank you. I’ll schedule some time in later today after checking with the team.

#

Can you send me this link on a private discord chat thank you?