LogoLogo
Visit Contextual.ioSign Up
  • Getting Started
    • Welcome
    • Tour: Hello, AI World!
  • TRAINING
    • Basic Developer Training Course
      • Lesson 1: HTTP Agent Introduction
      • Lesson 2: Logging and Error Handling Basics
      • Lesson 3: Event Processing Agent Introduction
  • Services Catalog
    • What's in the Catalog?
      • Intro Patterns
      • Object Type Bundles
    • Browse by Platform
    • All Intro Patterns
      • Anthropic Claude Image Analysis
      • Mistral AI Prompt and Response
      • xAI Grok Prompt and Response
      • DeepSeek Chat Prompt and Response
      • Qwen Chat Prompt and Response
      • Perplexity AI Search and Response
      • Firecrawl Website Scraper
      • Groq Prompt and Response
      • Nyckel Dog Breed Classification
      • RapidAPI ClassifyAI Text Classification
      • RapidAPI YouTube AI Video Summary
      • UnifyAI Model Comparison
      • WebPilot URL Analysis and Summarization
      • OpenAI Assistants Prompt and Response
      • OpenAI Sync
    • All Prebuilt Solutions
      • Invoice AI
      • Lead Generation Form
    • All Object Type Bundles
      • Work Order Management System ITIL Object Type Bundle
        • Work Order
        • User
        • Role
        • Permission
        • Asset
        • Task
        • Action
        • Attachment
        • Comment
        • Notification
        • Audit Log
        • Service Level Agreement
        • Custom Fields
        • Work Order Template
        • Work Order Transition
        • Escalation Policy
        • Tag
  • Components & Data
    • Object Types
      • Data in Contextual
        • Secrets
        • Validation
        • Versioning
      • Examples
      • Creating an Object Type
      • Object Type Details
        • Definition
        • Data Schema
          • Automatic Record Metadata
          • Generated Values
            • Dates and Times
            • UUIDs
          • Frequently Used Validation
          • Disallowing Null Property Values
          • Disallowing Undefined Properties
          • Secrets
          • AI Assistant
          • ID and PrimaryKey Permanence
        • UI Schemas
        • Features
        • Triggers
        • Actions
        • Audit Trail
        • Versions
        • Templates
        • Records
      • Using Object Types in Flows
      • Records
        • Records and Your Tenant API
        • Record Import
    • Flows
      • Nodes
      • Wires
      • Message Object
      • Flow Editor
        • Basics
        • Saving Changes
        • In-Flow Testing with Debugger
        • Restart Agents to Make Changes Active
        • Config
      • Node Reference
        • Common
          • Log Tap
          • Inject
          • Debug
          • Complete
          • Catch
          • Status
          • Link In
          • Link Call
          • Link Out
          • Comment
        • Event
          • Prepare Event
          • Event Start
          • Event End
          • Event Error
        • Object
          • Search Object
          • Get Object
          • Create Object
          • Patch Object
          • Put Object
          • Delete Object
          • Run Action
        • Request
          • Send to Agent
          • HTTP GET
          • HTTP PATCH
          • HTTP PUT
          • HTTP DELETE
          • HTTP POST
          • GQL
          • Produce Message
        • Function
          • Function
          • Switch
          • Change
          • Range
          • Template
          • Delay
          • Trigger
          • Exec
          • Filter
          • Loop
        • Models
          • ML Predict
        • Network
          • MQTT In
          • MQTT Out
          • HTTP In
          • HTTP Response
          • HTTP Request
          • WebSocket In
          • WebSocket Out
          • TCP In
          • TCP Out
          • TCP Request
          • UDP In
          • UDP Out
        • Sequence
          • Split
          • Join
          • Sort
          • Batch
        • Parser
          • csv
          • html
          • json
          • xml
          • yaml
    • Agents
      • Creating an Agent
      • Types of Agents
        • Event to Flow
        • HTTP to Flow
          • Custom Domains
      • How Agents Work
        • Flow Execution
        • HTTP Load Balancing
        • Event Routing
      • Scale and Performance
        • Flow execution
        • Parallel Instances
        • Event Lag Scaling
        • Compute Threshold Scaling
        • Instance Compute Sizing
      • Agent Details
        • Definition
        • Operations
        • Logs
          • Session Log
          • Message Log
        • Audit Trail
        • Versions
      • Using Agents in Flows
    • Connections
      • Creating a Connection
      • Types of Connections
        • Basic
        • Bearer
        • Client Grant
        • Kafka
        • Password Grant
        • Public
        • Pulsar
      • Using Connections in Flows
    • JWKS Profiles
      • Using JWKS Profiles in Your Solution
  • PATTERNS
    • Solution Architecture
      • Events, Messages, Queues
    • Working with Data
      • Search Object Node & Pagination
      • Message Payload Content - Triggers and Actions
    • Industry Cookbooks
      • Field Services
  • Tenants
    • Tenant Workspace
    • Tenant Logs
      • Contextual Log Query Language (CLQL)
        • String Searches
        • Keyword Searches
        • Advanced Operators
    • Tenant API
      • API Keys
        • API Key Settings
        • API Key Permissions
      • Documentation
  • Release Notes
    • 2024
      • 2024.12.09
Powered by GitBook
On this page
  • Flow Overview:
  • Detailed Flow Structure

Was this helpful?

  1. Services Catalog
  2. All Intro Patterns

OpenAI Assistants Prompt and Response

The OpenAI Assistants Example Flow facilitates prompt-based interactions with the OpenAI Assistants API, setting up threads, preparing messages, and handling the response to create structured records. Designed to support testing, API interaction, response management, and robust error handling, this flow enables efficient handling of conversational AI and RAG-powered responses.

You can find this template in the Services Catalog under these categories:

  • AI, Enrichment

What's Included:

  • 1 Flow

  • 1 Object Type

  • 1 Connection

Requirements:

  • Access to the OpenAI Assistants API

  • API Key for the OpenAI Assistants service

Ideas for Using the OpenAI Assistants Example Flow:

  • Enhanced Knowledge Retrieval: Deploy Assistants to retrieve contextually relevant answers from specialized knowledge databases. Ideal for scenarios where users need immediate access to intricate data, such as technical support or expert assistance.

  • Campaign Ideation: Use the flow to generate ideas grounded in specific datasets, transforming a prompt into tailored suggestions. This approach is beneficial for creative work, from content ideation to ad campaign concepts.

  • Decision Intelligence: Enable real-time, data-driven decision-making by embedding Assistants that sift through dense information, highlighting insights for rapid business analysis.


Flow Overview:

Flow Start

The flow begins with In-Editor Testing, where users can input a test prompt to verify prompt processing and the response pathway.

API Interaction: Sending Prompt and Receiving Response

The prompt is sent to the OpenAI Assistants API, and the response is logged, providing traceability and clarity for any issues encountered.

Format Response & Create Record

Responses from the Assistant are structured and stored in records, with a full record of the original prompt and AI-generated content.

Error Handling

Error handling captures and logs issues at each stage to ensure reliable, clear debugging.

Flow End

Completes with either successful record creation or logged errors for troubleshooting.


Detailed Flow Structure

Inbound Send to Agent Events

Nodes: contextual-start Purpose: Initializes the flow based on an external trigger.

In-Editor Testing

Nodes: Test Prompt, Prepare Assistant Message Purpose: Enables testing in the editor. The test prompt is structured and sent to the OpenAI Assistants API.

Code Example: Prepare Assistant Message Function

// Prepare the payload for OpenAI Assistants request
msg.payload = {
    role: "user",
    content: msg.prompt
};
return msg;

Explanation: Structures the user prompt for compatibility with the OpenAI Assistants API.

API Interaction: Send Prompt and Receive Response

Nodes: Run Assistant on Thread, Run Result Log Purpose: Sends the prompt to OpenAI Assistants and logs the response.

Code Example: Run Result Log

// Log the Assistant's response for future review
msg.runDetail = msg.runDetail; 
return msg;

Format Response & Create Record

Nodes: Prepare Record Data, Create AI Response Record, Create AI Response Log Purpose: Converts the Assistant's response into a structured record, organizing both the prompt and the response content.

Code Example: Prepare Record Data Function

// Format data for record creation
let body = {
    prompt: msg.threadMessages.data[1].content[0].text.value,
    aiResponse: msg.threadMessages.data[0].content[0].text.value
};
msg.payload = body;
return msg;

Explanation: Formats the retrieved data into a structured format for seamless record storage.

Error Handling

Nodes: catch, Error Catch Log, contextual-error Purpose: Captures and logs any errors throughout the flow.

Flow End

Nodes: contextual-end Purpose: Ends the flow by finalizing the record creation or logging errors if encountered.


Summary of Flow:

  1. Flow Start: Test with a prompt or trigger externally.

  2. Data Preparation: Format the user’s prompt for sending.

  3. API Interaction: Process the prompt and capture responses.

  4. Record Creation: Store prompt and response as structured data.

  5. Error Handling: Capture and log any errors.

  6. Flow End: Finalize upon record creation or error logging.

PreviousWebPilot URL Analysis and SummarizationNextOpenAI Sync

Last updated 6 months ago

Was this helpful?

Page cover image