Actions20
- Assistant Actions
- Embedding Actions
- File Actions
- Report Actions
- Text Actions
- Thread Actions
Thread → Create and Run Thread
AI-generatedOverview
The "Create and Run Thread" operation in this OpenAI Analytics node allows users to create a new conversational thread with an assistant, add one or multiple messages to it, optionally attach files, run the thread (i.e., send the conversation to the assistant for processing), and wait for the completion of the run to receive the results. This operation is useful for automating interactions with AI assistants where you want to start a fresh conversation, provide initial context or multiple messages, and get immediate responses.
Common scenarios include:
- Starting a new chat session with an AI assistant with a single prompt or multiple messages.
- Attaching relevant files (documents, data) to provide additional context to the assistant.
- Overriding default system instructions to customize assistant behavior.
- Waiting for the assistant's response synchronously before continuing workflow execution.
Practical example:
- A user wants to generate a report summary by creating a new thread, sending multiple messages describing the report sections, attaching related files, and receiving the summarized output immediately.
Properties
| Name | Meaning |
|---|---|
| Authentication | Choose between using dedicated OpenAI Analytics API credentials or existing OpenAI API credentials. |
| Message Input Method | Select how to input messages: either a single message or multiple messages with specified roles (user or system). |
| Initial Message | The initial message content to add to the thread when using single message input method. Required if single message method is selected. |
| Messages | List of messages to add to the thread when using multiple messages input method. Each message includes a role (User or System) and content. |
| File Attachment Method | How to attach files to the thread: use existing file IDs, upload binary files from previous node, both methods, or no file attachments. |
| Binary Property | The name of the binary property containing file data from the previous node, used when uploading files. |
| File Purpose | Purpose of uploaded files, e.g., for use with assistants or as input to assistants. |
| Enable File Attachments | Whether to attach existing uploaded files to the thread. |
| File IDs | List of existing file IDs to attach to the thread. |
| Wait for Completion | Whether to wait for the thread run to complete before returning the result. |
| Maximum Poll Time (Seconds) | Maximum time in seconds to wait for the run to complete if waiting for completion. |
| Instructions | Optional override for the default system instructions of the assistant. |
| Simplify Output | Whether to return a simplified response format instead of detailed raw data. |
| Select Assistant | How to select the assistant to use: from a list or by entering an assistant ID directly. |
| Assistant | The assistant selected from the list (required if selecting from list). |
| Assistant ID | The ID of the assistant to use for the run (required if selecting by ID). |
Output
The node outputs JSON data representing the result of the thread run. The structure depends on whether the "Simplify Output" option is enabled:
- If simplified output is enabled, the response contains a concise, user-friendly summary of the assistant's reply.
- Otherwise, the output includes detailed information about the thread run, including messages, status, and metadata.
If files are attached, the node handles them internally but does not output binary data directly in this operation.
Dependencies
- Requires valid API credentials for OpenAI Analytics API or OpenAI API.
- Needs network access to OpenAI endpoints.
- Uses OpenAI's official SDK client for API communication.
- For file uploads, expects binary data from previous nodes in n8n.
- The node dynamically loads available assistants and files via API calls.
Troubleshooting
- Credential Errors: If credentials are missing or invalid, the node will fail to authenticate. Ensure correct API keys and optional organization IDs are configured.
- File Attachment Issues: Uploading files requires proper binary data in the specified property. Missing or incorrectly named binary properties cause failures.
- Timeouts: When waiting for completion, if the maximum poll time is too short, the node may timeout before the run finishes. Increase the "Maximum Poll Time" if needed.
- Assistant Selection: Selecting an assistant by ID requires a valid existing assistant ID; otherwise, the run will fail.
- Message Validation: Messages must have required fields (role and content). Empty content or missing roles can cause errors.
- API Rate Limits: Hitting OpenAI API rate limits will cause errors; consider adding retry logic or increasing limits.