# 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://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FErBJxH81IL2MN8Xi9PDj%2F4741ee20fd27fef4d7a55275c1c809f7.png?alt=media&#x26;token=49158274-14bf-4fcc-8fed-a76aeb372aaa" 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://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FW8T7uaVPGf0ySit8ft0d%2Fbb37a11146b6d8c143293d8549a0c17a.png?alt=media&#x26;token=4673f2d0-4a0a-4884-bb1e-f0c0e695ce5d" 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://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FQahNOVMJxY6nAiMdi9sU%2F39ccf3c7a549ba2d9e858868da7157dd.png?alt=media&#x26;token=5a13fa5d-371c-4d76-bd6d-7602307582d3" 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://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FIW2wQzNSkhiex6JhDAEb%2Fffa5214b05298e7617dc14f1c69539a0.png?alt=media&#x26;token=f2c6cfda-f65f-41b4-8137-fb69930fab59" 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://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FUmEYGAb9Eip0v3Cu5kh0%2F2c1e1236cd18216d81395989e8c8582c.png?alt=media&#x26;token=0fc701e4-fa17-4374-8c9d-7311c3b30bbb" 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
