mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
fix(messaging): parse postbackText from Gupshup list_reply, pass selection ID to AI
Gupshup list_reply has empty id field — postbackText carries our ID.
Fixed ?? to || fallback. Also inject selection_id into user message so
AI can extract doctorId from "doc:{uuid}:{name}" format.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -72,9 +72,15 @@ export class MessagingService {
|
||||
|
||||
// 3. Load conversation history
|
||||
const history = await this.conversation.getHistory(phone);
|
||||
// For interactive replies, include the selection ID so the AI can
|
||||
// extract structured data (e.g. "doc:{uuid}:{name}" → doctorId)
|
||||
let userContent = text;
|
||||
if (message.type === 'interactive_reply' && message.interactiveReply?.id) {
|
||||
userContent = `[Selected: ${message.interactiveReply.title}] (selection_id: ${message.interactiveReply.id})`;
|
||||
}
|
||||
const messages = [
|
||||
...history.map(h => ({ role: h.role as 'user' | 'assistant', content: h.content })),
|
||||
{ role: 'user' as const, content: text },
|
||||
{ role: 'user' as const, content: userContent },
|
||||
];
|
||||
|
||||
// 4. Build system prompt
|
||||
|
||||
Reference in New Issue
Block a user