{"info":{"_postman_id":"b0bd7c5e-f1d7-454d-8870-843145c7b92f","name":"Morning Zen with Coco 💚","description":"<html><head></head><body><p><em>Made by <a href=\"https://www.twitter.com/amrit_sharma\">Amrit Sharma</a> in Toronto, Canada for <a href=\"https://postman-hack.devpost.com/\">The Postman API Hack</a></em>.</p>\n<h2 id=\"hey-there-im-coco-so-nice-to-meet-you\">Hey there, I'm Coco. So nice to meet you!</h2>\n<p><img src=\"https://images.unsplash.com/photo-1547007273-7c0aba25f361?ixlib=rb-1.2.1&amp;ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&amp;auto=format&amp;fit=crop&amp;w=600&amp;q=80\" alt=\"Coco\"></p>\n<p><em>Photo credit: <a href=\"https://unsplash.com/\">Unsplash</a></em></p>\n<p>How are you doing today?</p>\n<p>Listen. I know 2020 was a challenging year. 2021 is also pretty strange. </p>\n<p>The physical distancing, waiting for vaccines, not knowing when we will see our friends again and so much more. But you are fighting through it. I am sure you are following your local COVID-19 health guidelines, showing up to work (or school) on Zoom and doing your best. Yay you!</p>\n<p>The pandemic has certainly taken a toll on our minds, but did you know that while we are sitting at our desks (ok fine, couch) at home, we are also destroying our bodies - <a href=\"https://www.vice.com/en/article/4aynaw/working-from-home-is-leading-to-neck-back-pain-health-issues\">quite literally</a>. Problems like insomnia, back pain, hunched over and stiff shoulders, aching eyes and so much more are plaguing many of us because we're stuck at home and not doing much. :(</p>\n<p>This is a BIG deal.</p>\n<p>Taking care of yourself is the best \"developer productivity\" life hack in the world. We all know that we should drink more water, stretch, take breaks, ... but it's tough to remember to do them all the time, right?</p>\n<p>Well, Coco is here for you. 🐶</p>\n<p>Every morning, Coco will send you a gentle message in a private slack channel to remind you to take care of yourself and to help kick start your day on the right foot.</p>\n<p>*wags tail*</p>\n<p>-Coco.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"4962366","collectionId":"b0bd7c5e-f1d7-454d-8870-843145c7b92f","publishedId":"TW6upUeB","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"publishDate":"2021-01-25T23:30:22.000Z"},"item":[{"name":"Where Are You?","event":[{"listen":"test","script":{"exec":["var jsonData = JSON.parse(responseBody);","var lat = _.get(jsonData, 'data.[0].latitude');","var lng = _.get(jsonData, 'data.[0].longitude');","var locality = _.get(jsonData, 'data.[0].locality');","","","pm.environment.set(\"lat\", lat);","pm.environment.set(\"lng\", lng);","pm.environment.set(\"city\", locality);",""],"type":"text/javascript"}}],"id":"99bc2eb9-e1b1-4f4e-8ed7-f8f8d764eb0d","request":{"method":"GET","header":[],"url":"http://api.positionstack.com/v1/forward?access_key={{PositionStack_key}}&query=1 Dundas St W, Toronto, ON","description":"<p>I'm in Toronto and like to run on the sandy beaches of Lake Ontario. What about you? Tell me where you are from in the <code>query</code> query parameter.</p>\n<p>The Position Stack API will convert your address into coordinates, which we will need to check the weather and air quality in your neighborhood. </p>\n<p>You will need to <a href=\"https://positionstack.com/signup/free\">sign up for a FREE API Key</a> from Position Stack. It will only take a couple clicks. When you are done, enter that API key in the <code>PositionStack_key</code> environment variable.</p>\n<p>Sounds good? Let's go.</p>\n","urlObject":{"protocol":"http","path":["v1","forward"],"host":["api","positionstack","com"],"query":[{"key":"access_key","value":"{{PositionStack_key}}"},{"key":"query","value":"1 Dundas St W, Toronto, ON"}],"variable":[]}},"response":[],"_postman_id":"99bc2eb9-e1b1-4f4e-8ed7-f8f8d764eb0d"},{"name":"Weather Report","event":[{"listen":"test","script":{"exec":["var jsonData = JSON.parse(responseBody);","var feels_like = _.get(jsonData, 'current.feels_like');","var pm_25 = _.get(jsonData, 'results.[0].measurements.[0].value');","","feels_like_C = (feels_like - 273.15).toFixed();","feels_like_F = (feels_like_C * 9 / 5 + 32).toFixed()","","pm.environment.set(\"feels_like_C\", feels_like_C);","pm.environment.set(\"feels_like_F\", feels_like_F);"],"type":"text/javascript"}}],"id":"7c0d4b0a-e8b4-4ac9-8c68-3c9d7dd29b49","request":{"method":"GET","header":[],"url":"https://api.openweathermap.org/data/2.5/onecall?lat={{lat}}&lon={{lng}}&exclude=minutely,hourly,daily,alerts&appid={{OWM_key}}","description":"<p>Let's take a look outside to see what the weather is like today!</p>\n<p>You will need to sign up for a FREE API Key from OpenWeatherMap. You can do it easily on their <a href=\"https://openweathermap.org/home/sign_in\">sign up page</a> and grab the API key from the <a href=\"https://home.openweathermap.org/api_keys\">Accounts</a> page.</p>\n<p>Now paste that API Key into the <code>OWM_key</code> environment variable.</p>\n<p>That's it.</p>\n<p>You're on a roll. Let's keep going.</p>\n","urlObject":{"protocol":"https","path":["data","2.5","onecall"],"host":["api","openweathermap","org"],"query":[{"key":"lat","value":"{{lat}}"},{"key":"lon","value":"{{lng}}"},{"key":"exclude","value":"minutely,hourly,daily,alerts"},{"key":"appid","value":"{{OWM_key}}"}],"variable":[]}},"response":[],"_postman_id":"7c0d4b0a-e8b4-4ac9-8c68-3c9d7dd29b49"},{"name":"Air Quality Check","event":[{"listen":"test","script":{"id":"552835a6-177f-41b9-bc5f-1cf4a3187c9b","type":"text/javascript","exec":["var status_code = pm.response.code;","pm.environment.set(\"status_code\", pm.response.code);","console.log(status_code)","","if(status_code === 504 || status_code === 503 || status_code === 500){","","    console.log(\"5XX DETECTED.\")","    console.log(status_code)","    pm.environment.set(\"AQ_data\", false);","    pm.environment.set(\"AQ_level\", \"Sorry, your local air quality data is unavailable today. :mask:\");","    postman.setNextRequest('Assemble Message');","","} else {","","    pm.environment.set(\"AQ_data\", true);","","    var jsonData = JSON.parse(responseBody);","    var pm_25 = _.get(jsonData, 'results.[0].measurements.[0].value');","","    tests[\"PM 2.5 = \" + pm_25] = true;","","    // PM2.5 below 10ug/m3 meets WHO's guideline for clean air.","    if(pm_25 < 10) {","        pm.environment.set(\"AQ_level\", \"The air quality in your good today! Crack a window open or go for a walk.\");","    } else {","        pm.environment.set(\"AQ_level\", \"Oh no. The air quality is unhealthy today. Close your windows, avoid major roads, run an air purifier indoors and wear a mask outdoors. :mask:\");","    }","}"]}},{"listen":"prerequest","script":{"id":"b335e63f-59c4-45bd-a774-1dbaedb46cc1","type":"text/javascript","exec":[""]}}],"id":"9f80ef04-ae6e-4276-9593-174c3008ce34","request":{"method":"GET","header":[],"url":"https://api.openaq.org/v1/measurements?coordinates={{lng}},{{lat}}&radius=2000","description":"<p>Air pollution doesn't just affect people living in New Delhi during smoggy winter months or in San Francisco when wildfires are raging, but it adversely affects you even at seemingly low levels.</p>\n<p><a href=\"https://journal.chestnet.org/article/S0012-3692(18)32723-5/fulltext\">Comprehensive research</a> by scientists and doctors shows that \"air pollution may harm <a href=\"https://www.theguardian.com/environment/ng-interactive/2019/may/17/air-pollution-may-be-damaging-every-organ-and-cell-in-the-body-finds-global-review\">every organ and virtually every cell</a> in your body.\"</p>\n<p>This <a href=\"https://hbr.org/2016/09/air-pollution-is-making-office-workers-less-productive\">Harvard Business Review</a> article goes into detail about how \"air pollution is making office workers less productive\" even when pollution levels are \"relatively low.\"</p>\n<p><img src=\"https://images.unsplash.com/photo-1550633979-0789f5fe3377?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=450&amp;q=80\" alt=\"Coco\" /></p>\n<p>Coco believes that clean air is a basic human right. That's why I will check the air quality level in your city every morning and give you actionable health advisories to protect yourself.</p>\n<p>Disclaimer: The OpenAQ API is experiencing some <a href=\"https://status.openaq.org/\">technical issues</a> which is resulting in ~7% of API calls returning a 504 Gateway Timeout Error. In case we get that error, we are handling it by letting you know that there won't be an air quality report in Coco's message today. It will retry the next day.</p>\n","urlObject":{"protocol":"https","path":["v1","measurements"],"host":["api","openaq","org"],"query":[{"disabled":true,"key":"parameter","value":"pm25"},{"key":"coordinates","value":"{{lng}},{{lat}}"},{"key":"radius","value":"2000"}],"variable":[]}},"response":[],"_postman_id":"9f80ef04-ae6e-4276-9593-174c3008ce34"},{"name":"Push to Slack","event":[{"listen":"prerequest","script":{"id":"11c36a30-95a8-4593-ac48-f442fcfc5bf1","type":"text/javascript","exec":["const things = [\"Drink lots of water.\", \"Text someone you haven't talked to in a while.\", \"Think of three people you are grateful for.\", \"Pick up your phone and call someone.\", \"Assume positive intent from everyone.\", \"Offer to help someone today.\", \"If you get stuck on a problem, take a break and go for a short walk.\"];","","const random = Math.floor(Math.random() * things.length);","console.log(random, things[random]);","","var one_thing = things[random]","pm.environment.set(\"one_thing\", things[random]);","","","var message = `\"Hey, I'm Coco and I'm here with your Morning Zen. Let's begin. :dog:","",":one: _inhale_ with your nose. Hold for 3 seconds. Now _exhale_ from your mouth. :pray:","","Great. Let's do that a few more times.","",":two: In {{city}}, it feels like {{feels_like_C}}°C right now. That's {{feels_like_F}}°F. :thermometer:","","{{AQ_level}}","",":three: 5 mins of yoga at your desk: https://bit.ly/3pfMSaD","",":four: Close your eyes and think about the day ahead of you till the timer goes off. https://e.ggtimer.com/5minutes","",":five: Zen Tip of the Day: {{one_thing}} :green_heart:","\"`;","","pm.environment.set(\"slack_message\", message);","","// console.log(message)"]}}],"id":"c18437fb-610a-4bed-802f-571030dc0a54","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"text\": {{slack_message}}\n}"},"url":"{{Slack_Webhook}}","description":"<p><img src=\"https://images.unsplash.com/photo-1535909339361-ef56e179d637?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=450&amp;q=80\" alt=\"Slack message\" /></p>\n<p>Companies (and schools) use Slack for most internal communications today. Tech startups, especially, practically live on Slack. It's the water cooler or the town square for talking to your team, \"got a minute?\" messages from your manager, ticket injections into your sprint from your Product Manager, pages for system alerts and everything else.</p>\n<p>Coco lives on Slack too because it's the intuitive place for you to check first thing in the morning.\nCoco uses webhooks to send messages to any public or private channel in slack. You will need to set that up and enter your webhook URL in the <code>Slack_Webhook</code> environment variable.</p>\n<p>Our friends at Slack have written this easy-to-follow <a href=\"https://slack.com/intl/en-ca/help/articles/115005265063-Incoming-webhooks-for-Slack\">5 step guide to create a new Webhook</a>. Go ahead and follow those steps now. I'll wait here till you are done.</p>\n<p>...</p>\n<p>Welcome back! That's it. You're all set.</p>\n","urlObject":{"host":["{{Slack_Webhook}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"c18437fb-610a-4bed-802f-571030dc0a54"}],"event":[{"listen":"prerequest","script":{"id":"82755b84-2c04-4dd1-af28-6b0752f3bc96","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"c0dc8218-711e-4ea7-9993-a5e8d43444e3","type":"text/javascript","exec":[""]}}]}