Initial implementation of Telegram AI customer support bot
Cloudflare Workers + Hono + D1 + KV + R2 stack with 4 specialized AI agents (onboarding, troubleshoot, asset, billing), OpenAI function calling with 7 tool definitions, human escalation, pending action approval workflow, feedback collection, audit logging, i18n (ko/en), and Workers AI fallback. 43 source files, 45 tests passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
43
tests/tools/index.test.ts
Normal file
43
tests/tools/index.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { selectToolsForMessage, executeTool } from '../../src/tools/index';
|
||||
|
||||
describe('selectToolsForMessage', () => {
|
||||
it('returns knowledge tool for unknown/generic patterns', () => {
|
||||
const tools = selectToolsForMessage('안녕하세요');
|
||||
expect(tools).toHaveLength(1);
|
||||
expect(tools[0].function.name).toBe('search_knowledge');
|
||||
});
|
||||
|
||||
it('returns domain tool for domain-related messages', () => {
|
||||
const tools = selectToolsForMessage('도메인 등록하고 싶어요');
|
||||
const names = tools.map(t => t.function.name);
|
||||
expect(names).toContain('manage_domain');
|
||||
expect(names).toContain('search_knowledge');
|
||||
});
|
||||
|
||||
it('returns wallet tool for billing messages', () => {
|
||||
const tools = selectToolsForMessage('잔액 확인해주세요');
|
||||
const names = tools.map(t => t.function.name);
|
||||
expect(names).toContain('manage_wallet');
|
||||
expect(names).toContain('search_knowledge');
|
||||
});
|
||||
|
||||
it('returns server tool for server-related messages', () => {
|
||||
const tools = selectToolsForMessage('서버 목록 보여줘');
|
||||
const names = tools.map(t => t.function.name);
|
||||
expect(names).toContain('manage_server');
|
||||
});
|
||||
|
||||
it('returns security tools for DDoS/VPN messages', () => {
|
||||
const tools = selectToolsForMessage('DDoS 방어 서비스 현황');
|
||||
const names = tools.map(t => t.function.name);
|
||||
expect(names).toContain('check_service');
|
||||
});
|
||||
});
|
||||
|
||||
describe('executeTool', () => {
|
||||
it('returns error message for unknown tool name', async () => {
|
||||
const result = await executeTool('nonexistent_tool', {});
|
||||
expect(result).toContain('알 수 없는 도구');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user