> For the complete documentation index, see [llms.txt](https://docs.aisera.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aisera.com/aisera-platform/ai-automation-optimize-flow/ai-workflow-studio/building-workflows/using-workflow-actions/streaming-actions.md).

# Streaming Actions

Each of the following Actions is discussed in this topic:

* [Fetch LLM Chat Answer With Streaming](#fetch-llm-chat-answer-with-streaming)
* [Public KB Search With Streaming](#public-kb-search-with-streaming)
* [Generate RAG Answer With Streaming](#generate-rag-answer-with-streaming)

***

### Fetch LLM Chat Answer With Streaming

**Description:** Sends chat requests to the AI language model gateway with support for text and image inputs to generate intelligent responses. Supports both streaming (token-by-token) and non-streaming response modes.

**Configuration Parameters:** This action has no configuration parameters.

**Input:**

* **systemPrompt (String, Optional):** The system-level instructions that define the AI's behavior, role, and response guidelines for the conversation.
* **userRequest (String, Optional):** The current text message or question from the user that needs an AI response.
* **imageContent (String, Optional):** A single image provided as either a URL link or base64-encoded data for the AI to analyze.
* **imageAttachments (List\<Map\<String, String>>, Optional):** A list of files that the AI should process. Files can be added by uploading them through the form or user input.
* **conversationHistory (JSONArray, Optional):** A stringified JSON array representing previous conversation turns. Can be found in existing variables under `conversationContext`. Each entry must have `role` (`"system"`, `"user"`, or `"assistant"`) and `content` fields. Use this to maintain context. – example: `[{"role": "user", "content": "Hello"}]`
* **extraMessages (JSONArray, Optional):** Additional messages to include in the request for advanced use cases, formatted as a JSON array with `role` and `content` fields. Uses the same format as `conversationHistory`. – example: `[{"role": "user", "content": "..."}]`
* **configParams (Map\<String, Object>, Optional):** Advanced configuration options for the AI model such as temperature, max tokens, or other model-specific parameters.

**Output:**

* **success (Boolean):** Indicates whether the AI request completed successfully and returned a valid response.
* **responseMessage (String):** The AI-generated text response to the user's request. In streaming mode, delivered incrementally per line until the full response is complete.

{% hint style="info" %}
Messages are built for the LLM request in the following order: `systemPrompt`, `conversationHistory`, `userRequest`, `imageContent`, `imageAttachments`, `extraMessages`. Allowed roles in `conversationHistory` and `extraMessages` are `"system"`, `"user"`, and `"assistant"`.
{% endhint %}

***

### Public KB Search With Streaming

**Description:** Searches publicly accessible knowledge base content for a given query and returns a generated answer with citations. Supports domain filtering to restrict searches to specific websites. In streaming mode, the answer is delivered token by token followed by relevant document references. Search results include the source title, URL, and a content snippet.

**Configuration Parameters:** This action has no configuration parameters.

**Input:**

* **query (String, Required):** The search query to use when searching public knowledge base content.
* **numOfResults (Number, Optional):** The maximum number of search results to retrieve and use for answer generation. Defaults to `3` if not specified.
* **domainWhitelist (List\<String>, Optional):** A list of domain URLs to restrict the search to. If empty, all public domains are searched. – example: `["support.example.com", "docs.example.com"]`
* **enforceDomainWhitelistFilter (Boolean, Optional):** When `true`, the search is only performed if the query's domain matches one in the `domainWhitelist` — otherwise the action returns with status `NoSelectedDomain`. When `false`, the whitelist is used as a preference but does not block the search. Defaults to `false`.
* **supportMarkdown (Boolean, Optional):** When `true`, citation links in the answer are formatted using Markdown syntax. Defaults to `false`.
* **botId (Number, Optional):** The bot ID associated with this action. If not provided, the bot ID from the execution context is used.

**Output:**

* **status (String):** The result status of the search operation. Possible values: `SearchSuccess` (results found and answer generated), `NoSearchResult` (no matching results), `SearchFailed` (an error occurred), `NoSelectedDomain` (query domain not in whitelist when enforcement is enabled).
* **answer (String):** The generated answer text based on the search results, with appended citation links (HTML or Markdown depending on `supportMarkdown`). Empty if status is not `SearchSuccess`.
* **searchResultList (List\<Map\<String, Object>>):** A list of search result objects used to generate the answer. Each entry contains: `id` (Number), `title` (String), `url` (String), and `snippet` (String — a short excerpt of the source content).

{% hint style="info" %}
Citation links are formatted as HTML by default. Set `supportMarkdown` to `true` if the delivery channel renders Markdown.
{% endhint %}

***

### Generate RAG Answer With Streaming

**Description:** Generates AI-powered answers using Retrieval Augmented Generation (RAG) by combining knowledge base content with language model capabilities. Supports both streaming (token-by-token) and non-streaming response modes.

**Configuration Parameters:** This action has no configuration parameters.

**Input:**

* **payload (String, Optional):** The request configuration as a JSON string containing the user query, filters, and RAG generation parameters. Used in non-streaming mode. The `tenantId` and `botId` fields are automatically populated from the execution context. – example: `{"query": "How do I reset my password?", "tenantId": "myTenant", "botId": "123"}`
* **botId (Long, Optional):** The bot ID to use for the RAG request. If not provided, the bot ID from the execution context is used.
* **query (String, Optional):** The user query to generate a RAG answer for. Required in streaming mode.
* **supportMarkdown (Boolean, Optional):** When `true`, responses and citation links are formatted using Markdown syntax. Defaults to `false`.

**Output:**

* **success (Boolean):** Indicates whether the RAG answer generation completed successfully without errors.
* **response (String):** The AI-generated answer with citations and references from the knowledge base. In streaming mode, delivered incrementally per line, followed by formatted citation links to the source documents.
* **mapResponse (Map\<String, Object>):** The structured RAG response including answer, sources, confidence scores, and metadata as key-value pairs.

{% hint style="info" %}
In non-streaming mode, use the `payload` input. In streaming mode, use the `query` input instead.
{% endhint %}
