{"id":696,"date":"2024-04-19T03:57:23","date_gmt":"2024-04-19T03:57:23","guid":{"rendered":"https:\/\/draith.com\/?p=696"},"modified":"2025-01-04T04:11:01","modified_gmt":"2025-01-04T04:11:01","slug":"why-not-automating-coffee-break-notifications-with-azure-logic-apps","status":"publish","type":"post","link":"https:\/\/draith.com\/?p=696","title":{"rendered":"Why Not?  Automating Coffee Break Notifications with Azure Logic Apps"},"content":{"rendered":"\n<p>Let\u2019s face it, folks: productivity peaks when caffeine flows. But how often do you lose track of time, only to realize you\u2019ve been glued to your screen without your essential coffee break? Enter <strong>Azure Logic Apps<\/strong>, your caffeine accountability buddy.<\/p>\n\n\n\n<p>Yes, we\u2019re automating coffee break reminders. Is it silly? Absolutely. Is it also a fantastic way to show off your Logic Apps skills? You betcha. Let\u2019s build it\u2014with full code, because you deserve it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The Plan<\/strong><\/h2>\n\n\n\n<p>Here\u2019s what we\u2019re building:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Trigger<\/strong>: The Logic App runs every workday at a specific time.<\/li>\n\n\n\n<li><strong>Check Your Calendar<\/strong>: Ensure you\u2019re not in a meeting during coffee time.<\/li>\n\n\n\n<li><strong>Send a Reminder<\/strong>: Notify yourself to take a break and caffeinate responsibly.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Create the Logic App<\/strong><\/h2>\n\n\n\n<p>First, create a Logic App in the Azure Portal (Consumption Plan) and name it something clever like <code>CoffeeBreakBuddy<\/code>. We are building a caffeine ally here afterall.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Full Code: Coffee Break Reminder Logic App<\/strong><\/h3>\n\n\n\n<p>Here\u2019s the complete code for your new caffeine buddy in JSON. Save it as a <code>.json<\/code> file and import it into the Azure Logic Apps designer<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{<br>    \"definition\": {<br>        \"$schema\": \"https:\/\/schema.management.azure.com\/providers\/Microsoft.Logic\/schemas\/2016-06-01\/workflowdefinition.json#\",<br>        \"actions\": {<br>            \"Check_Calendar\": {<br>                \"inputs\": {<br>                    \"host\": {<br>                        \"connection\": {<br>                            \"name\": \"@parameters('$connections')&#91;'office365']&#91;'connectionId']\"<br>                        }<br>                    },<br>                    \"method\": \"get\",<br>                    \"path\": \"\/v2\/calendars\/me\/events\",<br>                    \"queries\": {<br>                        \"$filter\": \"start\/dateTime ge '@{utcNow()}' and start\/dateTime lt '@{addMinutes(utcNow(),30)}'\"<br>                    }<br>                },<br>                \"runAfter\": {<br>                    \"Recurrence\": &#91;<br>                        \"Succeeded\"<br>                    ]<br>                },<br>                \"type\": \"ApiConnection\"<br>            },<br>            \"Condition\": {<br>                \"actions\": {<br>                    \"Send_Reminder\": {<br>                        \"inputs\": {<br>                            \"body\": {<br>                                \"Content\": \"It's coffee o'clock! Take a break and enjoy your brew. \u2615\"<br>                            },<br>                            \"host\": {<br>                                \"connection\": {<br>                                    \"name\": \"@parameters('$connections')&#91;'office365']&#91;'connectionId']\"<br>                                }<br>                            },<br>                            \"method\": \"post\",<br>                            \"path\": \"\/v2\/emails\",<br>                            \"headers\": {<br>                                \"Subject\": \"Coffee Break Reminder\"<br>                            }<br>                        },<br>                        \"type\": \"ApiConnection\"<br>                    }<br>                },<br>                \"expression\": {<br>                    \"and\": &#91;<br>                        {<br>                            \"equals\": &#91;<br>                                \"@empty(body('Check_Calendar')?&#91;'value'])\",<br>                                true<br>                            ]<br>                        }<br>                    ]<br>                },<br>                \"runAfter\": {<br>                    \"Check_Calendar\": &#91;<br>                        \"Succeeded\"<br>                    ]<br>                },<br>                \"type\": \"If\"<br>            }<br>        },<br>        \"triggers\": {<br>            \"Recurrence\": {<br>                \"recurrence\": {<br>                    \"frequency\": \"Day\",<br>                    \"interval\": 1,<br>                    \"schedule\": {<br>                        \"hours\": &#91;<br>                            10<br>                        ],<br>                        \"minutes\": &#91;<br>                            0<br>                        ]<br>                    }<br>                },<br>                \"type\": \"Recurrence\"<br>            }<br>        }<br>    },<br>    \"parameters\": {<br>        \"$connections\": {<br>            \"defaultValue\": {},<br>            \"type\": \"Object\"<br>        }<br>    }<br>}<br><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How It Works<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Trigger: Recurrence<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Runs every day at 10:00 AM. Adjust the time in the <code>schedule<\/code> property under <code>Recurrence<\/code>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Check Your Calendar<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Uses the Office 365 Outlook connector to check for events in the next 30 minutes.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Condition: Is It Coffee Time?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If your calendar is empty during the coffee break window, it sends a reminder.<\/li>\n\n\n\n<li>If busy, skips the reminder because productivity comes first (sometimes).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Send Reminder<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Sends an email through the Office 365 connector. You can change this to a Teams message or even a text with Twilio.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Deploy<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Import the JSON<\/strong>:\n<ul class=\"wp-block-list\">\n<li>In the Logic Apps designer, click <strong>Import Logic App<\/strong> and upload the JSON file.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Set Up Connections<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Add an Office 365 Outlook connection for email and calendar integration.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Save and Run<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Save your Logic App and test it by running it manually or waiting for the next scheduled run.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Bonus Ideas<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add weather data to suggest iced or hot coffee.<\/li>\n\n\n\n<li>Hook up Spotify to start a \u201cCoffee Break\u201d playlist.<\/li>\n\n\n\n<li>Track your breaks in Azure Table Storage to analyze your caffeine habits.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Now go forth and caffeinate like a boss. And remember, this isn\u2019t just about coffee\u2014it\u2019s about showing the world that no problem is too small to automate. Cheers!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s face it, folks: productivity peaks when caffeine flows. But how often do you lose track of time, only to realize you\u2019ve been glued to your screen without your essential coffee break? Enter Azure Logic Apps, your caffeine accountability buddy. Yes, we\u2019re automating coffee break reminders. Is it silly? Absolutely. Is it also a fantastic &hellip; <a href=\"https:\/\/draith.com\/?p=696\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Why Not?  Automating Coffee Break Notifications with Azure Logic Apps&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4,13,24],"class_list":["post-696","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-azure","tag-logic-apps","tag-why-not"],"_links":{"self":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=696"}],"version-history":[{"count":6,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/696\/revisions"}],"predecessor-version":[{"id":702,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/696\/revisions\/702"}],"wp:attachment":[{"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}