Ask Assistant

Action ID: openai_ask_assistant

Description

Ask a GPT assistant anything you want! This node allows you to interact with OpenAI assistants, which are specialized AI agents configured with specific instructions, tools, and knowledge. You can ask questions and maintain conversation memory across runs using memory keys.

Provider

OpenAI

Connection

Name
Description
Required
Category

OpenAI Connection

The OpenAI connection to use for the assistant.

openai

Input Parameters

Name
Type
Required
Default
Description

assistant

dropdown

-

The assistant which will generate the completion.

prompt

string

-

The text prompt to ask the assistant.

memory_key

string

-

-

A memory key that will keep the chat history shared across runs. Leave empty to leave your assistant without memory of previous messages.

View JSON Schema
{
  "description": "Ask Assistant node input.",
  "properties": {
    "assistant": {
      "description": "The assistant which will generate the completion.",
      "title": "Assistant",
      "type": "string"
    },
    "prompt": {
      "description": "The text prompt to ask the assistant.",
      "title": "Question",
      "type": "string"
    },
    "memory_key": {
      "description": "A memory key that will keep the chat history shared across runs. Leave empty to leave your assistant without memory of previous messages.",
      "title": "Memory Key",
      "type": "string"
    }
  },
  "required": [
    "assistant",
    "prompt"
  ],
  "title": "AskAssistantInput",
  "type": "object"
}

Output Parameters

Name
Type
Description

messages

array

List of messages from the assistant containing the response.

View JSON Schema
{
  "description": "Response from asking an assistant.",
  "properties": {
    "messages": {
      "description": "List of messages from the assistant.",
      "items": {
        "description": "Message from an assistant.",
        "properties": {
          "id": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "content": {
            "items": {},
            "type": "array"
          },
          "created_at": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "type": "array"
    }
  },
  "title": "AskAssistantResponse",
  "type": "object"
}

How It Works

This node communicates with an OpenAI assistant through the Assistants API. The assistant is a pre-configured AI entity that may have specific instructions, tools (like code interpreter or web search), and files attached to it. When you ask a question, the node sends your prompt to the assistant and retrieves the response. The optional memory_key parameter allows you to maintain conversation history across multiple workflow runs, enabling persistent conversations with the assistant.

Usage Examples

Example 1: Simple Question to Assistant

Input:

assistant: "asst_abc123def456"
prompt: "What is machine learning?"

Output:

messages: [
  {
    "id": "msg_123",
    "role": "assistant",
    "content": [
      {
        "type": "text",
        "text": {
          "value": "Machine learning is a subset of artificial intelligence..."
        }
      }
    ],
    "created_at": 1699564800
  }
]

Example 2: Question with Memory

Input:

assistant: "asst_coding_helper"
prompt: "Now implement the algorithm in Python"
memory_key: "user_123_conversation"

Output:

messages: [
  {
    "id": "msg_456",
    "role": "assistant",
    "content": [
      {
        "type": "text",
        "text": {
          "value": "Here's a Python implementation..."
        }
      }
    ],
    "created_at": 1699565000
  }
]

Common Use Cases

  • Custom AI Assistants: Leverage specialized assistants configured with specific knowledge and tools

  • Persistent Conversations: Maintain context across multiple interactions using memory keys

  • Document Analysis: Use assistants with document retrieval to analyze uploaded files

  • Code Assistance: Leverage code interpreter capabilities built into assistants

  • Multi-turn Conversations: Build workflows that handle back-and-forth dialogue

  • Tool Integration: Use assistants that have access to functions and external tools

  • Domain-Specific Knowledge: Interact with assistants fine-tuned for specific domains

Error Handling

Error Type
Cause
Solution

Assistant Not Found

Selected assistant ID doesn't exist

Verify the assistant ID and ensure it's accessible with your API key

Authentication Error

Invalid or missing OpenAI API key

Verify your OpenAI connection is properly configured

Invalid Prompt

Prompt is empty or malformed

Ensure your prompt is a non-empty string

Memory Key Error

Issue accessing memory storage

Check memory key format and ensure storage is accessible

Rate Limit Error

Too many requests in a short period

Implement delays between requests or upgrade your OpenAI plan

Timeout Error

Request took too long to process

Try with a simpler prompt or shorter expected responses

Notes

  • Assistant Selection: Select from your existing OpenAI assistants. Create new assistants in the OpenAI dashboard if needed.

  • Memory Keys: Using a memory_key creates a persistent conversation thread. Leaving it empty creates independent, stateless interactions.

  • Response Format: Responses are returned as message objects with content arrays that may contain text, code, or other content types.

  • Streaming: For long-running operations, consider implementing streaming or async patterns in your workflow.

  • Cost: Assistant API calls may have different pricing than ChatGPT API calls. Check OpenAI's pricing page for current rates.

Last updated

Was this helpful?