Handle patient replies
When a patient answers a reminder with “C”, you can confirm the appointment in your EMR automatically and let staff see it was handled. This guide wires a webhook to that action.
You’ll need: an app user with messages:read and reactions:write, a webhook endpoint subscribed to conversation.message.created, and the reminder job from Send appointment reminders.
Receive and verify the event
Start from the verified receiver. Acknowledge fast and queue the event.
Fetch the message
The event carries IDs only, so read the latest messages to get the text:
curl "https://api.bloomtext.com/v1/conversations/e5c3b7b8-8f08-4d5a-9af1-0d11b0f4b7a0/messages?page[limit]=5" \
-H "Authorization: Bearer $BLOOMTEXT_API_KEY"Match the reply and act
JavaScript
const API = 'https://api.bloomtext.com/v1'
const headers = { Authorization: `Bearer ${process.env.BLOOMTEXT_API_KEY}` }
export async function handleReply(event, { findPendingReminder, confirmInEmr, alreadyProcessed }) {
if (await alreadyProcessed(event.id)) return // webhooks can repeat
const { conversation_id, message_id, sender_id } = event.payload
if (sender_id === process.env.BLOOMTEXT_APP_USER_ID) return
const { data } = await fetch(`${API}/conversations/${conversation_id}/messages?page[limit]=5`, { headers })
.then((r) => r.json())
const message = data.find((m) => m.id === message_id)
const answer = message?.body?.trim().toUpperCase()
const reminder = await findPendingReminder(conversation_id)
if (!reminder || answer !== 'C') return // anything else is for staff
await confirmInEmr(reminder.appointmentId)
await fetch(`${API}/messages/${message_id}/reactions`, {
method: 'POST',
headers: { ...headers, 'Idempotency-Key': `confirm:${message_id}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ emoji: '👍' }),
})
}Let staff see what happened
The 👍 reaction shows staff the reply was handled automatically. Anything you don’t recognize stays unreacted, so it stands out for a person to answer.
Keep the matching strict. “C” confirms; “can I come at 4 instead?” doesn’t. When in doubt, leave it for staff.