Build a Customer Support Bot
Stop making customers wait hours for support. Build an AI-powered support bot that instantly answers questions using your documentation, tickets, and knowledge base.
The Problem with Traditional Support
Common Challenges
- Support agents spend 30+ mins searching docs per ticket
- Customers wait hours for basic answers
- Inconsistent responses across team members
- Knowledge base becomes outdated quickly
- High support costs as you scale
Our Solution
- Instant answers from your documentation
- 24/7 automated support coverage
- Consistent, accurate responses
- Always up-to-date with latest docs
- Support costs stay low as you scale
Real Results
How It Works
Connect Your Knowledge
Point us to your documentation, help center articles, and past support tickets. Our API processes everything and stores it securely in your infrastructure.
Build Your Bot
Create a chat interface that uses RAGaaS to find relevant information and OpenAI to generate helpful responses. We'll show you exactly how below.
Deploy & Scale
Embed the bot on your site or in your app. It automatically stays up-to-date as your docs change, and scales to handle any volume of requests.
Implementation Guide
1. Connect Your Knowledge Sources
First, let's index your support content. You can use any of these methods:
Uploading Content
// Set up your API key
const RAGAAS_API_KEY = process.env.RAGAAS_API_KEY
// Method 1: Upload text content (e.g., FAQs)
async function uploadFAQs() {
const response = await fetch('https://api.ragaas.dev/v1/ingest/text', {
method: 'POST',
headers: {
Authorization: `Bearer ${RAGAAS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
namespaceId: 'ns_123',
ingestConfig: {
source: 'TEXT',
config: {
text: 'Your FAQ content here...',
metadata: {
title: 'Product FAQs',
category: 'documentation',
},
},
chunkConfig: {
chunkSize: 1000,
chunkOverlap: 200,
},
},
}),
})
if (!response.ok) {
throw new Error('Failed to upload FAQs')
}
}
// Method 2: Upload files (e.g., PDF documentation)
async function uploadDocumentation() {
const formData = new FormData()
formData.append('namespaceId', 'ns_123')
formData.append('source', 'FILE')
formData.append('file', documentFile) // Your file object
formData.append(
'metadata',
JSON.stringify({
title: 'Product Documentation',
version: '1.0',
}),
)
const response = await fetch('https://api.ragaas.dev/v1/ingest/file', {
method: 'POST',
headers: {
Authorization: `Bearer ${RAGAAS_API_KEY}`,
},
body: formData,
})
if (!response.ok) {
throw new Error('Failed to upload documentation')
}
}
// Method 3: Scrape help center website
async function scrapeHelpCenter() {
const response = await fetch('https://api.ragaas.dev/v1/ingest/website', {
method: 'POST',
headers: {
Authorization: `Bearer ${RAGAAS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
namespaceId: 'ns_123',
ingestConfig: {
source: 'WEBSITE',
config: {
url: 'https://help.yourcompany.com',
maxDepth: 3,
maxLinks: 100,
includePaths: ['/docs', '/faq'],
excludePaths: ['/internal', '/admin'],
scrapeOptions: {
includeSelectors: ['.article-content', '.faq-content'],
excludeSelectors: ['.navigation', '.footer'],
},
metadata: {
source: 'help_center',
version: '1.0',
},
},
chunkConfig: {
chunkSize: 1000,
chunkOverlap: 200,
},
},
}),
})
if (!response.ok) {
throw new Error('Failed to scrape help center')
}
}
// Check ingestion status
async function checkIngestionStatus(jobId: string) {
const response = await fetch(
`https://api.ragaas.dev/v1/ingest-job-runs/${jobId}?namespaceId=ns_123`,
{
headers: {
Authorization: `Bearer ${RAGAAS_API_KEY}`,
},
},
)
if (!response.ok) {
throw new Error('Failed to check status')
}
const status = await response.json()
return status.data.status // QUEUED, PRE_PROCESSING, PROCESSING, COMPLETED
}
2. Create the Support Bot
Here's a complete example of a support bot that:
- Finds relevant documentation
- Maintains conversation context
- Formats responses professionally
- Includes source references
Support Bot Implementation
async function getSupportBotResponse(
question: string,
conversationHistory: Message[],
) {
// 1. Search documentation
const searchResponse = await fetch('https://api.ragaas.dev/v1/search', {
method: 'POST',
headers: {
Authorization: `Bearer ${RAGAAS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: question,
namespaceId: 'ns_123',
topK: 3,
filter: {
metadata: {
status: 'published',
rating: { $gte: 4 },
},
},
searchType: 'hybrid',
}),
})
if (!searchResponse.ok) {
throw new Error('Search failed')
}
const searchResults = await searchResponse.json()
// 2. Format conversation context
const context = searchResults.results
.map((result) => result.content)
.join('\n\n')
// 3. Generate response with OpenAI
const completion = await openai.chat.completions.create({
model: 'gpt-4',
messages: [
{
role: 'system',
content: `You are a helpful customer support agent.
Answer questions based on the provided documentation.
Be friendly and professional.
If you're not sure about something, say so.
Include relevant links when available.`,
},
// Include past messages for context
...conversationHistory,
{ role: 'user', content: question },
],
temperature: 0.7,
})
// 4. Return response with sources
return {
answer: completion.choices[0].message.content,
sources: searchResults.results.map((result) => ({
title: result.metadata.title,
url: result.metadata.url,
snippet: result.content.substring(0, 200),
})),
}
}
3. Add the Chat Interface
Here's a React component that implements the chat interface:
Chat Interface
function SupportChat() {
const [messages, setMessages] = useState<Message[]>([])
const [loading, setLoading] = useState(false)
async function handleUserMessage(message: string) {
setLoading(true)
try {
const response = await getSupportBotResponse(message, messages)
setMessages((prev) => [
...prev,
{ role: 'user', content: message },
{
role: 'assistant',
content: response.answer,
sources: response.sources,
},
])
} catch (error) {
console.error('Error:', error)
setMessages((prev) => [
...prev,
{ role: 'user', content: message },
{
role: 'assistant',
content:
'Sorry, I encountered an error. Please try again or contact human support.',
},
])
}
setLoading(false)
}
return (
<div className="support-chat">
<div className="messages">
{messages.map((msg, i) => (
<Message key={i} {...msg} />
))}
</div>
<MessageInput onSubmit={handleUserMessage} disabled={loading} />
</div>
)
}
Best Practices
Search Configuration
Search Configuration
const searchConfig = {
// Retrieve fewer, high-quality results
topK: 3,
scoreThreshold: 0.7,
// Prioritize recent content
filter: {
metadata: {
created_at: { $gte: '2024-01-01' },
status: 'published',
},
},
// Use hybrid search for better results
searchType: 'hybrid',
}
Prompt Engineering
Make your bot more helpful with these prompt improvements:
Prompt Engineering
const systemPrompt = `You are a helpful customer support agent for our company. Follow these guidelines:
1. Be friendly and professional
2. Use the provided documentation to answer questions
3. If you're not sure, say so and offer to escalate
4. Include relevant links when available
5. Keep responses concise but complete
6. Format responses for readability
7. Acknowledge the customer's issue
Context from our documentation:
${context}`
Error Handling
Implement graceful fallbacks:
Error Handling
try {
const searchResults = await ragaas.search({
query: userQuestion,
...searchConfig,
})
if (searchResults.results.length === 0) {
return {
answer:
"I couldn't find specific information about that. Would you like me to connect you with a human support agent?",
shouldEscalate: true,
}
}
// Continue with normal flow...
} catch (error) {
console.error('Search error:', error)
return {
answer:
"I'm having trouble accessing our knowledge base. Let me connect you with a human agent who can help.",
shouldEscalate: true,
}
}
Next Steps
-
Start Small
- Begin with a focused set of documentation
- Test with common support questions
- Gather feedback from support team
-
Optimize
- Fine-tune search parameters
- Improve prompts based on interactions
- Add custom metadata for better filtering
-
Scale
- Add more knowledge sources
- Implement user feedback collection
- Set up analytics to track effectiveness
-
Advanced Features
- Add ticket creation for escalations
- Implement user authentication
- Add support for attachments and images
Ready to reduce support costs and response times? Get started with RAGaaS today.