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 { 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); return normalizeBaseUrl(base);
} }

View File

@ -141,7 +141,11 @@ export function WhatsAppChatbotsPage() {
greeting: bot.greeting, greeting: bot.greeting,
registration: bot.registration, registration: bot.registration,
knowledge: bot.knowledge knowledge: bot.knowledge
? { includeEventDetails: bot.knowledge.includeEventDetails } ? {
includeEventDetails: bot.knowledge.includeEventDetails,
includeFoodRecommendations: bot.knowledge.includeFoodRecommendations,
includePlacesRecommendations: bot.knowledge.includePlacesRecommendations,
}
: undefined, : undefined,
}); });
if (res.error) { if (res.error) {
@ -211,6 +215,20 @@ export function WhatsAppChatbotsPage() {
await loadBot(bot._id); 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 () => { const handleAddUrl = async () => {
if (!bot || !urlInput || !urlName) return; if (!bot || !urlInput || !urlName) return;
await conciergeBotsApi.createSource(bot._id, { await conciergeBotsApi.createSource(bot._id, {
@ -230,7 +248,7 @@ export function WhatsAppChatbotsPage() {
const up = await uploadMediaFile(file, { const up = await uploadMediaFile(file, {
eventId: eid, eventId: eid,
module: "concierge", module: "concierge",
name: file.name, //name: file.name,
}); });
const key = up.s3Key; const key = up.s3Key;
if (!key) { if (!key) {
@ -422,6 +440,33 @@ export function WhatsAppChatbotsPage() {
/> />
Include event programme in knowledge base Include event programme in knowledge base
</label> </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 }}> <div style={{ display: "flex", flexWrap: "wrap", gap: 8 }}>
<button type="button" style={btnPrimary} onClick={saveSettings}> <button type="button" style={btnPrimary} onClick={saveSettings}>
Save settings Save settings
@ -429,6 +474,12 @@ export function WhatsAppChatbotsPage() {
<button type="button" style={btnSecondary} onClick={handleSyncEvent}> <button type="button" style={btnSecondary} onClick={handleSyncEvent}>
<RefreshCw size={14} /> Sync event programme <RefreshCw size={14} /> Sync event programme
</button> </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}> <button type="button" style={{ ...btnSecondary, color: "var(--destructive)" }} onClick={handleClearKnowledge}>
<Trash2 size={14} /> Clear all knowledge <Trash2 size={14} /> Clear all knowledge
</button> </button>

View File

@ -16,7 +16,7 @@ import {
export type { ApiRequestInit }; 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 BASE_URL = API_BASE_URL;
const STORAGE_KEYS = { const STORAGE_KEYS = {

View File

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