Skip to content

AIWebChat Node ​

The AIWebChat node allows users to submit a prompt and optionally a context window to an AI web chat service (e.g., OpenAI) and receive a response. This response can either be interpreted as structured code (e.g., JSON) or plain text, and the result is stored in a named variable for downstream use.


🧠 Purpose ​

Use this node to:

  • Interact with an AI service via a simple input prompt.
  • Provide additional context to guide the AI’s response.
  • Store results from AI responses in a reusable workflow variable.
  • Optionally, extract structured code snippets from the response.

βš™οΈ Node Configuration ​

This node is configured via a modal form in the Workflow UI. Users must fill out the following fields:

Field LabelTypeRequiredDescription
User InputTextβœ…The primary user message or question to send to the AI service.
Context WindowTextβœ…Optional context to provide additional instruction or history to the AI.
Request Code OnlyBooleanβœ…If set to true, the node attempts to extract a code block or object from the AI's response.
Save to Variable NameTextβœ…The name of the variable in which to store the result from the AI service.

πŸ’‘ Context Window is pre-processed by appending system information such as country and timestamp before being sent to the AI service.


πŸ§ͺ Example Use Case ​

Let’s say a user wants to generate a sample JSON schema for a user profile form. They would:

  • Input: "Create a JSON schema for a user profile with name, email, and age"
  • Context Window: "Return only the object without explanation"
  • Request Code Only: true
  • Save to Variable Name: userSchema

This will store the parsed JSON object (if successful) into userSchema.


🧰 Runtime Behavior ​

  1. Validation: Ensures all required inputs are present.
  2. Service Resolution: Looks up credentials for the ServiceAccount-OpenAI.
  3. AI Request: Constructs the final prompt using system metadata and context.
  4. Response Handling:
    • If Request Code Only is true, attempts to deserialize the result into a JSON object.
    • Fallback: Saves raw string output.
  5. Storage: Stores the final result in the specified variable name.

πŸ“¦ Output ​

  • Output Variable: The result from the AI is saved to the variable provided in the Save to Variable Name field.
  • The result may be:
    • A raw string (e.g., a paragraph or code snippet).
    • A parsed JSON object if deserialization is successful and Request Code Only = true.

⚠️ Error Handling ​

  • If the AI service fails to return a response, the node fails with status "Fail" and a message (AIAgent) - AI Service Failed.
  • If the OpenAI service account cannot be found, the task will also fail.
  • Exceptions during deserialization are caught, and the raw output is used instead.

πŸ” Permissions & Service Accounts ​

This node depends on a configured ServiceAccount-OpenAI. This must be defined and accessible within your automation environment.


πŸ“˜ Notes ​

  • The AI service is invoked via AISingleReequest() with system and user context prepended.
  • The timestamp and country are dynamically added at runtime to enhance contextual relevance.

βœ… Success Criteria ​

  • The AI returns a response.
  • If Request Code Only is true, the response is successfully deserialized (or falls back gracefully).
  • Output is stored under the specified variable name.
  • taskSuccess = true, statusReturn = "Completed"

Tentech 2024