AI Customer Support Agent with Knowledge Base and API Enrichment

This AI-powered workflow automates customer support by combining internal knowledge base search, Google Docs knowledge retrieval, API integration, and advanced language model reasoning. The agent responds in Slovak or the customer’s language, always provides up-to-date information, and can escalate to human support if needed. Ideal for companies seeking multilingual, automated, and context-aware customer service.

How the AI Flow works - AI Customer Support Agent with Knowledge Base and API Enrichment

How the AI Flow works

Receive Customer Query

The flow captures customer queries from chat input and retrieves recent chat history for context.

Gather Knowledge from Internal and External Sources

The workflow searches both internal document repositories and connected Google Docs for relevant knowledge base information using document retrievers.

Enrich and Analyze Data via API

Customer message IDs are used to call external APIs, retrieve message histories, and parse necessary information for context enrichment.

AI Agent Answers and Multilingual Generation

An advanced AI agent uses the gathered context, knowledge sources, and language models to generate responses in Slovak or the customer's language, ensuring professional, concise, and accurate answers.

Respond to Customer and Escalate if Needed

The agent delivers the response to the customer, including relevant links and information, and escalates to human support if the query cannot be resolved automatically.

Prompts used in this flow

Below is a complete list of all prompts used in this flow to achieve its functionality. Prompts are the instructions given to the AI model to generate responses or perform actions. They guide the AI in understanding user intent and generating relevant outputs.

Tool Calling Agent (ToolCallingAgent-K7dur)

A tool calling agent.

                You are an AI language model assistant acting as a friendly and professional customer support and shopping assistant for YOURCOMPANY. You respond in Slovak language by default, or in the customer's input language if detected to be different than Slovak. AND ALWAYS USE EMAIL TONE AND FORMAT.

<u>Your role:</u>

You combine the responsibilities of technical customer support and product recommendation assistant. You help customers solve issues, make decisions, and complete purchases related to YOURCOMPANY products and services. Your tone is always friendly and professional, and your goal is to ensure the customer feels understood, supported, and confident in their next step.

<u>Your Goal:</u>

you receive CONVERSATION HISTORY and the most recent user query as LATEST MESSAGE your goal is to answer the LATEST MESSAGE based on the tools at your disposal.&#x20;

<u>Identify intent and provide answers:</u>

First source: ALWAYS SEARCH THE knowledge_source_tool TO ANSWER USER'S QUESTION AND NEVER ANSWER FROM YOURSELF.

Second source: Always use the Document Retriever tool to find context related to the question.

If relevant context is found:

Use it to provide accurate, concise answers.

Include ONLY RELEVANT URLs retrieved from the Document Retriever, never edit the url.

Never invent product names and category names. You can recognize a category by the fact that the page MUST contain a list of different products.; use only those available in your knowledge base.

Follow the information exactly as stated in the reference.

If no relevant context is found and the question is about YOURCOMPANY:

Ask polite clarifying questions to gather more details.

If still unresolved, use the Contact Human Assist tool to transfer to a human support agent.

If the customer’s message is unclear or incomplete:

Do not guess — always ask for more information before answering.

If the customer shows interest in a specific product:

Let them know that pricing and ordering is quick and simple directly on the website.

They can configure the product (dimensions, extras, quantity…) and see the price immediately and the production time.

If the question is about production time, always include express options if available.

For inquiries not related to YOURCOMPANY:

Politely inform the customer that you only provide support for YOURCOMPANY.

Suggest contacting the appropriate business support team at CONTACT METHOD

<u>Resource Utilization:</u>

Use the Document Retriever to search for knowledge relevant to the customer question.

Use the Contact Human Assist tool to escalate if needed.

Use the Document Retriever to provide valid product or info links - NEVER invent or assume URLs

<u>Formatting:</u>

Your tone is always friendly, clear, and professional.

The answers should be SHORT - max. about 100-200 tokens.

Use structured formatting:

Short paragraphs

Bold text for emphasis

Bullet points where appropriate

Emojis to make the messages more engaging 😊

Write in plain text format. Do not use markdown.

            

Components used in this flow

Below is a complete list of all components used in this flow to achieve its functionality. Components are the building blocks of every AI Flow. They allow you to create complex interactions and automate tasks by connecting various functionalities. Each component serves a specific purpose, such as handling user input, processing data, or integrating with external services.

Flow description

Purpose and benefits

Overview

This workflow automates the process of retrieving customer messages from a ticketing or support system, extracting the latest relevant message, enhancing it with context and chat history, and then leveraging advanced AI (LLMs) combined with knowledge tools to generate professional, multilingual customer support responses. The process then prepares and sends these responses back to external systems, making it ideal for scaling and automating customer support, knowledge retrieval, and external API integration.


Step-by-Step Breakdown

1. Input Acquisition and Preparation

  • Chat Input: The workflow can receive incoming chat messages directly.
  • Prompt Creation for API: The system uses a prompt template to dynamically construct the URL for fetching ticket messages from an external API (e.g., https://arshiakahani.ladesk.com/api/v3/tickets/{input}/messages). This enables flexible retrieval based on incoming user data.
  • Query Parameter Construction: A data creation node is used to dynamically build the necessary query parameters for the API request.

2. External Data Retrieval

  • API Request: Using the constructed URL and query parameters, the workflow sends a GET request to fetch the ticket’s message history from an external ticketing system. API key authentication is supported via headers.
  • Parsing Fetched Data: Once the API returns data, a parser node structures and converts this data into plain text using templates, making it suitable for downstream AI processing.

3. Message Extraction and Preprocessing

  • LLM-based Extraction: An OpenAI LLM (e.g., GPT-4.1) is used with a system prompt to extract only the latest user message from the ticket’s data (specifically messages of type “M”)—ensuring only relevant content is processed further.
  • Prompt Enrichment: The extracted message and chat context are inserted into a sophisticated prompt template that includes conversation history and latest message segmentation, preparing the input for the main support agent.

4. Knowledge Augmentation

  • Chat History: The system can look up the last N messages in the conversation to provide continuity and richer context.
  • Document Retrieval: A document retriever tool searches internal/external knowledge bases (optionally including Google Docs) for relevant information to answer the customer’s query. This is essential for grounding responses in up-to-date and accurate knowledge.
  • Tool Integration: Both the document retriever and Google Docs retriever are registered as “tools” available to the agent, enabling dynamic lookup during response generation.

5. Agent-driven Response Generation

  • Tool Calling Agent: At the core is a Tool Calling Agent (powered by an LLM), which receives the enriched prompt, chat history, and access to knowledge tools. Its role is to determine user intent, search the knowledge base/tools for answers, and compose a concise, friendly, and professional response.
    • The agent always responds in Slovak by default or switches to the customer’s language if detected.
    • Structured formatting is enforced: short paragraphs, bold for emphasis, bullet points, and emojis for engagement.
    • The agent prioritizes using retrieved knowledge, never invents facts or URLs, asks for clarification if needed, and escalates unresolved issues to human agents.
    • All responses adhere to customer support tone and structure, suitable for email communication.

6. Post-processing and Output

  • Response Formatting: The agent’s response is further processed through prompt templates to construct multilingual output (e.g., including both Slovak and customer’s original language).
  • LLM Generation: Another LLM node can generate or translate portions of the output as needed.
  • API Integration for Outbound Messages: The workflow dynamically builds data objects for outbound API requests, packages the generated response, and sends it (typically via POST) to the relevant external system.
  • Parsing and Final Output: Outbound API responses can be parsed and displayed in the chat playground or sent back to the user interface.

Key Components & Their Purpose

ComponentPurpose
Chat InputAccepts user/customer messages
Prompt TemplateDynamically builds URLs and message prompts
API RequestFetches ticket data/messages from external system
Parse DataConverts structured data into plain text
OpenAI LLMExtracts relevant messages, generates or translates responses
Document RetrieverSearches knowledge base for relevant info
Google Docs RetrieverIntegrates external docs as knowledge for the agent
Tool Calling AgentCentral AI support agent—uses tools and chat history
Create DataPackages responses and data for outbound API requests
Chat OutputDisplays the final result to end-user or system
NotesProvide operator guidance (e.g., where to input API keys/URLs)

Use Cases & Benefits

  • Automated Customer Support: Streamlines the process of extracting, augmenting, and responding to customer inquiries with professional, accurate, and context-aware answers.
  • Multilingual Support: Automatically detects and responds in the customer’s language, with translation and formatting handled by the workflow.
  • Scalable Knowledge Management: Integrates multiple knowledge sources (internal documents, Google Docs, etc.) for comprehensive and up-to-date answers.
  • Seamless External System Integration: Easily connects to various APIs for both inbound (fetching messages) and outbound (posting responses) actions.
  • Human-in-the-loop Escalation: Automatically hands off unresolved or unclear cases to human agents, ensuring high-quality support.

Why This Workflow is Useful for Scaling & Automation

  • Reduces Manual Work: By automating data retrieval, message extraction, context building, and response generation, it minimizes the need for human intervention for routine support queries.
  • Consistency & Quality: Ensures all customer communications adhere to company tone, format, and information accuracy, regardless of agent or shift.
  • Rapid Adaptation: Easily connects to new data sources or APIs, adapts to new languages, and can scale to handle higher support volumes with little extra configuration.
  • Improved Customer Satisfaction: Fast, relevant, and friendly responses—tailored to each customer’s language and query—lead to better experiences and loyalty.

Visual Flow (Simplified)

Below is a simplified flowchart representation of the main steps:

  1. Chat Input / API Query
  2. Fetch Ticket Messages (API Request)
  3. Parse Data
  4. Extract Latest User Message (LLM)
  5. Enrich Prompt with Context & History
  6. Retrieve Knowledge (Document/Google Docs Retriever)
  7. Tool Calling Agent (LLM) Generates Response
  8. Format/Translate/Send Response (API Request)
  9. Display/Deliver Output

This workflow is a robust foundation for any organization looking to automate and scale customer support, technical assistance, or information delivery workflows that require integration with external APIs, knowledge bases, and advanced AI responses.

Let us build your own AI Team

We help companies like yours to develop smart chatbots, MCP Servers, AI tools or other types of AI automation to replace human in repetitive tasks in your organization.