Hey. How can we access a current user (passed to the session when it was created from ChatKit) inside the agentic workflow? Right now, we have an option to pass a user to the ChatKit session (https://platform.openai.com/docs/api-reference/chatkit/sessions/create#chatkit-sessions-create-user), but there is no way to get that value and use it inside the tool (or an MCP server).
All existing templates (flows) in the agent builder cover simple use cases, but any suggestions on how to inject different users(can be userID or user token)?
4 Likes
Hey, we’re working on providing some hooks into accessing this value for hosted ChatKit!
4 Likes
As far as I understand, when you create a session you can set a state variable, which can then be used within the agent builder.
Current openai-node v6.3.0 api:
const session = await openai.beta.chatkit.sessions.create({
user: userId,
workflow: {
state_variables: {
user_id: userId,
},
id: 'wf_your_id',
},
})
1 Like
Oh wow, this worked for me, thanks! That’s the second time I missed the “Add” button, I was trying to figure out how to pass the output from one agent as the input of the next, and had to hit the “Add” button to add instructions and put the {{output_from_prev_agent}} as the input to the next agent.