ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Build Customer Support Knowledge Search
Tutorial

How to Build Customer Support Knowledge Search

Build a knowledge search layer for customer support that queries your docs site and the open web to answer support tickets. Python and JS examples.

Get Free API KeyAPI Docs

Build a customer support knowledge search layer that combines queries against your own documentation site with open web search to find answers for support tickets. When a customer asks a question, the system first searches your docs using a site-scoped query, then falls back to general web search if no relevant docs are found. This two-tier approach ensures accurate answers from official sources while still handling edge cases and third-party integration questions. Scavio's API makes both tiers a single endpoint call with different query formats.

Prerequisites

  • Python 3.8+ or Node.js 18+ installed
  • requests library (Python) or built-in fetch (JS)
  • A Scavio API key from scavio.dev
  • Your product's documentation URL (e.g., docs.yourproduct.com)

Walkthrough

Step 1: Configure the two-tier search

Set up the docs-first search strategy with your documentation domain and a fallback to general web search.

Python
import os, requests

API_KEY = os.environ['SCAVIO_API_KEY']
DOCS_DOMAIN = 'docs.yourproduct.com'

def search_docs(query: str) -> list:
    resp = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY},
        json={'platform': 'google', 'query': f'{query} site:{DOCS_DOMAIN}'}, timeout=10)
    return resp.json().get('organic_results', [])

def search_web(query: str) -> list:
    resp = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY},
        json={'platform': 'google', 'query': query}, timeout=10)
    return resp.json().get('organic_results', [])

Step 2: Build the tiered search function

Try docs first; if no results or insufficient results, fall back to web search. Tag results with their source.

Python
def knowledge_search(query: str, min_docs: int = 1) -> dict:
    docs_results = search_docs(query)
    if len(docs_results) >= min_docs:
        return {
            'source': 'docs',
            'results': [{'title': r['title'], 'url': r['link'], 'snippet': r.get('snippet', '')} for r in docs_results[:3]]
        }
    web_results = search_web(query)
    return {
        'source': 'web',
        'results': [{'title': r['title'], 'url': r['link'], 'snippet': r.get('snippet', '')} for r in web_results[:3]]
    }

Step 3: Format results for the support agent

Convert search results into a context block that the support agent can use to draft a response.

Python
def format_support_context(search_result: dict) -> str:
    source_label = 'Official docs' if search_result['source'] == 'docs' else 'Web search'
    lines = [f'Source: {source_label}', '']
    for r in search_result['results']:
        lines.append(f"- {r['title']}")
        lines.append(f"  {r['snippet']}")
        lines.append(f"  URL: {r['url']}")
        lines.append('')
    return '\n'.join(lines)

result = knowledge_search('how to set up webhooks')
print(format_support_context(result))

Step 4: Handle ticket batches

Process multiple support tickets in batch, running the knowledge search for each and collecting the results.

Python
def process_tickets(tickets: list) -> list:
    responses = []
    for ticket in tickets:
        search_result = knowledge_search(ticket['question'])
        context = format_support_context(search_result)
        responses.append({
            'ticket_id': ticket['id'],
            'question': ticket['question'],
            'source': search_result['source'],
            'context': context,
        })
        print(f"Ticket {ticket['id']}: answered from {search_result['source']}")
    return responses

tickets = [
    {'id': '001', 'question': 'how to set up webhooks'},
    {'id': '002', 'question': 'SAML SSO configuration'},
    {'id': '003', 'question': 'error 429 rate limit exceeded'},
]
process_tickets(tickets)

Python Example

Python
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}

def knowledge_search(query, docs_domain):
    docs = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': 'google', 'query': f'{query} site:{docs_domain}'}).json()
    results = docs.get('organic_results', [])
    if results:
        return {'source': 'docs', 'results': results[:3]}
    web = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': 'google', 'query': query}).json()
    return {'source': 'web', 'results': web.get('organic_results', [])[:3]}

print(knowledge_search('webhook setup', 'docs.example.com'))

JavaScript Example

JavaScript
const H = {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'};
async function knowledgeSearch(query, docsDomain) {
  let r = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST', headers: H,
    body: JSON.stringify({platform: 'google', query: `${query} site:${docsDomain}`})
  });
  let results = (await r.json()).organic_results || [];
  if (results.length) return {source: 'docs', results: results.slice(0, 3)};
  r = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST', headers: H, body: JSON.stringify({platform: 'google', query})
  });
  results = (await r.json()).organic_results || [];
  return {source: 'web', results: results.slice(0, 3)};
}
knowledgeSearch('webhook setup', 'docs.example.com').then(console.log);

Expected Output

JSON
A two-tier knowledge search that returns official docs results when available and falls back to web search, formatted as context blocks for support agents.

Related Tutorials

  • How to Ground a Support Bot with Live Search
  • How to Add Live Search to a Support Agent

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.8+ or Node.js 18+ installed. requests library (Python) or built-in fetch (JS). A Scavio API key from scavio.dev. Your product's documentation URL (e.g., docs.yourproduct.com). A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Related Resources

Best Of

Best APIs for Agent Memory Search Grounding (2026)

Read more
Best Of

Best Search API for Customer Support Bots in 2026

Read more
Use Case

Customer Support Agent Grounded in Search

Read more
Workflow

Daily Personal Knowledge Base Update with Search

Read more
Glossary

Search API Provider Landscape (2026)

Read more
Use Case

Support Agent Knowledge Search

Read more

Start Building

Build a knowledge search layer for customer support that queries your docs site and the open web to answer support tickets. Python and JS examples.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy