mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
Provider-agnostic WhatsApp integration for AI-driven appointment booking: - MessagingProvider interface (sendText, sendButtons, sendList, parseInbound) - GupshupProvider implementation (Gupshup WhatsApp API) - MessagingService — AI orchestration with tools (department/doctor/slot lists via interactive WhatsApp messages, appointment booking, caller resolution + context injection) - Redis conversation history (24h TTL, matches WhatsApp session window) - Webhook controller at POST /api/messaging/webhook Swappable to Ozonetel or Meta Cloud API by implementing MessagingProvider and switching MESSAGING_PROVIDER env var. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
917 B
TypeScript
28 lines
917 B
TypeScript
export type NormalizedMessage = {
|
|
phone: string; // E.164 without +, e.g. "919949879837"
|
|
name: string; // sender name from WhatsApp profile
|
|
text: string; // message text (or button reply title)
|
|
type: 'text' | 'interactive_reply' | 'location' | 'image' | 'unknown';
|
|
interactiveReply?: { // populated when user taps a button or list item
|
|
id: string; // button/row ID set by us
|
|
title: string; // display text
|
|
};
|
|
rawPayload: any; // original provider payload for debugging
|
|
};
|
|
|
|
export type ConversationEntry = {
|
|
role: 'user' | 'assistant';
|
|
content: string;
|
|
timestamp: number;
|
|
};
|
|
|
|
export type InteractiveButton = {
|
|
id: string;
|
|
title: string; // max 20 chars for WhatsApp
|
|
};
|
|
|
|
export type ListSection = {
|
|
title: string;
|
|
rows: { id: string; title: string; description?: string }[];
|
|
};
|