Schedule Sessions with Customized Timing for Each Participant
Avicenna's triggering logics already cover most use cases, but surely there will be cases where you want to prompt surveys on certain schedules, and none of our triggering logics fit. For full flexibility, we offer the following:
- Release an activity to instantly deliver it to participants (for example, when immediate action is required).
- Schedule individual sessions through the calendar interface.
- Upload a CSV file containing the list of sessions, to create multiple sessions at once.
In this article, we'll focus on the third approach.
The Situation
The participant pool includes those scheduled for a surgery. Each participant's surgery date will be different. You want to prompt them with a survey on a daily basis at 9 o'clock for 10 days following their surgery.
What to Do?
-
Create your daily survey. Do not add any triggering logic to it, and delete the existing default triggering logics. Save and publish the survey. Ignore the warnings.
-
Create a baseline survey so you can get the surgery date of each participant. The survey should have one calendar question with its
Selector
set asDate
. You can add more questions if you want of course. -
Create and link a notification template to the baseline survey to get notified whenever a participant submits the baseline survey. This is essential if you don't want to schedule sessions late.
-
To generate CSV files for upload, you can use tools like R, Python, Excel, or Google Sheets. We go with Google Sheets here. Open your spreadsheet. Create two sheets. Let's name the first one
CSV
and the second oneParameters
. -
Define three parameters in the second sheet:
Participant ID
,Survey ID
, andSurgery Date
. You can set some values for them. -
Go to the first sheet and define three columns:
user_id
,activity_id
, andscheduled_time
. The sheet should have 10 rows (+1 header row). Use the Google Sheets formula and parameters to populate the first sheet:- For cells under the first column, use
= Parameters!$B$1
. - For cells under the second column, use
= Parameters!$B$2
. - Since the scheduled times in the CSV you're going to upload should be in
milliseconds since the Unix epoch, for cells under the third column, use
this formula:
= (DATE(YEAR(Parameters!$B$3), MONTH(Parameters!$B$3), DAY(Parameters!$B$3) + (ROW() - 1)) + TIME(9, 0, 0) - DATE(1970, 1, 1)) * 86400000
- For cells under the first column, use
-
Download the first sheet as a CSV.
-
-
To see the generated sessions more easily, you can switch to the
Year
view mode.
Pro Tips
This article hasn't considered the participant's timezone or the daylight saving
time for the sake of simplicity; the date/time values will be in UTC when
uploaded and after the upload, you might notice a shift in the time (and
probably date). You can define the participant's timezone or the date range for
daylight saving time as new parameters and adjust the formula for the
scheduled_time
column accordingly.
That being said, we're going to improve how we handle the date/time values in the future.