Version: Latest

Handling User Silence

This guide outlines a conversational flow for a chatbot that provides information about its capabilities and uses reminders to handle user inactivity.

How to Handle Unresponsive Users with Reminders

Your assistant may need to handle situations where users don't respond to prompts. This guide shows you how to use reminders to re-prompt users after periods of inactivity.

Implement the reminder logic using action_set_reminder

  • Create two custom actions named action_set_reminder and action_forget_reminders as shown below
  • Customize the minutes parameter to determine the desired delay for the reminder.
  • You are required to import the ReminderScheduled class with the following parameters:
    • "EXTERNAL_reminder": This is the required identifier for the reminder type.
    • trigger_date_time: The scheduled time for the notification (set to the calculated date).
    • "reminder": The name of the reminder (can be customized).
    • kill_on_user_message=True: This ensures the reminder is reset when the user utters a message.
actions.py
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
import datetime
from rasa_sdk.events import ReminderScheduled, ReminderCancelled
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
class ActionSetReminder(Action):
"""Schedules a reminder"""
def name(self) -> Text:
return "action_set_reminder"
async def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict[Text, Any]]:
# set a timer for 30 seconds:
date = datetime.datetime.now() + datetime.timedelta(minutes=0.5)
# Required: pass params to Reminder Object. For more info visit:
# https://rasa.com/docs/rasa-pro/nlu-based-assistants/reaching-out-to-user#reminders
reminder = ReminderScheduled(
"EXTERNAL_reminder",
trigger_date_time=date,
name="reminder",
kill_on_user_message=True,
)
return [reminder]
class ForgetReminders(Action):
"""Cancels all reminders."""
def name(self) -> Text:
return "action_forget_reminders"
async def run(
self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]
) -> List[Dict[Text, Any]]:
# Cancel all reminders
return [ReminderCancelled()]

Update the pattern_collect_information flow

Overwrite the default pattern_collect_information pattern. This will enable the reminder logic for any collect.

patterns.yml
flows:
pattern_collect_information:
description: Flow for collecting information from users
name: pattern collect information
steps:
- id: "top"
action: action_forget_reminders # clear any previously scheduled reminders
- action: action_run_slot_rejections # check if the requested slot was already set
- action: validate_{{context.collect}}
- action: action_set_reminder # schedule a new reminder
- action: "{{context.utter}}"
- action: "{{context.collect_action}}" # ask user for the required slot
- action: action_listen # listen for next user response
next: top

Best Practices

  • Customize reminder messages and timeouts based on your use case and user experience goals.
  • Consider using different reminder messages for subsequent reminders to avoid repetition.
  • Implement a maximum number of retries to prevent excessive interruptions.
  • Inspect and test your implementation thoroughly to ensure it behaves as expected.

Conclusion

By following these steps and incorporating best practices, you can effectively handle user inactivity and improve the overall user experience of your assistant. The reminder system, implemented within the action_set_reminder and the pattern_collect_information flow, plays a crucial role. It nudges unresponsive users without being overly intrusive. This feature allows the assistant to be informative and helpful while respecting the user's time and attention.