ChatKit/AgentKit - How to make the workflow make the first move?

Hi all -

I’m wrestling with some functionality I’m trying to achieve. I am building a conversational onboarding workflow. Right now, my workflow is simple so that I can test the end to end functionality. AgentKit workflow is hosted on openai and I’m running ChatKit on NextJS/React. I have a backend endpoint to mint the token. All that works fine.

Here’s the scenario I want. User hits my onboarding route and ChatKit loads, but I want the workflow to make the first move, not the user. If I’m reading the docs correctly, this is done via a sendAction or sendCustomAction method. The problem is, I can’t seem to create a thread to send the action to. Once the user sends something, my workflow immediately kicks in. But I don’t want the user to have to submit first.

I want the page to load and the user to see my workflow respond with a message, like: “Welcome. I’m here to help get you onboarded. What should I call you?” or similar. Not a chat window waiting for the user to know what to ask for. But if I just call the sendAction method, I get an error because there’s no thread yet. But, I also don’t see a chatKit method for creating a thread either.

What is the correct way to achieve what I’m trying to accomplish?

If I try to send action to initiate, I get this error:

IntegrationError.ts:20 Uncaught (in promise) IntegrationError: ChatKit: sendAction() ignored - no active thread.