Interactive Notifications

View as Markdown

Deliver pending notifications to callers and collect interactive responses, with database tracking of acknowledgments and follow-ups.

Overview

This use case demonstrates:

  • Delivering pending notifications to callers
  • Interactive voice response via AI
  • Database acknowledgment tracking
  • Follow-up flagging for unconfirmed items

State flow: PENDING -> ANSWERED -> DISCONNECTED

Example

1@client.on(events.INCOMING_CALL)
2async def interactive_notification(call: ActiveCall):
3 await call.answer()
4
5 customer = await db.get_customer_by_phone(call.caller_number)
6 pending_notifications = await db.get_pending_notifications(customer.id)
7
8 for notification in pending_notifications:
9 await call.send_audio(
10 await tts.synthesize(notification.message)
11 )
12
13 # AI listens for confirmation/response
14 response = await ai_model.get_caller_response(call)
15
16 if response.confirmed:
17 await db.mark_notification_acknowledged(notification.id)
18 await call.send_audio(
19 await tts.synthesize("Got it, that's been confirmed.")
20 )
21 else:
22 await db.flag_for_followup(notification.id)
23 await call.send_audio(
24 await tts.synthesize(
25 "No problem, someone from our team will follow up."
26 )
27 )
28
29 await call.send_audio(
30 await tts.synthesize("That's everything. Have a great day!")
31 )
32 await call.disconnect()

How It Works

  1. When the caller calls in, the AI answers and identifies the customer by phone number
  2. It retrieves all pending notifications from the database for that customer
  3. For each notification, the AI:
    • Reads the notification message aloud
    • Listens for the caller’s response using AI comprehension
    • If confirmed: marks the notification as acknowledged in the database
    • If not confirmed: flags it for follow-up by a human team member
  4. After all notifications are delivered, the AI signs off and ends the call

Key Commands Used