OpenAI Functions Agent node

Use the OpenAI Functions Agent node to use an OpenAI functions model. These are models that detect when a function should be called and respond with the inputs that should be passed to the function.

Refer to AI Agent for more information on the AI Agent node itself.

You can use this agent with the Chat Trigger node. Attach a memory sub-node so that users can have an ongoing conversation with multiple queries. Memory doesn’t persist between sessions.

Note

OpenAI Chat Model required You must use the OpenAI Chat Model with this agent.

Node parameters

Configure the OpenAI Functions Agent using the following parameters.

Prompt

Select how you want the node to construct the prompt (also known as the user’s query or input from the chat).

Choose from:

  • Take from previous node automatically: If you select this option, the node expects an input from a previous node called chatInput.

  • Define below: If you select this option, provide either static text or an expression for dynamic content to serve as the prompt in the Prompt (User Message) field.

Require Specific Output Format

This parameter controls whether you want the node to require a specific output format. When turned on, n8n prompts you to connect one of these output parsers to the node:

Node options

Refine the OpenAI Functions Agent node’s behavior using these options:

System Message

If you’d like to send a message to the agent before the conversation starts, enter the message you’d like to send.

Use this option to guide the agent’s decision-making.

Max Iterations

Enter the number of times the model should run to try and generate a good answer from the user’s prompt.

Defaults to 10.

Return Intermediate Steps

Select whether to include intermediate steps the agent took in the final output (turned on) or not (turned off).

This could be useful for further refining the agent’s behavior based on the steps it took.

Templates and examples

Refer to the main AI Agent node’s Templates and examples section.

Common issues

For common questions or issues and suggested solutions, refer to Common issues.