Teammate recognition can improve productivity and promote collaboration. An easy and often overlooked way to recognize teammates is by celebrating them on their birthday and letting them know that they are invaluable team members. In this tutorial, we'll learn to build a Slack App so that your entire team never misses out on the opportunity to celebrate teammates' birthdays. 🙌🏼
The Slack app will kick off birthday celebrations once a day by posting a message to a specified channel; acknowledging those who were born on that day and month. The Slack app template is preprogrammed with two handy commands. Workspace members can quickly query a Google spreadsheet for a list of registered birthdays with:
/cmd list
- returns all the stored birthdays in a private message visible to the invoking user.
Members can also add birthdays to the Spreadsheet directly from Slack using:
/cmd add <Name> <Birth Month> <Birth Day>
- adds Name, Birth Month, and Birth Day to a Spreadsheet.
For example /cmd add Andrea Sanchez 12 07
Copy this Google Spreadsheet and title it CompanyBirthdays or something similar. Make sure it's set up with three fields for Name
BirthdayMonth
and BirthdayDay
. Fill in a few rows with test data as I have done. Make sure to input the current Month and Day for at least one of the rows - we'll need to test run our application before deploying it.
Great! You're ready to install your Slack app.
Click this deploy from Autocode button to quickly set up your project in Autocode.
You will be prompted to sign in or create a free account. If you have a Standard Library account click Already Registered and sign in using your Standard Library credentials.
Give your project a unique name and select Start API Project from Github:
Autocode automatically sets up a project scaffold to save your project as an API endpoint.
To deploy your API to the cloud navigate through the functions/events/scheduler
folders on the left and select daily.js
file.
Select the red Account Required button, which will prompt you to link a Slack and Google sheets account.
Let's start by linking a Slack Resource.
Select Link New Resource to link a new Slack app.
Select Install Standard Library App.
You should see an OAuth popup. Select the workspace you'd like to install your Slack app in and click Allow.
Give your Slack app a name and image if you'd like.
Select Finish. The green checkmark confirms that you've linked your Slack account. Next select Link Resourc to connect to your Google account through a similar authentication flow.
Once you choose the Google account where you've created your spreadsheet select Allow. Find and Select the CompanyBirthdays Spreadsheet. Continue to Finish Linking.
And finally, follow the instructions to finish linking your Giphy Account to your Standard Library token.
Once you're done linking Slack, Google Sheets and Giphy select Finished Linking.
You're now ready to test run the code and verify that you've linked your application to the correct accounts.
Select the green Run Code button to test your Slack project.
You should see the following message appear in your #general channel.
To deploy your Slack App select Deploy API in the bottom-left of the file manager.
Your Slack App is live! It is set to post a message in the #general channel every day at 8:00 am PST. Your Slack App is now available for use in the Slack workspace you authorized it for. Your Slack app should respond to:
/cmd list
returning a list of all the names and their respective birth months and birthdays. Notice the message is only visible to you so that your request won't disturb your workspace.
If you'd like to add a birthday to the spreadsheet use /cmd followed by first name, last name, birth month and birthday:
/cmd add Andrea Sanchez 12 07
You should receive a confirmation message once you hit enter - the confirmation message is only visible to you :
To verify that the birthday logged you can check your spreadsheet or run /cmd list again:
Congrats! Now that your app is live you can return to Autocode and change the channel that the Slack app posts messages to, change the message, change time, etc.
You will notice that the code is programmed to run at 8:00 am America - Los Angeles time. To change the time your Slack app posts birthday messages double click on the daily.js
file and select Clone API Endpoint.
Use the API Wizard to select Scheduler as your event source and then select the frequency you'd like to have your Slack app post inside a channel. Select the time and timezone and make sure to hit the Save Endpoint button.
Delete the extra const result = {};
statement on line 10.
Delete the extra return result;
statement on line 70
Select Save EndPoint
Autocode automatically saves your new endpoint file as daily0.js
inside /scheduler
folder. Delete your first file if you don't want your app to run at both times.
Make sure to deploy your app again for the changes to take effect by selecting Deploy API in the bottom-left of the file manager.
Standard Library has easy dev/prod environment management. If you want to ship to production, visit build.stdlib.com, find your project and select manage.
From the environment management screen, simply click "Ship Release."
Link any necessary resources, specify the version of the release and click Create Release
to proceed.
That's all you need to do!
Via Slack: libdev.slack.com
You can request an invitation by clicking Community > Slack in the top bar on https://stdlib.com
Via Twitter: @Sandard Library
Via E-mail: [email protected]
Thanks to the Standard Library team and community for all the support and to Akanksha Kevalramani for leading a workshop that inspired this guide.
Keep up to date with platform changes on our Blog.
Happy hacking!