Reminder
ReminderFlow sends a reminder every interval until the recipient opts out. ReminderStep waits for either the interval Timer or the OptOut Channel. When the timer fires, it sends a reminder and moves to itself. When OptOut arrives first, the Step completes the Flow.
Core Step
class ReminderStep(Step[None]):
def __init__(self, service: ServiceDependency, opt_out: Channel[None]) -> None:
self.service = service
self.opt_out = opt_out
def wait_for(self, context: Context, input: None) -> Wait:
del context, input
return Wait.any_of(Timer.by_duration(REMINDER_INTERVAL), self.opt_out.for_one())
def execute(self, context: Context, input: None) -> StepDecision:
del input
if not context.has_timer_fired():
return graceful_complete()
self.service.send_email("Reminder: please respond", "Hello, ...")
return go_to(ReminderStep, None)
Example: examples/python/dex_examples/patterns/reminders/reminder_flow.py