Building a yoga-bot in slack

Arus
2 min readMar 8, 2021

As developers and other screen-based humans, we tend to forget that our bodies aren’t made to sit in a chair and look at a screen for 8–14 hours a day. It’s an epidemic in this industry; honestly, not taking care of your body is widespread among all startup-ers alike; developers, in particular, are extremely susceptible to this pattern of behavior.

So why not build something that helps us to remember to do this a few times a day!!??

Yoga-bots

Photo by Simon Rae on Unsplash

Most companies use slack as a central point of communication, which seemed like the perfect place to start.

We built a yoga-slack-bot at arus.io to remind us to take 5 mins a few times a day and stretch it out!!

At arus.io we believe in open source and sharing the love!! Feel free to grab a copy of this project on our GitHub page (we have a few awesome open source projects on there) or just stick around and we will go over step by step how to build your own yoga-bot!!

Make a project and add some deps:

npm initnpm i babel-core && serverless-bundle && serverless-pseudo-parameters && aws-sdk && axios

Now lets make a serverless file and add what we need to deploy the bot:

touch serverless.yml

Edit the serverless.yml to add the aws config and env needs:

service:  
name: slack-yoga-bot-service
plugins:
- serverless-bundle
- serverless-pseudo-parameters
provider:
name: aws
runtime: nodejs12.x
memorySize: 256
stage: ${opt:stage, 'dev'}
region: us-west-1
functions:
processYoga:
handler: src/handlers/processYoga.handler
events:
- schedule: rate(24 hours)

Lets make a directory for the handlers and a yoga process file:

mkdir handlers && cd handlers && touch processYoga.js

Now lets add what we need to make the bot work:

const Axios = require("axios");
async function processYoga(event, context) {
await Axios.post(
`SLACK-WEBHOOK-URL`,
{
blocks: [........(see slack blocks documentaion)]
);}
export const handler = processYoga;

Now lest deploy out serverless function

sls deploy  -v

--

--

Arus

Aficionad of the deep: startup technology consultant, founder arus.io, builder of all the things, father, global citizen, and lover of street tacos