This commit is contained in:
Ravi Gulhane 2026-07-03 16:57:07 +05:30
commit 980e0d9156
4 changed files with 74 additions and 5 deletions

View File

@ -14,7 +14,7 @@ function builderIframeSrc(): string {
}
function apiBaseUrlForChild(): string {
const base = import.meta.env.VITE_API_URL || "http://localhost:3001/api";
const base = import.meta.env.VITE_API_URL || "http://localhost:3002/api";
return normalizeBaseUrl(base);
}

View File

@ -141,7 +141,11 @@ export function WhatsAppChatbotsPage() {
greeting: bot.greeting,
registration: bot.registration,
knowledge: bot.knowledge
? { includeEventDetails: bot.knowledge.includeEventDetails }
? {
includeEventDetails: bot.knowledge.includeEventDetails,
includeFoodRecommendations: bot.knowledge.includeFoodRecommendations,
includePlacesRecommendations: bot.knowledge.includePlacesRecommendations,
}
: undefined,
});
if (res.error) {
@ -211,6 +215,20 @@ export function WhatsAppChatbotsPage() {
await loadBot(bot._id);
};
const handleSyncFood = async () => {
if (!bot) return;
await conciergeBotsApi.syncFoodKnowledge(bot._id);
setMsg("Food recommendations sync queued");
await loadBot(bot._id);
};
const handleSyncPlaces = async () => {
if (!bot) return;
await conciergeBotsApi.syncPlacesKnowledge(bot._id);
setMsg("Places recommendations sync queued");
await loadBot(bot._id);
};
const handleAddUrl = async () => {
if (!bot || !urlInput || !urlName) return;
await conciergeBotsApi.createSource(bot._id, {
@ -230,7 +248,7 @@ export function WhatsAppChatbotsPage() {
const up = await uploadMediaFile(file, {
eventId: eid,
module: "concierge",
name: file.name,
//name: file.name,
});
const key = up.s3Key;
if (!key) {
@ -422,6 +440,33 @@ export function WhatsAppChatbotsPage() {
/>
Include event programme in knowledge base
</label>
<label style={{ display: "flex", alignItems: "center", gap: 8 }}>
<input
type="checkbox"
checked={bot.knowledge?.includeFoodRecommendations !== false}
onChange={(e) =>
setBot({
...bot,
knowledge: { ...bot.knowledge, includeFoodRecommendations: e.target.checked },
})
}
/>
Include food recommendations in knowledge base
</label>
<label style={{ display: "flex", alignItems: "center", gap: 8 }}>
<input
type="checkbox"
checked={bot.knowledge?.includePlacesRecommendations !== false}
onChange={(e) =>
setBot({
...bot,
knowledge: { ...bot.knowledge, includePlacesRecommendations: e.target.checked },
})
}
/>
Include tourist places recommendations in knowledge base
</label>
<div style={{ display: "flex", flexWrap: "wrap", gap: 8 }}>
<button type="button" style={btnPrimary} onClick={saveSettings}>
Save settings
@ -429,6 +474,12 @@ export function WhatsAppChatbotsPage() {
<button type="button" style={btnSecondary} onClick={handleSyncEvent}>
<RefreshCw size={14} /> Sync event programme
</button>
<button type="button" style={btnSecondary} onClick={handleSyncFood}>
<RefreshCw size={14} /> Sync food recommendations
</button>
<button type="button" style={btnSecondary} onClick={handleSyncPlaces}>
<RefreshCw size={14} /> Sync places recommendations
</button>
<button type="button" style={{ ...btnSecondary, color: "var(--destructive)" }} onClick={handleClearKnowledge}>
<Trash2 size={14} /> Clear all knowledge
</button>

View File

@ -16,7 +16,7 @@ import {
export type { ApiRequestInit };
export const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001/api';
export const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3002/api';
const BASE_URL = API_BASE_URL;
const STORAGE_KEYS = {

View File

@ -14,7 +14,11 @@ export interface ConciergeBotRegistration {
export interface ConciergeBotKnowledge {
includeEventDetails?: boolean;
includeFoodRecommendations?: boolean;
includePlacesRecommendations?: boolean;
lastEventSnapshotAt?: string;
lastFoodSnapshotAt?: string;
lastPlacesSnapshotAt?: string;
}
export interface ConciergeBotRecord {
@ -45,7 +49,7 @@ export interface KnowledgeSourceCrawlStats {
export interface KnowledgeSourceRecord {
_id: string;
eventId: string;
type: 'url' | 'pdf' | 'event';
type: 'url' | 'pdf' | 'event' | 'food' | 'places';
sourcePath: string;
displayName: string;
status: 'PENDING' | 'PROCESSING' | 'READY' | 'FAILED';
@ -63,6 +67,12 @@ export interface ContextChunkRecord {
sourceId: string;
}
export interface Event {
_id: string;
name?: string;
[k: string]: any;
}
export const conciergeBotsApi = {
list(params?: { organization?: string }) {
const sp = new URLSearchParams();
@ -162,4 +172,12 @@ export const conciergeBotsApi = {
syncEventKnowledge(botId: string) {
return api.post<KnowledgeSourceRecord>(`/concierge-bots/${botId}/knowledge/sync-event`, {});
},
syncFoodKnowledge(botId: string) {
return api.post<KnowledgeSourceRecord>(`/concierge-bots/${botId}/knowledge/food-sync`, {});
},
syncPlacesKnowledge(botId: string) {
return api.post<KnowledgeSourceRecord>(`/concierge-bots/${botId}/knowledge/places-sync`, {});
},
};