Deal with session expire

Hello, everyone, I want to send a message to user and close the socket connect when after a user was inactive for a period defined by the session_expiration_time, how to do this?

You can use the ReminderScheduled() event and read session_expiration_time from the domain variable inside Custom Actions.

Thanks for you reply, can you show me a demo or tutorial. I haven’t found any tutorial about events.

Sure, here’s one :slight_smile:

rasa_sdk.events.ReminderScheduled(
    intent_name: Text, # Intent which the reminder will trigger
    trigger_date_time: datetime.datetime, # Datetime at which the execution of the action should be triggered.
    entities: Optional[Union[List[Dict[Text, Any]], Dict[Text, Text]]] = None, # Entities to send with the intent
    name: Optional[Text] = None, # ID of the reminder. If there are multiple reminders with the same id only the last will be run.
    kill_on_user_message: bool = True, # Whether a user message before the trigger time will abort the reminder
    timestamp: Optional[float] = None # Optional timestamp of the event
)

You just need to put the same reminder in all actions (read the name argument).

Ok, thanks, I have just got it. I want to send a ReminderScheduled event every time when the form is requesting a slot. And when I receive the reminder, I will send a message. So how to detect the requesting? I know extract_slot_name can do this, but only custom slot mapping has this function, and it is not a good idea.

No, that’s not for forms, it’s for custom actions

At last, I start a ReminderSchedule in every custom AskSlotAction, not a gentle but works.