Periodic scheduling
How to use meya.schedule
to trigger periodic flows.
Meya provides a manage periodic scheduler via a built-in flow called meya.schedule
. This allows your bot execute any flow
of your choice on a pre-defined schedule. You can either schedule using cron syntax or the more simple period syntax:
cron: 0 9 * * mon-fri
will execute at 9am, Monday to Fridayperiod: minutes, interval: 15
will execute every 15 minutes
states:
intro:
component: meya.text
properties:
text: "Great! I'll send you something nice every minute for the next hour (or until you say 'stop')"
start:
flow: meya.schedule
data:
tag: affirmation
flow: nice
period: minutes
interval: 1
max_count: 60
This affirmation example will trigger the nice
flow every minute for an hour
There are many ways to configure meya.schedule
.
Features
cron
orperiod
based scheduling- preventing duplicate flows from being invoked per user using
tag
- auto-restarting on failure
- allow the user to unsubscribe from existing schedules using
meya.schedule_stop
- limiting the total number of occurences
- rate limiting the executing loop, and terminating out of bounds schedules
- runs any flow that your bot has access to
- transparency and control on running schedules using the Meya platform tools
- pystache syntax for reading in data from your datastore
flow
,user
,bot
scope
flow: meya.schedule
data:
# [required]
flow: flow_name
# pass data to the flow
data: data needed for the flow
# cron schedule. either `cron` or `period` are required
cron: */5 * * * *
# one of seconds, minutes, hours, weeks, months, years
period: minutes
# applies to period. how often to run. default 1 [optional]
interval: 5
# for stopping and preventing dupes [optional]
tag: tag_name
# max number of loops [optional]
max_count: 100
# base time to calculate first run [optional] default `now`
base: 1465224764
# the timezone to apply for cron jobs [optional] default `UTC`
timezone: Canada/Eastern
# where to read the timezone [optional]. Ignored if timezone is set
timezone_scope: user
meya.schedule
is actually a built-in flow
that is made publicly available for all bot accounts. It's underlying architecture looks like this:
Tip!
If you want to use the same underlying delay component for more advanced delays that simple relative/absolute delay, you can use the
meya.delay
component that is used bymeya.schedule
Updated over 6 years ago