Reference OpenAI assistant ID in unconnected flows

I’m working with OpenAI Assistants and have a question about referencing them by ID.

In my setup:

  • In Flow 1 (when a user registers), a new assistant is created and assigned to them. The assistant is named using the format "assistant_{userid}". This part works fine — I get the assistant ID (e.g., asst_ffspwnDAdK6E4dNNRdhStdcH) at creation time.
  • In Flow 2 (triggered later, e.g., by a timer), I need to send a message to the same assistant. At this point, I know the assistant’s name, but I do not have the ID anymore.

Question: Is there a way to either:

  1. Reference an assistant by name, or
  2. Look up the assistant ID later by its name?

Hi @nucjag ,

You can execute a workflow after the trigger and output the assistant id. pass it into the openai id spot. You can either paste in the json to generate the assistant, or choose the name of your workflow.

Here’s the workflow.

If this answer helped solve your issue, feel free to mark it as the solution so others can benefit from it too!

Best,

Robert

1 Like

You could even have the sub workflow only run a portion of the workflow so all of it doesn’t run each time. Let me know if you want me to show that as well!

Hi rbreen,

Thanks for the suggestion—it’s an interesting idea to “wrap” a workflow inside a node!

However, this approach doesn’t quite align with my current model:

  1. The “Create OpenAI Assistant” workflow is a one-time setup per user. It’s resource-intensive in terms of tokens, which is why I opted to separate it as a standalone initialization step.

  2. The “Use Assistant” workflow, on the other hand, is designed to be triggered frequently—potentially multiple times a day per user. This makes it impractical to recreate the assistant every time.

What I really need is a way to convert the assistant’s name into its corresponding ID. One option would be to use an external API to store and retrieve this mapping between flows. However, that feels unnecessarily complex, and I’m hoping there’s a simpler way to achieve this directly within n8n.

1 Like

Hi @nucjag,

I see. You can create assistants via the openai portal, and reference them from your flow. Thats probably the best way to do it. Here’s the link.

https://platform.openai.com/assistants.

You can create the assistant from a workflow and it will show up here as assistants that you can reference.

Best,

Robert

i need automated flow. @Olek can you have a look please?

1 Like

Hopefully @olek can help as well :slight_smile:

but I’ll take another crack at it as well. I see the issue now.

  1. You can create the assistant dynamically with the first flow, and send an error if that assistant already exists with the user id passed into the name.
  2. In the second flow, merge the assistant names with “assistant_userid” to get the assistant assigned to that user.

Here’s a flow.

2 Likes

@nucjag thank you for pinging me.
Your use case is very interesting, but I must admit that I am not as knowledgeable in AI agents space as @rbreen
I myself learned something new from this discussion.
Hope you will crack it.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.