Create a Scheduled Routine
caution
Tutorial under review due to updates in data schemes.
Company Requirements
Ruanda's Human Resources department wants to implement a bot that reminds team members of upcoming birthdays. The idea is to have a monthly reminder of all the birthdays on that month so that everyone has them in mind.
To make it even more fun, have the company's mascot send the message.
Pre-Requisites
Access Role
- User with the
admin-*-write
permission, which allows complete access to the admin. - User with the
read admin
access role.
Channel
- Create a channel that has the entire team on it. Save the channel id, we'll refer to it as
channel_id
. - You might already have a channel like this from the Create Groups & Channels Tutorial or Create Survey Tutorial.
- You can easily get the id by going to the channel's page and coping the serial number that appears in the URL.
User
- Create a user (company mascot), who will send the birthday message on the team channel. Save the user id, we'll refer to it as
user_id
. - You might already have a user that serves as a company mascot from the Create Survey-Triggered Parameterized Bot Survey.
- You can easily get the id by going to the user's settings page and coping the serial number that appears in the URL.
Steps
I. Create a Collection
- Create the birthdays collection.
- Add Elements to add person and birthdate.
- Use the following data for this exercise:
Name:
Code:
Display:
January
month_01
Andrew [2], Sergio [3], Ariel [12], Gwen [20] and Julie [23]
February
month_02
Mario [2] and Will Smith [12]
March
month_03
Valentina [15] and Aron Piper [22]
May
month_05
Javiera [16] and Christian[15]
June
month_06
Tom Holland [18]
July
month_07
Joaquin [30]
August
month_08
Robert [13]
September
month_09
Zac Efron [7]
October
month_10
Lily Collins [3]
November
month_11
Tom Cruise [5]
December
month_12
Harry Styles [20] and LeBron James [30]
II. Create Scheduler
- Access the Administrator and open Schedules.
- Press + button to create a new scheduler.
- Set up the General information section:
- Code:
birthday_reminder
- Activate the Recurrence button.
- Select the Monthly option
- Every: 1
- Day: 1
- Hour: 9
- Minute: 0
- Code:
Set up the Routine builder and set the following:
- Press + Add Stage
- Code:
get_date
- Type:
Network Request
- URL:
http://worldtimeapi.org/api/timezone/America/Santiago
- Method:
GET
- Code:
- Press + Add Stage and set the following:
- Code:
property
- Type:
Network Request
- URL:
$JOIN#/#($ENV#BASEURL)#api#properties#findByCode#($JOIN##month_#($OUTPUT#get_date#data|datetime|[date=>format=MM]))
- Method:
GET
- Activate the Default authentication button.note
Default authentication must be be active in order for it to work with the Cotalker API.
- Code:
- Press + Add Stage and set the following:
- Code:
message
- Type:
Send Message
- Content:
$JOIN##(🎈 This month we celebrate the following birthdays! 🎈)#($OUTPUT#property#data|extra|display)
- Content Type:
text/plain
- User: user_id*
- In Channel press + Add Item:
- Item: channel_id*note
*Remember to use the mascot's and channel's id as explained above.
- Item: channel_id*
- Code:
- Press + Add Stage and set the following:
- Code:
empty_condition
- Type:
Conditional
- Left side:
$OUTPUT#property#data
- Right side:
$CODE#users#email#asdasd@cotalker.com
- Operator:
neq
- True Condition:
message
- Code:
- Max. Iterations:
10
- Initial Stage:
get_date
- Set up the Outputs section of the get_date stage:
Succed
: property
- Set up the Outputs section of the property stage:
- Succed:
conditional
- Succed:
- Press + Add Stage
- Press Save.