# Workfx QA Agent

In this section, we introduce a representative use case featuring a simple Agent Flow designed specifically for Workfx-related questions. Key points include:

* The agent **receives user input** in the form of questions.
* It **performs targeted retrieval** from the Workfx introduction document using a predefined knowledge search process.
* The agent **generates relevant answers** based strictly on retrieved content.
* The system is **restricted to a single domain** to ensure all responses align with Workfx’s official documentation.

## Overview of Flow Structure

<figure><img src="https://content.gitbook.com/content/hGfTEVKKLwhhZ4N0zmxX/blobs/3vVOY75pxFEZQTKmgj8V/Use%20Cases%20Agent%20Flow%20Overview.png" alt=""><figcaption></figcaption></figure>

The execution logic of this flow is as follows:

* **Question Classifier Node**\
  The flow begins by determining whether the user’s question is related to Workfx.
* **Workfx-Related Questions**
  * If the question is relevant to Workfx, the system invokes the **knowledge search tool** defined in the “Tool-Flow Tool” section;
  * The tool performs retrieval and returns related content;
  * The agent then generates a natural language response based on the retrieved result.
* **Unrelated Questions**

  * If the question is not related to Workfx, a **Code Node** is used to return a fixed message such as:\
    \&#xNAN;*“Sorry, I can only answer questions related to Workfx.”*

## **Question Classifier Node**

<div data-full-width="false"><figure><img src="https://content.gitbook.com/content/hGfTEVKKLwhhZ4N0zmxX/blobs/cGZy4J8PMPFgGjFFLM7l/Question%20Classifier%20Node%20config.png" alt=""><figcaption></figcaption></figure></div>

**Model Configuration**

* **Model**: `gpt-4o-mini`

**Chat History**

* **Input Variable**: `"User Query"`&#x20;

**Classes**

* **CLASS 1**: Questions about Workfx Introduction
* **CLASS 2**: Questions having nothing to do with Workfx Introduction

## **Tool Node**

<figure><img src="https://content.gitbook.com/content/hGfTEVKKLwhhZ4N0zmxX/blobs/jnTZOl90ldqgzwkUo4Yd/Tool%20Node%20config%20in%20Use%20Cases.png" alt=""><figcaption></figcaption></figure>

### **Tool Metadata**

* **Name**: Knowledge Base Search Tool for Workfx
* **Description**: Introduction KB Search Tool

### &#x20;**Tool Selection**

* **Selected Tool**: `Workfx Introduction KB Search Tool`&#x20;

### **Tool Parameters**

* **Query Prompt**: `</> system.query`&#x20;

the user's original input (`User Query`) is passed directly to the knowledge search tool as the query parameter, without any additional processing or intermediate transformation.

## **Code Node**

<figure><img src="https://content.gitbook.com/content/hGfTEVKKLwhhZ4N0zmxX/blobs/hh7dXNzh632ZXJNxDmOS/Code%20Node%20Config.png" alt=""><figcaption></figcaption></figure>

**Configuration**

* **Input Variables**: None (the node operates independently)
* **Output Field**: `result`
* **Function**: Outputs a fixed message when the question is unrelated to WorkFX, informing the user that the system cannot respond.

**Output Code Logic**

```python
def main() -> dict:
    return {
        "result": "Sorry, this question is not related to WorkFX, so I can't answer it."
    }
```

## **LLM Node**

<figure><img src="https://content.gitbook.com/content/hGfTEVKKLwhhZ4N0zmxX/blobs/p7ZjN4Nji7GBFoWAd5F0/LLM%20Node%20Config.png" alt=""><figcaption></figcaption></figure>

### **Prompt Template**

This prompt guides the LLM to generate an answer based on the retrieved content from the tool:

```
{{#tool-1751255820523.text#}}
Here is some information about WorkFX.
Based on this information, please answer the following question.
{{#system.query#}}
```

* Line 1: Inserts the content returned by the knowledge search tool (`text` field)
* Line 2: Provides context that the answer should be based on that information
* Line 3: Inserts the original user query (`system.query`)

### **Output Variable**

* `final_answer` (or the default output field used by the platform)

### **Input Variables**

* Implicitly bound:
  * `tool-1751255820523.text` (from the knowledge tool)
  * `system.query` (user input)

## **Answer Node**

The final answer in this flow comes from one of two sources:

### **LLM Node Output – For Related Questions**

* **Source**: LLM Node
* **Output Field**: `final_answer`
* **Condition**: Used when the question is related to WorkFX
* **Logic**:
  * Read the generated answer from the LLM Node (`final_answer`)
  * Set it as the response output from the End Node

### **Code Node Output – For Unrelated Questions**

* **Source**: Code Node
* **Output Field**: `result`
* **Condition**: Used when the question is not related to WorkFX
* **Logic**:
  * Read the predefined message from Code Node (`result`)
  * Set it as the response output from the End Node
