I’m using the ChatKit JS widget on my own site and connecting it to an Agent workflow built in the OpenAI Builder. The chat UI works fine (token exchange, history, etc.), but I can’t figure out the right way to let the agent know who the user is.
Specifically, I want the workflow to have access to a userId for:
-
tool/MCP calls (e.g. fetching user-specific data)
-
or internal context (scoping behavior per user)
Here’s my current setup:
-
Frontend calls my API
/api/chatkit/start→ creates a ChatKit session viaPOST https://api.openai.com/v1/chatkit/sessions -
I send
user: "<my-user-id>"in that payload before returning theclient_secretto the widget.
That all works. But inside the Agent Builder, I can’t see any way to access that user value.
Questions:
-
Does
userfrom the ChatKit session become available in the workflow (likesession.userorcontext.user)? -
If not, what’s the best practice for passing identity into the workflow?
-
via a metadata or instructions field when creating the session?
-
via an HTTP or MCP tool that fetches it from my backend on the first turn?
-
-
Is there any built-in way to template headers or variables (like
{{session.user}}) in tool calls?
I just want a clean, supported way for an agent hosted by OpenAI to know which user is chatting through my own frontend.