<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Maxim Bassin on Medium]]></title>
        <description><![CDATA[Stories by Maxim Bassin on Medium]]></description>
        <link>https://medium.com/@maxim.bassin?source=rss-8a5f04f51ad1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ESMnUEDIiNHluLanvfOmjg.jpeg</url>
            <title>Stories by Maxim Bassin on Medium</title>
            <link>https://medium.com/@maxim.bassin?source=rss-8a5f04f51ad1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 02:10:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maxim.bassin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Crash course on backend programming for Product Managers//Building a Slack app from scratch]]></title>
            <link>https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-4fcff93da387?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fcff93da387</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Sat, 13 Nov 2021 10:53:54 GMT</pubDate>
            <atom:updated>2021-11-13T11:01:30.595Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s3_LhTBwixuNawHmZw_jFQ.png" /></figure><p>Backend programming is a huuuuuuge domain that is usually less intuitive for product managers (and other humans) who don’t have a programming background. Have you ever tried to read about Oauth2 on your own, just to find yourself drifting away to look at funny cats’ gifs?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*BXS5dXvEtFSkvPeSqz9qkQ.gif" /></figure><p>This article will simplify the backend domain, having product managers in mind. Through a step-by-step (384 screenshots and 16 gifs) hands-on backend programming experience, you (yes you!) will build an app (yes, an actual working app!) that will occasionally send to Slack an inspirational photo and a few words of wisdom (or a knock-knock joke).</p><p>The result will work similarly to this Product Snippets app that sends bite-size product management insights to your work Slack:</p><p><a href="http://productsnippets.com/">productsnippets.com</a></p><h4>🏆 You will get:</h4><ul><li>Hands-on experience with technologies your team uses</li><li>Familiarize yourself better with backend related terms and flows</li><li>Have the confidence to start your own side hustle</li></ul><h4>🔎 We’ll touch on the following topics:</h4><ul><li>GitHub + Git</li><li>NodeJS + npm packages + cron jobs</li><li>MongoDB</li><li>Amazon S3</li><li>API + GET + Oauth2</li></ul><h4>💪 This is what you’ll need to build the Slack app with this article:</h4><ul><li>Passion about technology and how things work</li><li>Basic understanding of programming. You don’t need to know how to program, just to be familiar with the basics (not being scared by things such as “for”, “variable” and “function”)</li></ul><h4>🥱 These will not be covered:</h4><ul><li>Best practices — the programming methods chosen in the article may not align with production-grade, real-world applications. The main goal here is to make it work in the simplest explainable manner.</li><li>Optimization — some methods presented here might not be the most optimum ones for runtime, memory usage, and code size. But we don’t care (right?), because we are after getting the sense of the basics by building a non-mission-critical Slack app in the simplest manner.</li><li>Detailed platforms capabilities — we’ll cover only what we need from the platforms we’ll use.</li><li>Advanced tools — we’ll use the minimum amount of tools to reach our goal.</li></ul><h3>Ready? Let’s go!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*Jvk5w52M5XJtiXWkSb_m8g.gif" /></figure><h4>First, let’s define the “need”</h4><p>As a product manager, I’d like to learn a lot of work-appropriate jokes, at a pace that I will be able to remember, so I will have the best presentation starters/endings in the company.</p><h4>The “solution”</h4><p>Hand-picked jokes accompanied with an image, sent to user’s Slack, once a week, before lunchtime.</p><h4>The flow</h4><p>Once a week, the app will:</p><ul><li>Pull the info of the users who installed the app</li><li>Pull the message of the week from the database for each user</li><li>Using the tokens of each user we’ll use the Slack API to send the messages</li></ul><h4>The architecture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LFLlyNBqBLlmcldhpUZceg.png" /></figure><h4>App installation</h4><ul><li>A simple website with an “Add to Slack” button</li><li>Once installed, all relevant user info will be saved to the MongoDB database</li></ul><h3>Let’s get this done! Deep breath, diving in.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*TBtFMdITUEqeXMKKumBlAg.gif" /></figure><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part1-58911ab902d9?source=friends_link&amp;sk=bde2519f3645cd1305e8411973ed85ab">Part 1 — Setting the basics</a></h4><p><strong>You will:</strong></p><ol><li>Create and set up a new app in Slack</li><li>Install the app to your Slack account</li><li>Download and install Xcode (Mac users) and VSCode</li><li>Install NodeJS</li><li>Install Slack’s npm package for sending messages</li><li>Using the app token from Slack and your Slack user ID, send a text message from your computer to Slack, using Slack’s chat.postMessage method</li></ol><p><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part1-58911ab902d9?source=friends_link&amp;sk=bde2519f3645cd1305e8411973ed85ab">Part 1 hands-on — Let’s go!</a></p><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part2-b74121185ef0?source=friends_link&amp;sk=d2e8ee4ab7d2d583d686358c9f7d2694">Part 2 — Git, GitHub, and Heroku</a></h4><p><strong>You will:</strong></p><ol><li>Set up Git versioning control</li><li>Open a GitHub project and sync your project to it</li><li>Set up a worker on the Heroku server</li><li>Link Heroku to be in sync with the GitHub account</li></ol><p><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part2-b74121185ef0?source=friends_link&amp;sk=d2e8ee4ab7d2d583d686358c9f7d2694">Part 2 hands-on — Let’s go!</a></p><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part3-ba66d7a1e39?source=friends_link&amp;sk=6b2f3f4490ee03d3ca9bb5809f82f44e">Part 3 — Cron job, Message styling, and AWS</a></h4><p><strong>You will:</strong></p><ol><li>Install cron npm package</li><li>Using Slack’s message building tool, customize the message format to be sent via API</li><li>Set up an AWS account and create a new bucket to store images</li></ol><p><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part3-ba66d7a1e39?source=friends_link&amp;sk=6b2f3f4490ee03d3ca9bb5809f82f44e">Part 3 hands-on — Let’s go!</a></p><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part4-30f351515197?source=friends_link&amp;sk=bb549abbf2c822460fc80639bb52a8cd">Part 4 — Storing, retrieving, and updating messages in Mongo DB</a></h4><p><strong>You will:</strong></p><ol><li>Open a new account in Mongo DB</li><li>Create a new database and a collection to store the messages in it</li><li>Install Mongo DB’s npm package</li><li>Store credentials in the config vars on the server (avoiding hardcoded credentials)</li><li>Retrieve the “next up” message from Mongo DB and send it using our app</li><li>Once successfully sent, mark the message as sent in Mongo DB and set the “next up” message</li></ol><p><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part4-30f351515197?source=friends_link&amp;sk=bb549abbf2c822460fc80639bb52a8cd">Part 4 hands-on — Let’s go!</a></p><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part5-820fdb708cf7?source=friends_link&amp;sk=cdd9d24a76f522279e8f117f2258dec0">Part 5 — Create a website with an “Add to Slack” button</a></h4><p><strong>You will:</strong></p><ol><li>Create a new server app on Heroku that will serve as a website</li><li>Set the server application to respond to GET messages</li><li>Create a simple HTML page with an “Add to Slack” button</li><li>Built an Oauth2 authentication process: Get from Slack a temporary authorization code and exchange it for an access token</li></ol><p><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part5-820fdb708cf7?source=friends_link&amp;sk=cdd9d24a76f522279e8f117f2258dec0">Part 5 hands-on — Let’s go!</a></p><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part6-245ae99dbca9?source=friends_link&amp;sk=d4686254e6ce89e63f0919736caf430d">Part 6 — Storing info of all the users who installed the app in Mongo DB and send them a cool message once a week</a></h4><p><strong>You will:</strong></p><ol><li>Create a new collection in Mongo DB to store user credentials</li><li>Using the website app, upon every app installation, store the user credentials in Mongo DB</li><li>Using the worker app and the for loop, set the app to go over all the user info and send them a message once a week</li></ol><p><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part6-245ae99dbca9?source=friends_link&amp;sk=d4686254e6ce89e63f0919736caf430d">Part 6 — FINAL PART — hands-on — Let’s go!</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*783SO5k5vmmSHRHu75K5tQ.gif" /></figure><h3>Easy Peasy:)</h3><p>Now that you had the hands-on experience of building an end-to-end app, you should be more comfortable with technical discussions with your team and be able to create awesome side projects on your own. Finally, the StackOverflow answers and the API documentations will become much clearer now.</p><p>🦄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fcff93da387" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part1]]></title>
            <link>https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part1-58911ab902d9?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/58911ab902d9</guid>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Sat, 13 Nov 2021 10:53:38 GMT</pubDate>
            <atom:updated>2021-11-16T08:04:36.441Z</atom:updated>
            <content:encoded><![CDATA[<h3>Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TbpSgrFg7anXcYaqXG1Yxg.png" /></figure><p>Welcome to the first part of the series of <a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-4fcff93da387">Crash course on backend programming for Product Managers</a>, where we will build a Slack app, step-by-step.</p><h3>In this part you will:</h3><ol><li>Create and set up a new app in Slack</li><li>Install the app to your Slack account</li><li>Download and install Xcode (Mac users) and VSCode</li><li>Install NodeJS</li><li>Install Slack’s npm package for sending messages</li><li>Using the app token from Slack and your Slack user ID, send a text message from your computer to Slack, using Slack’s chat.postMessage method</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*YvAfDhDMYSU_ZsWBE8AK6g.gif" /></figure><h4>Let’s go to Slack and set up a new app</h4><p>(10 steps)</p><p>We’ll create an app and install it into our workspace. Then we’ll test our setup using Slack’s documentation tools.</p><p><strong>Note</strong>: This is only an app setup in terms of name, permissions, and tokens. We’ll build the actual app logic in the later steps.</p><ol><li>Go to the <a href="https://api.slack.com/apps">Slack API</a> website and create a new app from scratch.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tV2IQ5PEpcnBjccVmHAVSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KWMU7GUJKf4pOfDVI7dSLQ.png" /></figure><p>2. Under <strong>Add features and functionality</strong>, click the <strong>Permissions</strong> card. You’ll be redirected to OAuth &amp; Permissions sections</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dx1quwY4u_4VU2XvPKinaw.png" /></figure><p>3. Under <strong>Scopes</strong>, click <strong>Add an OAuth Scope</strong> to add <strong>chat:write</strong> scope — this is the scope we’ll need for our app to post messages</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMnZmAYnNc0fol5MmOFYLQ.png" /></figure><p>4. Under the <strong>Install App</strong> tab, click the “Install to Workspace” button, allow the permissions and copy the bot token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7MoYpmwJJPRxMc62nS5aNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ohSizikVB56OEA6kHVLe_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5N_koZuDK1HvzXxUhrWrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jqhwZd5LRREuz33oRKt9Nw.png" /></figure><p><strong>Note</strong>: If your app is monitored by an admin, you should request to install the app, by clicking the <strong>Request to Install</strong> button under the <strong>Install Ap</strong>p tab and wait for the admin approval (send your admin a Slack to speed up the process)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_i9b2gOS3LAa-JnV8M77tg.png" /></figure><p><strong>Bonus note</strong>: You can create an additional workspace in Slack to toally isolate your side project from work. Just go to the <a href="https://slack.com/intl/en-il/">slack website</a> and click on “Create a New Workspace”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lyWhBC2WDnq3c8vFhjT5A.png" /></figure><p>If you have a Gmail address, you can use a “+text” as a suffix to keep recieving emails to the same inbox, but having a different user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_-ChHzTDKxkRSIWLH05LLQ.png" /></figure><p>Then, when you’ll create your app, just select your new workspace, in the workspace dropdown in Step 1.</p><p>5. Now let’s test our app manually. In the documentation, search for the post message method, and click the Test tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fykXW8k-x_cNWY-9r_EBKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QZgj7uP3xZ8j3jTOq-7wpg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZuEEdBLIAVjgen8K3PVbOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HswzWn8rv62iVkF5xy2NZA.png" /></figure><p>6. Paste the copied token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6mp3zXcX2MEu8IPz6Fi_7Q.png" /></figure><p>7. For the “channel” field we’d need the ID of the channel we’d like our app to post to. Since we kept our permissions to the minimum, we can paste to the channel of the app directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*wapoSh8mIe8lM259J_brRg.png" /></figure><p>According to the <a href="https://api.slack.com/methods/chat.postMessage/test#channels__post-to-a-direct-message-channel">Slack documentation</a>, if we’ll provide the member ID in the channel field, it will send the message to the app channel. Let’s copy our member ID:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzW70f2_pGF5dUfW1LvNgw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8dwOXtY-xnB4QqCx2kFPhw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x7EVF-fq5lMq9Dr7YDwKBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v55HlcpDFWWcZQcGzAEpjw.png" /><figcaption>Just click the field, and it will copy the value</figcaption></figure><p>8. Now let’s paste the member ID in the channel field of our test:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44n-NLlm7XSha22HqF02rg.png" /></figure><p>9. Add some text for the message and click “Test method”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__rCpynTEtVaUSsUj9HIRg.png" /></figure><p>10. If all went well, on the right side you should get a result similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BSTnGA6jnet9IPjqslSTVg.png" /></figure><p><strong>To recap so far:</strong></p><p>We’ve created and installed a Slack app that has permission and credentials to send messages to the app channel on slack.</p><h4>Now let’s try to test the message post method directly from our local computer</h4><p>We’d need to set up our code environment and then test Slack’s message posting method.</p><p><strong>Setting up the code environment</strong></p><p>(4 steps)</p><ol><li>For Mac users, we’d need to download and install the <a href="https://developer.apple.com/xcode/">Xcode</a> by Apple to — we’ll need it for the command line tool (Windows users can skip this step). Keep in mind that it&#39;s an 11GB download, so this can be a great coffee break opportunity ☕️. After the installation, you don’t need to set up anything for Xcode, you can just close the window. Note: MAC users, do not skip this step, you must complete it before moving to the next steps.</li><li>Download and install <a href="https://code.visualstudio.com/">VScode</a> — this will be our local code editor</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ebItaAAsErWdqk8358qotA.png" /></figure><p>3. Let’s set up our project folder to keep the project files in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4GbT9mfyUmFy72aWZpaSpw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fo1bq-ufftZuAJSiKVWRYg.png" /></figure><p>4. Download and install <a href="https://nodejs.org/en/download/">Node.js</a> (use installer download for simplest installation). Basically, this is the javascript-based code platform for development — relatively intuitive and pretty popular.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lsEaCRXwjoO1TxVN90zSiw.png" /></figure><h4><strong>So far we were just setting up our environment, now let’s start coding by building the simplest NodeJS app that will send a message to Slack</strong></h4><p>(7 steps)</p><p>This is the perfect time to take another deep breath 🤓</p><p>1. Initiate npm in your working folder, by opening the terminal in the VSCode and typing<strong> npm init. </strong>npm is a package manager for the JavaScript programming language and it will help us download the package for slack interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ceEHf_scsOm1PceuFv4P5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ajs34HGg3_aZn_eke4sv_g.png" /></figure><p><strong>Note</strong>: The first word for terminal commands is the app, and after it come the commands related to that app, along with parameters (if applicable). So in this case the program is <strong>npm</strong>, and the command is <strong>init</strong> (to initialize the service)</p><p>2. You’ll be asked several questions, if you are not too picky, you can go ahead and click the<strong> return </strong>key<strong> </strong>for all the questions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jqoLmAWfcwZZTaTlvZkfjg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0Zz-JuGnYtqQYi9mQBKEQ.png" /></figure><p>3. Install the <strong>@slack/web-api</strong> npm package to your app project, by typing <strong>npm install @slack/web-api </strong>and then clicking the <strong>return</strong> key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MmrxcC7-0XPGAW7zf5QssA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1xfIJXUG22freQFkFWEMhA.png" /></figure><p><strong>Note</strong>: There were some config files added to your folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-iFGm9KKP8l4cNXeU-cSjw.png" /></figure><p>4. Create a javascript file called app.js file in your folder, through the VSCode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*53wht9e-VjZbAhzYBIUDvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9QMIJmDhlJhIjUv3vewW1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qwUTH6U6oM6dY5CMPptW8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s5g7kXn_o9-cNZhQb6huLQ.png" /></figure><p>5. Paste the following code into the app.js file:</p><pre>// Require the Node Slack SDK package (github.com/slackapi/node-slack-sdk)<br>const { WebClient, LogLevel } = require(&quot;@slack/web-api&quot;);<br><br>// WebClient insantiates a client that can call API methods<br>const client = new WebClient(&quot;YOUR-Bot-User-OAuth-Token&quot;);</pre><pre>// ID of the channel you want to send the message to<br>const channelId = &quot;YOUR-MEMBER-ID&quot;;<br>(async () =&gt; {<br>try {<br>  // Call the chat.postMessage method using the WebClient<br>  const result = await client.chat.postMessage({<br>    channel: channelId,<br>    text: &quot;Hello world from my computer&quot;<br>  });<br><br>  console.log(result);<br>}<br>catch (error) {<br>  console.error(error);<br>}</pre><pre>})();</pre><p><strong>Note</strong>: The lines starting with <strong>// </strong>are comment lines in the code, and they are not executed.</p><p>Replace the token and the channel with your own data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sqUzDzrpHmutdQXs1-O5fw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v55HlcpDFWWcZQcGzAEpjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJ0eFR_BZklTYuXAEmN7iA.png" /></figure><p>6. Save the app.js file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*MdoezaIlYSVvH9c2xbb_1w.png" /></figure><p>7. Now let&#39;s run our app.js file by using the following command in the terminal: <strong>node app.js</strong> (click the return key to execute)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bBP1IvK6bNIXHTQXYwvptQ.png" /></figure><p>If all goes well, you’ll get a result in the terminal, similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8odqGpR8tnGEXkjDswSM9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ECPhs6bsNuz7K_RYdXJGFA.png" /></figure><p>Yay! You’ve just programmatically sent a message to Slack 🎉</p><h3>In the next part you will:</h3><ol><li>Set up Git versioning control</li><li>Open a GitHub project and sync your project to it</li><li>Set up a worker on the Heroku server</li><li>Link Heroku to be in sync with the GitHub account</li></ol><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part2-b74121185ef0?source=friends_link&amp;sk=d2e8ee4ab7d2d583d686358c9f7d2694">Let’s go to part 2&gt;&gt;</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*goYzfCmEJh_ASa9kzJnu0A.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58911ab902d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part2]]></title>
            <link>https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part2-b74121185ef0?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b74121185ef0</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[product-management]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Sat, 13 Nov 2021 10:53:30 GMT</pubDate>
            <atom:updated>2021-11-13T10:53:30.636Z</atom:updated>
            <content:encoded><![CDATA[<h3>Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TbpSgrFg7anXcYaqXG1Yxg.png" /></figure><p>This is the 2nd part of the <a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-4fcff93da387">series</a>, where we build an awesome app, all by ourselves.</p><p>In the first part, we’ve set up our Slack app, the dev environment and managed to run our first node.js code from our computer 🥳.</p><h3>In this part you will:</h3><ol><li>Set up Git versioning control</li><li>Open a GitHub project and sync your project to it</li><li>Set up a worker on the Heroku server</li><li>Link Heroku to be in sync with the GitHub account</li></ol><h3><strong>Let’s review and understand the code we’ve used:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqnL-n11JdBZhSbdm1N5rw.png" /></figure><ul><li>Line #2</li></ul><pre>const { WebClient, LogLevel } = require(&quot;<a href="http://twitter.com/slack/web-api">@slack/web-api</a>&quot;);</pre><p>This line calls for the Node Slack SDK package, and assigns it to a parameter called <strong>WebClient</strong>. Which is a setup we have to do in order to use the Slack-related actions. <strong>LogLevel</strong> parameter is redundant and we’ll ignore it for now.</p><ul><li>Then, on line #5 we’re creating an instance called <strong>client</strong>, which we will use to make Slack-related actions (posting a message in our case). We’ve added our token to the instance so it will have the authority to perform these actions</li></ul><pre>const client = new WebClient(&quot;YOUR-Bot-User-OAuth-Token&quot;);</pre><p>which basically translates into:</p><p>Create a new constant instance called <strong>client</strong>, it should be a new instance of WebClient, initialized by the app token that allows it to perform actions.</p><ul><li>On line #7 we’ve created an instance called <strong>channelId</strong>, that keeps the member ID</li></ul><pre>const channelId = &quot;YOUR-MEMBER-ID&quot;;</pre><p>The reason that we’ve used an instance, is so that we will type <strong>channelId</strong> every time that we’d need to use it, instead of explicitly writing the ID. Parametrizing all the information at the beginning of the code is a very good way to keep a flexible and readable code.</p><ul><li>Then we have a block, starting at line #8 and finishing on line #21</li></ul><pre>(async () =&gt; {<br>  //SOME CODE TO SEND A MESSAGE TO SLACK<br>})();</pre><p>This is a format for an asynchronous function. It means that during the code execution, the code execution will not pause until the content of the async function will finish (as with non-async functions, where the code execution is paused until the function has finished its execution). Why do we need an asynchronous function to execute the message sending? Good question! It has to do with the code inside the function:</p><pre>try {<br>  //SOME CODE TO SEND A MESSAGE TO SLACK<br>}<br>catch (error) {<br>  //SOME CODE TO DEAL WITH WHAT HAPPENS WHEN THE MESSAGEE WILL NOT BE SUCCESSFULLY DELIVERED<br>}</pre><p>It has a try/catch block, which is a method to try and execute a command and being able to deal with the case where the command fails, without breaking out of the execution (if the command fails, we’d be able to handle it and continue the execution of the rest of our code). To implement the try/catch block, it has to live within an async function.</p><ul><li>Let’s examine the command that actually sends the message to Slack, on lines #11–13</li></ul><pre>  const result = await client.chat.postMessage({<br>    channel: channelId,<br>    text: &quot;Hello world from my computer&quot;<br>  });</pre><p>It’s a bit counter-intuitive but what is written here is something among the lines of:</p><p>The <strong>result</strong> that I want, is the outcome of when I’ll finish waiting for <strong>chat.postMessage</strong> method of the client instance to complete. The <strong>chat.postMessage</strong> method executes using 2 configuration parameters: <strong>channel, </strong>which equals to our <strong>channelId </strong>(previously defined), and <strong>text</strong>, which equals to the message we’d like to send.</p><p>This block executes the <strong>chat.postMessage</strong> and puts the execution result (the Slack server response for our chat.PostMessage call) into the <strong>result.</strong></p><ul><li>Then on line #16</li></ul><pre>  console.log(result);</pre><p>We’re displaying the response in our terminal. Basically saying: Set a <strong>log</strong> entry of the <strong>console</strong> to be the content of the <strong>result.</strong></p><p>The content of the <strong>result</strong> is what we saw here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vN5QwQYnzzGrGMbior6rvQ.png" /></figure><ul><li>Let’s review the catch part of the block</li></ul><pre>catch (error) {<br>  console.error(error);<br>}</pre><p>This basically translates into: If there is an error with the <strong>try</strong> block, set the content of the error into the <strong>error</strong> parameter, and then set a <strong>log</strong> entry of the <strong>console</strong> to be the content of the <strong>error.</strong></p><p>Pretty simple, right? 😅</p><h3>Now let’s set up versioning control and put our code in the cloud</h3><h4>But why 🤔?</h4><p>Good question! During development, there are many interactions and sometimes parallel coding. In order not to lose ourselves, we should keep track of all our changes by managing versions of the changes. Having our code and versions on the cloud will allow us to sync it with a server to run our code, and also will allow us and other team members to contribute to our code from anywhere.</p><h4>Let’s open a GitHub account to store our code and its versions</h4><ul><li>Go to <a href="https://github.com/">https://github.com/</a></li><li>Sign up</li><li>In VSCode, click the version. control icon on the left toolbar and click <strong>Publish to GitHub</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FmYt-O0CQFRt4kKPLwBxhA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p6lWADLfZmvMvHjW1opvLQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I7mjHLc31HsAl6UQMy5ZXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vwlnCtTNNjIsrNno0J-kXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SagyZ7Nx5S1DqTHfh20XfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7TZOIqtQMU3WnAYdB6Knw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23CvhdTwVweNACS6r6l3Ww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fouec2TmKGqEjKh7vPh3qA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZAqlmqnTVKv4FYoakttHNA.png" /></figure><ul><li>Click on the checkmark button to make the first commit</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*DeLsq-WxQrV1zOM8YXm7_w.png" /></figure><ul><li>Add commit note and press the <strong>return</strong> key</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EFH7yl5oGp2EEyJWXq-FIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RdyrArZWcEjZvIeWZJvCzQ.png" /></figure><ul><li>Oh no, we had an error, let’s see what the issue</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*YgbPx7Le9vnXLgJPAWPtRg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SXcUf2wlmOmh6wP82UnSZQ.png" /></figure><ul><li>Let’s set up the user email and name for git commits</li><li>Open the <strong>terminal</strong> and put in the following info (replace the email and name placeholders with the data you used to set up the GitHub account)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K6zQxGZZAA-e_Yy1sB8V6A.png" /></figure><pre>git config --global user.email &quot;<a href="/service/mailto:you@example.com">you@example.com</a>&quot;<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dTswtM4vUcThIHXxTdv-Uw.png" /></figure><p>and then hit the return key.</p><p>Then add the user name and hit the return key</p><pre>git config --global user.name &quot;Your Name&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rX4MnevHb21tsfGcKK8THQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMiC4x3HmBogzy4mf_FuGw.png" /></figure><ul><li>Let’s try to commit again, using the checkmark icon and adding the note</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*H1eLFQkcBHs4su3qjxDp0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RdyrArZWcEjZvIeWZJvCzQ.png" /></figure><p>you should note that the list on the left side became empty — meaning that all our latest changes have a project version assigned to them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*QZb64_PDfGbiGj2QF0mR6A.png" /></figure><ul><li>You’ll notice on GitHub that now you have a new repository. Click it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZI6HWD7lK2vQf6hPHwAL1w.png" /></figure><ul><li>Copy the repository link</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yNahrOsf05h_a-knqNaazQ.png" /></figure><ul><li>Now let’s <strong>Push</strong> our latest version to GitHub</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*nITj_Gkjvpcd9H2XdxZ_ag.png" /></figure><ul><li>We’ll get an error shown on the bottom right of the VSCode window. Let’s click “Add Remote” to resolve it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fE9yOvDc-brUCGTVF-KaZw.png" /></figure><ul><li>Paste the URL you’ve copied from GitHub</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u4pMyiF1gYa0g4MBOFdNpw.png" /></figure><ul><li>Add a name to the remote source and hit the Return key</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E5wfFWvolSoLoqTub8kXxQ.png" /></figure><ul><li>Let’s try to Push our code again</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-9cCBLYAzvzaveGm7_2u9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CcEqqQjTnbZpFmc_85fZMQ.png" /></figure><ul><li>Now, when you’ll refresh your GitHub project, you’ll see our local files in the project.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6cTk12zYCSHIlQUCMR5gpg.png" /></figure><h4>Let’s review what just happened</h4><p>We’ve hooked up the version control system (git) and then pushed our latest version to our master branch in GitHub.</p><p>So what are these <strong>Commit</strong> and <strong>Push</strong> actions?</p><p>We used <strong>Commit</strong>, to commit the files for versioning, and <strong>Push</strong>, to push the latest version to the remote repository on GitHub.</p><p>During our development, we will save &amp; <strong>Commit</strong> our changes and then <strong>Push</strong> them to GitHub, for every new code version we’ll create.</p><h3>OK, now we’ll set up a remote server (Heroku) to run our app</h3><p>(9 steps)</p><ol><li>Go to <a href="https://www.heroku.com/">Heroku</a> and create a new account with all the defaults. Be sure to set the default programming language as Node.js</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKHcpgmas7yC5KDzrJDEaQ.png" /></figure><p>2. Create a new app in Heroku (give it a fun and recognizable name)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xclk5iyE96_tB95Yln1Lcw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vh89Eg7pZF0k22Wr0rS37A.png" /></figure><p>3. Connect your GitHub project to the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HRLrOLXeg5BrTz4d1IvVhg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e1OFe9glOMDE9QmC7LcdSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4vEBX98SGYPOJzEK-NJBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x6rcjRBl7FtZy4h51Z0vJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MClHIvCN4gN2cJPC70gm8g.png" /></figure><p>4. In VSCode, let’s specify that <strong>start</strong> is the command that should execute the app.js file that contains our app. It’s just something that needs to be done in order for things to run as expected.</p><p>4.1 Go to Explorer, click the package.json file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_lOKuf5JSMojjxRxgpUPg.png" /></figure><p>4.2 Replace the “test” line under scripts with the following:</p><pre>&quot;start&quot;: &quot;node app.js&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MbY3w5aYTymL0v-ydIikwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w19MClpp6zx1kxTHVi4shQ.png" /></figure><p>4.3 Save the modified package.json file</p><p>4.4 Create a new file in the project folder and call it Procfile (without extension). Add the following line to the file and save it (This is something that needs to be configured to make things run as expected on Heroku).</p><pre>worker: npm start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ybLVw_B5dggm4_DYJDZC0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v4z9_HJnrDWw8N5ZwQIruA.png" /><figcaption>“worker” will indicate to Heroku, that our app is a process that runs on the server, vs a “web” that specify a setup that listens to ports and fetches web pages, like a website</figcaption></figure><p>4.5 On the Heroku website, change the following configuration to be “worker” instead of “web”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yFoDls9W4BXm9Q9Y9A05IQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hBA9bRfMMpTolNWnffp8fQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rfBcHg8OZuZ767QKeZoWzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O7Qd1KaoOhkrZEJzFyJBtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPriFgeVd8jhrVWsZ2e9JQ.png" /></figure><p>5. Now let’s change the message we’d like to send using our app (don’t forget to save the file), commit the changes, push it to GitHub and see what happens. The pushed changes should put our code to the Heroku server and run it from there — eventually sending our message to our Slack from the Heroku server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A17aAbmrfiiFmm-tnhO9MQ.png" /></figure><p><strong>***THIS IS SOMETHING THAT YOU WILL DO FOR EVERY CODE CHANGE AFTER YOU SAVE YOUR FILES***</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8aVHYr6SHFToG6i65gG82Q.png" /><figcaption>If you didn’t see any updates, it’s probably because you didn’t save your changes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7rdWCpY45oZJoNCig2nEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f4eabwpneZVL0v88ypM64w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0G9tbE1B6UvU5edh33f2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QUK71i6fXwjzioe5PteDhQ.png" /></figure><p>6. On Heroku, you can click to manually deploy the change to the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*btsOWV-7r0S_5NtXgDnN_g.png" /></figure><p>7. If all went well, you should see this message in Heroku and get a new slack message</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MlKgTlKgmkf21ybqFwoOkQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1rBkBqiNWMrrjNpef94HNg.png" /></figure><p>8. Set Heroku to automatically deploy any changes happening on the GitHub repository. This way, every push to GitHub will be automatically deployed to Heroku and executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CgoAFBgMaNbaLR7HORA_BA.png" /></figure><p>9. Let’s test again our end-to-end, by changing the message again, committing, and pushing the change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RPmQ1RF1u4eXUncF_FgoZg.png" /><figcaption>Remeber to save the file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fsjasDzuvzlQEunSG52kUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9rhPMgm0emRZVTqOi6jSyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-BrHOb5vHpXBxHivhLIUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rYkoyrZtNfN30bnReLqqwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LwE7u7L3H_if_UQQZN39Cg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q6WAV9S_e5kjLAnnzaIuew.png" /></figure><h4>You did it! 🍾</h4><p>You’ve successfully set up a server that runs your app. In addition, your local development is synced with a remote repository. So all your committed and pushed changes are automatically executed on the server.</p><p>This is pretty big — <strong>Good job!</strong></p><h3>Now what?</h3><p>Our next steps will be:</p><ol><li>Install cron npm package</li><li>Using Slack’s message building tool, customize the message format to be sent via API</li><li>Set up an AWS account and create a new bucket to store images</li></ol><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part3-ba66d7a1e39?source=friends_link&amp;sk=6b2f3f4490ee03d3ca9bb5809f82f44e">Let’s go to part 3&gt;&gt;</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*YDbYaPhUOG2F5h_XeMx-1A.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b74121185ef0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part3]]></title>
            <link>https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part3-ba66d7a1e39?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba66d7a1e39</guid>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Sat, 13 Nov 2021 10:53:23 GMT</pubDate>
            <atom:updated>2021-11-13T10:53:23.368Z</atom:updated>
            <content:encoded><![CDATA[<h3>Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part 3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TbpSgrFg7anXcYaqXG1Yxg.png" /></figure><p>This is the 3rd part of the <a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-4fcff93da387">series</a>, where we build an awesome app, all by ourselves.</p><p>In part 1 and part 2, we’ve successfully set up our Slack app, wrote a message sending code via Slack’s API, using node.js, push it to GitHub through Git, and run the app from the Heroku server🥳.</p><h3>In this part you will:</h3><ol><li>Install cron npm package</li><li>Using Slack’s message building tool, customize the message format to be sent via API</li><li>Set up an AWS account and create a new bucket to store images</li></ol><h3>Let’s begin with the timing of our message</h3><p>Currently, our command is fired once the code is loaded to the server. What we’d like to do is to set a function to run once a week on Tuesday, at 11:30 AM and send the message. For that, we’d need something that’s called a “cron job”. Cron is a tool that allows you to execute <em>something</em> on a schedule. It has a freaky syntax so get ready:)</p><p>First, we’d need to add a node.js npm package that will allow us to use the cron functionality in our code. To do so, we’d need to do the following:</p><p>(4 steps)</p><ol><li>Install the package using the following command in VSCode terminal</li></ol><p>npm install cron</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DYqPvVN38MCd274PLI0YYQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RDPmWvyIG5788c6f_ai28Q.png" /></figure><p>and hit the return key. You should see the success message and a bunch of files added to the version control tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uSvWmeHwWNTpdVBBrpUaAQ.png" /></figure><p>2. Now let’s include this functionality in our code by adding the following line to the top of our code, and saving the file:</p><pre>//Requere the Cron package<br>var CronJob <strong>=</strong> require(&#39;cron&#39;).CronJob;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9PQh8Uup21ZXLEapTQc9w.png" /></figure><p>Note that since we’ve installed the cron package, it modified the code in these files to indicate the addition of dependencies in our code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RMVCPQyYKSWWtQo4ujWmCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o2VkixjFmIC3T51S4eUJiA.png" /></figure><p>3. Now we’ll utilize the cron functionality by wrapping our code in the following way:</p><pre>var job <strong>=</strong> <strong>new</strong> CronJob(&#39;* * * * *&#39;, function() {</pre><pre> //OUR CODE FOR SENDING A MESSAGE</pre><pre>});</pre><pre>job.start();</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2CoBHn0jf4yniZdd6-uo1Q.png" /></figure><p>Now let’s save our file and then commit and push our project to GitHub (if you forgot how to do it, see the <a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part2-b74121185ef0?source=friends_link&amp;sk=d2e8ee4ab7d2d583d686358c9f7d2694">previous part</a>).</p><p>Check the Heroku logs and Slack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mSNmrvfGXSaNuH9Y3MQk7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ihQW3mhNmqLXmqir6rc4EQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5lw5XubdozhYQ8IG_tMF2Q.png" /><figcaption>Sign that our server app is up and running</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fRlMwkOstzui4UkwZQeNug.png" /><figcaption>The success message response from Slack, about the successful message sent (the same response we saw in the terminal of VSCode when we sent the message from our local environment)</figcaption></figure><p>You’ll notice that you are getting the Slack message every minute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2txz7mwVZTXCso0QnJqIg.png" /></figure><p>And this is due to the freaky syntax of our cron job setup here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jycYlTuZ9CLV35496K66w.png" /></figure><p>4. Over <a href="https://crontab.guru/">here</a> you can see the specification on how to set up your timing right with the syntax. In our case, if we’d like to send a message once a week, on Tuesday at 11:30 AM, this is how the syntax should look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2KzV4kepsOoVPNTen7jJog.png" /></figure><p>So our code will look like this</p><pre>var job <strong>=</strong> <strong>new</strong> CronJob(&#39;30 11 * * TUE&#39;, function() {</pre><pre>//OUR CODE FOR SENDING A MESSAGE</pre><pre>});</pre><pre>job.start();</pre><p>Most of the chances are that by the time you got here it’s not a few minutes before 11:30 on a Tuesday. So what we’d do is to set the timing for 5 minutes from now, run it, and see if the timing works. Assuming that today is Friday, and the time is 12:55 AM. We’ll make the following adjustment to our app.js file in VSCode (timing and a different message, to track the change), save it, commit and push it to our server (clicking the checkmark on the top right, adding “Cron” as a comment, the from the menu selecting “Push to” and selecting our repository)</p><p>Note: Your server’s timezone on Heroku probably differs from your time zone, you can see your server time in the logs. It’s probably UTC. So when adding 5 minutes to the current time, also add the timezone difference as well. I have 3 hours difference from my server time, so I’ve set the cron job to 10:00</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IxfSKJoBvDX6R5E7q413sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lrtT8x8fU0XEbBGioHuFLA.png" /></figure><p>Save the file and then commit and push our project to GitHub (if you forgot how to do it, see the <a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part2-b74121185ef0?source=friends_link&amp;sk=d2e8ee4ab7d2d583d686358c9f7d2694">previous part</a>).</p><p>And now we wait…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*TU18JEgDA5pT0fgRIHufXA.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35DlYvWWmro_AhlIUx-R7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ODQrGmxjvO9PexA3o1yylg.png" /></figure><p>Success!</p><h4>So, what we’ve actually done? 🤔</h4><p>We’ve set up a process (node.js app) on a server (Heroku) that executes a message sending function (API call) once a week (cron job).</p><p>And that is AMAZING!🥳</p><h3>Now, let’s make a fancy message styling, by utilizing the Slack API options</h3><p>Check <a href="https://app.slack.com/block-kit-builder/">this</a> message-building tool by Slack. You can start fresh by deleting the content and adding 2 “Section/mrkdwn” blocks and 1 “Image/title” block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y40_FuExrV1wZco_68tswA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5G5zlvxtVaNb1i27NCebsg.png" /></figure><p>Now note the code created on the right side. This is the code we’d need to add if we’d want to get the message styled in the way it’s shown in the message preview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJ1xyM9DktkpJ3IOVdoJrg.png" /></figure><p>Basically, we can see there is an array under “blocks”, consisting of 3items (2 for the markdown text, and the other for the image). Each item has several parameters (e.g. “type”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ZInIvc-N0-SD0QYuspIBw.png" /></figure><p>Adjust the right side to the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nTQ1cII31_Go1exmkrWH_A.png" /></figure><p>Note that the 2 asterisks that we’ve added to our text here made the text bold. This is the unique behavior for Slack’s platform when the block type is “mrkdwn”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IkH1HhS7YdPIiJsd4If18A.png" /></figure><p>You can test the message styling by sending it to yourself using this button and selecting your own channel in the popup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*umVECpg-De45n0_EaOqnvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZPYgSqbw3DTVLsdCzQl3_Q.png" /></figure><p>And sure enough, you’ll be able to see the result in your own channel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8acSnvCmGjPLj8wStGh1g.png" /></figure><p>OK, everything is looking good and we can now add that piece of code to our own code and test it.</p><h3>We got the style, now let’s use it in our code</h3><p>(3 steps)</p><ol><li>Copy the entire right side code from the Block Kit Builder, without the curly brackets ({})at the beginning and the end of the code:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AAXEyY_RglEc8N3oCeIy7Q.png" /></figure><p>2. Add a comma at the end of line 18 in our code, make a new line and paste the copied code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dNNyR2dsRlM_3Lm-A11GaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dEhjZ04j9oxWwmQS9_UkYQ.png" /><figcaption>Note that the text in the “text” parameter on line 18 (“Testing end-to-end with custom timing”) will be the fallback text for the message in case there will be an issue with the “blocks” section</figcaption></figure><p>3. To test our code, let’s change the cron job settings to be on today&#39;s day of the week, 5 minutes from now in the UTC timezone (in my case it’s Tuesday 13:50). Save, commit and push it to see it in our Slack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4EqiO4Lc2Na52WmvxTYOJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XjvTEhd6343WimIkPX3rxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aqOhlJYnFA3bbBMGGcHqDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KcbVSoI86jxgl1pvLyOD9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*takEXbiZikpAec4CJN4Rvg.png" /></figure><p>And on the time we’ve specified, we should get the message from our app on the Heroku server to the app channel in our Slack</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmj6wOkJ28yr6BuXbj3HWg.png" /></figure><p>That is amazing!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*pgvwWUE1WpyDRdixJFVc2Q.gif" /></figure><h3>It’s time to make our message content dynamic</h3><p>So far, the content we were sending was hardcoded into our code. In order for our app to send new content for every message, our app will need to retrieve the message content from a database each time it plans to send a message.</p><h4>Our logic will be:</h4><ul><li>Once a week, check the database for the latest joke to send</li><li>Get the content from the database for the latest joke</li><li>Send the joke to Slack</li><li>Update the next joke in the database to be the latest one to send</li></ul><p>Let’s assume you’ve already collected your list of jokes and the images to match them.</p><h4>Our images will go to AWS S3 — Amazon’s image storage service — Let’s set it up</h4><p>(7 steps)</p><ol><li>Go to the <a href="https://portal.aws.amazon.com/billing/signup#/start">AWS website</a> to set up an account</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*43S-ZfOkbLQUMe7erqtQ7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lX-6f7b49Dp-EAIRKF2KIQ.png" /></figure><p>2. Sign in as a Root user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWs4xOdtsYiBjIzhNovHeg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YX_CnbjLBWpH1O3CGV66ZA.png" /></figure><p>3. Click on Services and select S3 under Storage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cmkIYjM_WuL_qnrL-0Hmug.png" /></figure><p>4. Now let&#39;s create a public “Bucket”. Which is similar to a public folder. We’d need to have a place to store our images, and then get a public link to them, so we’ll be able to add them to our slack messages</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lo_IAtqb9eqHd6oLKQA_Dg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*7wV9UWQlQPm7wZQ_grKN_g.png" /></figure><p>5. Time to upload our images (we’ll use 3 images, corresponding to 3 jokes — for simplicity)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZNSuy0cuX8BLgykA2kVvwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kL__E4TRiy8AvF7XwMalOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQz5aAtpXWy9QD5neTDl7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qia64K8JL9bF6d5TcP4Apg.png" /></figure><p>6. Now let’s mark all the uploaded files and make them public</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4pR0WJoQihqeb9i86Kafg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bNsvRU0FNVLjPCHUgLsE-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SfoEzAwyMBVRftjB9X9tMQ.png" /></figure><p>7. Congratulations! Now you can get the public link to every file in your bucket, by selecting the file and clicking “Copy URL”. We’ll use it for our messages setup in MongoDB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xqPWNkxKDV1C6Mv3t4XNw.png" /></figure><h3>To summarize this part so far</h3><ul><li>We’ve set a cron job to run our app once a week and send a message to Slack</li><li>Then we added some style to our message</li><li>Finally, our hand-picked images for the jokes are now stored on an AWS S3 server</li></ul><h3>In the next part you will:</h3><ol><li>Open a new account in Mongo DB</li><li>Create a new database and a collection to store the messages in it</li><li>Install Mongo DB’s npm package</li><li>Store credentials in the config vars on the server (avoiding hardcoded credentials)</li><li>Retrieve the “next up” message from Mongo DB and send it using our app</li><li>Once successfully sent, mark the message as sent in Mongo DB and set the “next up” message</li></ol><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part4-30f351515197?source=friends_link&amp;sk=bb549abbf2c822460fc80639bb52a8cd">Let’s go to part 4&gt;&gt;</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ASEyNcV6V-JppkJxBdVA1A.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba66d7a1e39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part4]]></title>
            <link>https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part4-30f351515197?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/30f351515197</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[hands-on-tutorials]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Sat, 13 Nov 2021 10:53:13 GMT</pubDate>
            <atom:updated>2021-11-13T10:53:13.468Z</atom:updated>
            <content:encoded><![CDATA[<h3>Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part 4</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TbpSgrFg7anXcYaqXG1Yxg.png" /></figure><p>This is the 4th part of the <a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-4fcff93da387">series</a>, where we build an awesome app, all by ourselves.</p><h3>In this part you will:</h3><ol><li>Open a new account in Mongo DB</li><li>Create a new database and a collection to store the messages in it</li><li>Install Mongo DB’s npm package</li><li>Store credentials in the config vars on the server (avoiding hardcoded credentials)</li><li>Retrieve the “next up” message from Mongo DB and send it using our app</li><li>Once successfully sent, mark the message as sent in Mongo DB and set the “next up” message</li></ol><h3>Setting up a MongoDB account and adding the messages to it</h3><p>(4 steps)</p><ol><li>Set up the MongoDB account with Javascript as a preferred language, starting <a href="https://www.mongodb.com/">here</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NmgXCKZQHJe4QOK-z74WQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*12JPoOql1H6VLW-CKwBonQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S91QfIznSRQ-N5JWaEgDyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5AO3Mm4qKCmP9MV9uEXCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0mkm8Ub9EEIyTDNCDsKHg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B_DuOnsV3O7Y-f50WZ2VCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cq3EeJZuLoDKwanHLtT5nw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n1IIpWcPxrHDDhopUgELAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJgXrmtc6P9wQLoK-Tk2RQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZewmlvA6nozNc53_253cQw.png" /></figure><p>2. Now let’s create a “collection” for our messages data. A collection is like a folder that contains “documents”, which are similar to files under a folder. Each “document” will hold info about a single message</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mgzJioReRhsb-v9DTu_9NA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-nlbnDPmpAd1h2G9Mneew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a7d3qTa5qQcZXjj3AwXBVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OwRo7gdxO0Uga1n5lfndxg.png" /></figure><p>3. Now we’ll add our first message data. The message data should contain the following info:</p><ul><li>setup — this will hold the text for the joke setup (including the special characters we used to stylize our message — the asterisks at the beginning and the end of the text)</li><li>punch — this will hold the text for the punchline</li><li>image — this will hold the link address to the joke image on the S3 bucket</li><li>nextup — this is the boolean (true/false) indicator for whether the message is the next up to be sent</li></ul><p>(Use the return key to create a new line)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7VJoVewXJ441ckQXEQATKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wrskEskwvAXO3Ce-tSIMHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R1be0tOAWeqDOmecbIa1xg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HBt6R1dWtcQrtzK2YWH-IA.png" /></figure><p>4. Now let’s use the document clone option to copy the structure, and for every new copy we’ll update it with the relevant content. The reason for creating a clone is to maintain the exact same document structure for our code to operate correctly. Repeat the process until you’ll add all your jokes to MongoDB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wVN2KUUb9OiETYwU92l_IQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wDVcFDhH8H2Ryp5haQQduw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b2MtpbA-NXXiilqqgY8LCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9jYdVMrzq-JT8K-L7S_Q6g.png" /></figure><h3>Getting our code to pull the next up message from the MongoDB account</h3><p>(15 steps)</p><ol><li>Install the MongoDB npm package to our project so we will be able to easily use the MongoDB related functions in our code. Write the following text in the Terminal of the VSCode, and hit the return key:</li></ol><pre>npm install mongodb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQGx2yiseb3Ww8LR535_TA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fTBtH7nU45Z74JM9u_6TYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UQigORFvnnVaCk0gGiehw.png" /><figcaption>This is how the success screen should look like</figcaption></figure><p>2. Now let’s include this functionality in our code by adding the following line to the top of our code, and saving the file:</p><pre>//Requere the mongodb package<br>const { MongoClient } = require(&#39;mongodb&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O0nnwrLur8ndey-F_Dt8xQ.png" /></figure><p>3. Let’s create a user on MongoDB to get credentials to connect to our database from our app (avoid using special characters for username and password setup, for simplicity)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9VgM4WEux-LvgepAtw36A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QFgQKUij-_4LzU1GSCbGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dDm7Dyi0NtSNfidABtTJ3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7fC4gMFJP1b1gBPAJL2eMw.png" /></figure><p>4. Now let’s copy those credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*juyCQ8yed00g35zXbTDzzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*byrH7scEZLj9F3pyrWXoHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K5O9kRYM1llmjfhHuzYO-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4MQAjPyyadXURNxthk12ag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lIDr6v6Zun30Es-BqnjGyQ.png" /></figure><p>5. Add the following lines to the code and paste the copied credentials right after it. We will use <em>mongouri</em> as credentials in our code for MongoDB connection (instead of pasting the actual credentials each time). Also, we’ve set up a joke parameter</p><pre>const mongouri = //PASTE HERE THE CREDENTIALS CODE YOU&quot;VE COPIED//<br>let joke;// the joke parameter will hold our message data</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lntAln36NXReMQeJL5E-1A.png" /></figure><p>6. Replace the &lt;password&gt; part with the password of the user you’ve recently created to access the database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XKBQOByVcWE4eqA07oaxiA.png" /></figure><p>7. Copy the database name from MongoDB and paste it instead of the “myFirstDatabase” part</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jxSiuGsDERdFSefb0KuQFQ.png" /></figure><p>8. Add double quotes around the credentials. content in quotes is treated as text, instead of variable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X6-EySjjQlmUdynExK1SvQ.png" /></figure><p>9. Create the actual connection to the database using the credentials, by adding the following code</p><pre>// Create a new MongoClient<br>  let mongoClient = new MongoClient(mongouri, {<br>    useUnifiedTopology: true <br>    })<br>    try {<br>        // Connect the client to the server<br>        await mongoClient.connect();<br>        let db = mongoClient.db(&#39;slackapp&#39;)//set the reference to the connected slackapp database as db<br>        <br>        //get the joke data<br>        let messagesCollection = db.collection(&#39;messages&#39;)// set the reference to the messages collection as messagesCollection<br>        joke=await messagesCollection.findOne({ nextup: true }) // this line will find one document in the messages collection that has the nextup value set to true, and store this document and its content as parameter named joke<br> <br>        <br>    } catch (errormongo) {<br>        console.error(errormongo);<br>        }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Di5u7veuTSjZq_H8e29v7A.png" /></figure><p>This code basically connects to the database using the credentials we’ve set up, and retrieves the document that has the nextup parameter set to true, from the messages collection. The document is stored in the joke parameter, and we can use its content to fill the message content we are sending. Instead of sending a hardcoded message.</p><p>10. Using the joke’s parameter content, we’ll fill in the message data we’d like to send. Remember that in our document, there are keys named <em>setup</em>, <em>punch,</em> and <em>image. </em>To retrieve their content from the joke’s parameter, we can use the following syntax: joke.setup will give the setup content of the retrieved document, joke.punch will retrieve the punch content, and joke.image will retrieve the link to the link to the image.</p><p>Replace the message content with the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6YDSEMCEAWY9LNZYbpdbpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OT4YIu_gN8V4PdKTBgXz8g.png" /></figure><p>11. Let’s test it by setting up the time for 5 minutes from now, on the UTC timezone, saving the file, committing it, and pushing it to production. Then check our slack to see if we got the message when the time comes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XjjroeDMivokDbMCXocDPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gDPVVr4MIunoDzq6HzkZPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hAGka19_A6g2luK_nVe8Yw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MB2UmT_8PiP9yRt21wk1Sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L952blWDWskkhRMZwq0_Kw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7PH-zgs_gSTzEvagRM088g.png" /></figure><p>12. Check your Slack. Did you get a new message from the app? You did? Great! You’ve successfully hooked up MongoDB to your app and retrieved the message content from the database, instead of having it hardcoded in the app.</p><p>13. One last thing for this part. Our MongoDB credentials are hardcoded in the app code. We’ll store them on the server (Heroku) for security reasons. Go to Heroku, and add the MongoDB credentials (without the quotes) as a value of mongouri parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0BaWQ5zV1qjBNEBMBS0i8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7nnGFUoeDnhn5NwGGMvzBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3GVbQr-6QJ01Rv3Qpv2w2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X29czH01G79ZKgiGKkJ9Cg.png" /></figure><p>14. Instead of the hardcoded credentials we should get the value from our server. These Config Vars are stored as environment variable that is available on the server. To access its value from the code we can use <em>process.env.mongouri</em> syntax, which basically goes to the process object, and gets the mongouri variable from the env (environment) parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zJQM2x99xGtZAdknIFhjsw.png" /></figure><p>15. Let’s test it again (adjust the job time to 5 minutes ahead in UTC, save, commit, push). Got the message in Slack? Yay!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpyedHxpfopBLV3j1qXLwQ.png" /></figure><h3>Update the jokes collection to indicate the new next up message, to be used for the next message</h3><p>We’ll a new field to our documents to indicate messages that have already been sent, and mark the next up message to be sent.</p><p>Let’s go!</p><h4>Add the “sent” field of a boolean type (true/false) to all our documents in the collection</h4><p>(7 steps)</p><ol><li>Let’s set up our terminal in VSCode to access and modify our MongoDB documents programmatically. Go here to find the instructions:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wclHuJK5Q5jTqEJomA-DDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nIdmoZC8hVmzWbSh-PDM4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fmu2tgITHXX5Micwg8Ms3w.png" /></figure><p>2. I’ll go with the Mac version. Write the following command in the Terminal and hit the return key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ro9Upop0weEcBUlqU_Uj8g.png" /></figure><pre>brew install mongosh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wRHSIEyQqlmyoVrr_4vSeg.png" /></figure><p>This might take a few minutes to complete.</p><p>3. Once you’ll see this line, this means that the process is complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*On_s-nw5ZXfGws9L24sOlg.png" /></figure><p>You might notice a few errors, that were thrown in the process — those can pop up for many reasons. Let’s try to run our command anyway, in case the errors are not related to our goal.</p><p>4. Now add the connection command copied from the instructions and hit the return key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-TKwWKz45B4PnbsPY5iwmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zn4oWyMXr94pUV5F3ENI1w.png" /></figure><p>5. Add your password for the added user in MongoDB and click enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IuNaefu7ISsmLBQhYTpyrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0NpLWRx9hGuIqR3U2lNmbA.png" /><figcaption>This is the sign of a successful connection</figcaption></figure><p>6. Now that we are connected to our database in MongoDB, we can add “sent” field to all of our documents in the messages collection, using the following code:</p><pre>db.messages.updateMany({},{ $set: {&quot;sent&quot;: false} })</pre><p>Note: <em>messages</em> in the code above is the name of the collection that keeps your documents containing the jokes</p><p>You can read more about this code in the official documentation <a href="https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/">here</a>.</p><p>Basically, this code translates to:</p><ul><li>Go to “messages”<em> </em>collection in the database and update (db.messages.updateMany)</li><li>all the documents (the curly brackets {} without a value inside them specify that we don’t want to filter anything out of the messages collection)</li><li>with an additional parameter named “sent”, that is set to false ({ $set: {“sent”: false} })</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7-wq2Q62VDi-WpC3yDV_5w.png" /></figure><p>When clicking enter, you should see a similar result in the terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*37tNXA2kMZHCHLepOAiuJw.png" /></figure><p>7. Check the collection in MongoDB to see the updated documents 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2a1Q975UZmjtOjKZrVOzg.png" /></figure><h4>Upon sending the message to slack, update the “sent” field of the sent document to “true” and mark another document as “nextup”</h4><p>(5 steps)</p><ol><li>Since we’re going to update several things in our collection, let’s set the variables for the database and collection references as global variables, by putting them in the top section of our code, before our functions are executed. To do so we need to add these 2 lines (variables set up outside of a function are available for all functions. Variables set up inside a function are available only for that function and are not accessible from other functions)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TAxU1lSEEWGsTXOUjg8_dg.png" /></figure><p>and then to remove the “let” from the variables here (“let” is a command to create a new variable, since we’ve set it up at the beginning of our code, we wouldn’t want to create a new one locally)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vPJGb1mdLhm9iqmevCKhzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zuQ1KzFg-eDcxF8UBlhnjg.png" /></figure><p>2. Mark the currently sent document as sent and remove the nextup flag from it. Paste the following lines into the code in the VSCode, to be right after the last “catch” statement:</p><pre>try {<br>    let updatesent = await messagesCollection.updateOne({ nextup: true }, { $set: { nextup: false, sent: true } }) ; //Find one document that has the nextup value set to true and change its nextup value to false, and sent value to true<br>   }<br>   catch (errormongo){<br>    console.error(errormongo);//in case an of an error with the execution, printout the error in the server log<br>   }</pre><p>Which translated to:</p><ul><li>Try to update one document from the messages collection, wait for the action to finish. Let <em>updatesent</em> be the variable holding the results of the action</li><li>When looking for a document to update, search the one that has the <em>nextup</em> field set to <em>true</em></li><li>When found, set the <em>nextup</em> field to <em>false</em> and the <em>sent</em> field to <em>true</em></li><li>In case of an error, print it out in the server log</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NSwqOeqJe0E0GxaUkV5SZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U58hVlNbA62B9y4yzLg0Kw.png" /></figure><p>3. Now let’s find a document that is not flagged as <em>nextup</em>, <strong>nor</strong> as <em>sent </em>(nextup: false, sent: false), and set it to be next up (nextup: true). Paste this code right after the previous one:</p><pre>try {<br>    let updatenextup = await messagesCollection.updateOne({ nextup: false, sent: false }, { $set: { nextup: true } }) ; //Find one document that has the nextup value set to false, while the sent value is set to false, and change its nextup value to true<br>   }<br>   catch (errormongo2){<br>    console.error(errormongo2);//in case an of an error with the execution, printout the error in the server log<br>   }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NdYNt3idRyyjxTsAs8tysQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eicYHcwqiFT4otwtjKYXEQ.png" /></figure><p>4. Change the corn job timing to be a few minutes from now and <strong>save.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kdgw6SwOIaiMpb2UZR2Xw.png" /></figure><p>5. Then add, commit and push to the server. when the job will finish executing, you will be able to see the updated fields in MongoDB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iy1w6_GHXb8h7U-bsLuYTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bRTFK0pE7xJCQ8bnUffYSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ISu7RNLzpLIYQ8RyL4cPIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LygPc8pEj5VKRNj_RIRlEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJ4UBXpU92CYT5J9oomdFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hlove0dCRFT429g6xuS9vg.png" /></figure><h3>To summarize what we’ve achieved in this part</h3><ul><li>We set up a MongoDB account</li><li>Switched the message sending to use database info, instead of hardcoded messages</li><li>Used the terminal and shell commands to access the database and perform batch actions on our database data</li><li>Dynamically retrieved and updated database from our app</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/0*0r07smszaRVUVcka" /></figure><h3>In the next part you will:</h3><ol><li>Create a new server app on Heroku that will serve as a website</li><li>Set the server application to respond to GET messages</li><li>Create a simple HTML page with an “Add to Slack” button</li><li>Built an Oauth2 authentication process: Get from Slack a temporary authorization code and exchange it for an access token</li></ol><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part5-820fdb708cf7?source=friends_link&amp;sk=cdd9d24a76f522279e8f117f2258dec0">Let’s go to part 5&gt;&gt;</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*y5vcVHtGwAIeWGezWkskQg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30f351515197" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part5]]></title>
            <link>https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part5-820fdb708cf7?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/820fdb708cf7</guid>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Sat, 13 Nov 2021 10:53:08 GMT</pubDate>
            <atom:updated>2021-11-13T10:53:08.691Z</atom:updated>
            <content:encoded><![CDATA[<h3>Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part 5</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TbpSgrFg7anXcYaqXG1Yxg.png" /></figure><p>This is the 5th part of the <a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-4fcff93da387">series</a>, where we build an awesome app, all by ourselves.</p><h3>In this part you will:</h3><ol><li>Create a new server app on Heroku that will serve as a website</li><li>Set the server application to respond to GET messages</li><li>Create a simple HTML page with an “Add to Slack” button</li><li>Built an Oauth2 authentication process: Get from Slack a temporary authorization code and exchange it for an access token</li></ol><h3><strong>Off we go!</strong></h3><p>The idea here is that we’d need to have a website that would contain an “Add to Slack” button. By clicking that button, any user will be able to install our app to their domain. When the user will click the button, they will be prompted with Slack’s authorization popup, once confirmed, the authorization process will provide us with the Slack info of the user and their workspace, together with a token that we’d be able to use to send them messages from our app. Remember, currently, we only have 1 user using our app (our own Slack), and we use the hardcoded token and the channel ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3U1Tezd5Bjaa4NUPyKFBUg.png" /></figure><p>Our goal here is to store that data in the database and retrieve it dynamically, just as with messages.</p><h3>Setting up the environment for a new website</h3><p>To create a website, we’ll use Heroku</p><p>(7 steps)</p><ol><li>Go to Heroku, and create a new app</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zhCqgVVlEwQkuTUvDyvqKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AeDF3PcrqsfSjXepbZucIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o6Opb5sIdToYu4LMVKfTww.png" /></figure><p>2. Got to VSCode and open a new window</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5mMTUDvJse9fiwvIraGqgA.png" /></figure><p>3. Create a new folder for our website project and navigate to it from VSCode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GRm5CzyJlIfA5Y9xrv401g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r21hhbIvLtSFtSvdawlPGg.png" /></figure><p>You should see the folder name here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YD2R7W4AsWaeXMgQAZpUtQ.png" /></figure><p>4. Now we should create a placeholder file named server.js. This file will be used as the behind-the-scenes coordinator to handle website requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i9daCuwch5DFPVtY6aItUQ.png" /></figure><p>And save it as is, under the name of “server.js”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A_sBgjfYG57X3la7OEadqw.png" /></figure><p>5. Let’s connect our folder to a new private GitHub repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8YcehR-02-jPfQFYlBP6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*or_JnmANlED7P99leeUvEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fj2KjWOxreEMVkIfQnqTOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8jfrmcF16SU-zDJukKbk2A.png" /></figure><p>Now we have our new repository on GitHub for our website.</p><p>6. Let’s connect the GitHub repository to a new app in Heroku, so whatever code we’ll push to the repository, will be synced to Heroku — our server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0MgSaGsMNpdGLvpbu8Jy8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7E3gcpywzH1ahxlYT_Od8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LuoAxMYyHyg8Sj84fjKt2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Ud83x7dsvzVHGpKRcCGOA.png" /></figure><p>7. And finally, we’ll allow automatic deployment, so any change pushed to GitHub will be automatically deployed to Heroku</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1TUqrXTRmKr7U2a8K7c6Pg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lld3QSBL-keYW8RxKu9avA.png" /></figure><h3>Creating a simple website</h3><h4>The setup</h4><p>(4 steps)</p><ol><li>Initiate npm in your working folder, by opening the terminal in the VSCode and typing <strong>npm init </strong>(and click enter). npm is a package manager for the JavaScript programming language and it will help us download the package for Slack and MongoDB interaction.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tn7SQzO74cm-vJlgiJoG-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yNntH4SYCTI76wplLGlvQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jkBHPDYK1mryNzF3Cd-7OQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfVs05z0jxlz1LQ9k3CJMg.png" /></figure><p>2. Click the return key a few times to have the default settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NEWE1-hyMQZnnD5Cv8FvJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*keU9rV4NWOehjhrKwCsrkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zhJUkQCkgf6gYiCSJc8oUA.png" /></figure><p>3. Install the Slack npm package by typing the following and clicking enter:</p><pre>npm install @slack/web-api</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ngOqWJ92GJ8bV2faFIrgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NBKXL-WGgpCgswgMEOUvHA.png" /></figure><p>4. Install MongoDB npm package with this line:</p><pre>npm install mongodb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YaQoxZrD3SKlCOvl6mqbjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZVbdvmXB1icT0Blf9ZLmA.png" /></figure><h4>The landing page</h4><p>We’ll create a simple website that will contain the word “hello world”</p><p>(8 steps)</p><ol><li>Create a new file by double-clicking the empty space in the tabs header</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zbfDSJA2Qu_VJdYFC0bwwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qxm1HnHklHnshRqEnjfMsA.png" /></figure><p>2. Add the following code to the file</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;head&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>   &lt;h1&gt;hello world&lt;/h1&gt;<br>&lt;/body&gt;</pre><p>3. Save the file as “index.html”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*czmj8qXUxttd5Lkw53jKHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ftGhr8RXm-uTJRGe5hmPg.png" /></figure><p>Note: This is a very basic setup of a webpage, where the first line is the document type declaration, the &lt;head&gt;&lt;/head&gt; part is a placeholder for page configurations (&lt;NAME&gt; is the opening tag, and the &lt;/NAME&gt; is a closing tag of any element on a page), and &lt;body&gt;&lt;/body&gt; is the section containing the content of our site. In our case, we have only one element, which is &lt;h1&gt;&lt;/h1&gt; which is a text Header1 type of element, having “hello world” as content.</p><p>4. Run the file locally to see how it looks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJo_CqiLuO-cGJeY8goztg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdzlDB7oBLw9lbRQFCNIJQ.png" /><figcaption>Simple indeed</figcaption></figure><p>Click to stop the run</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_aBjItHiAFTiYkOYm3Wiw.png" /></figure><p>5. Now we’d like to present this page to whoever will visit our Heroku website. Your default name is YOURHEROKUAPPNAME.heroku.com</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P1m5hhcolwjdyG_VuNNL1A.png" /></figure><p>And now that we visit it, it doesn&#39;t present any content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GDora31DmrMQEPAivwUXCQ.png" /></figure><p>So we need to instruct the server.js file to prevent index.html page to whoever visits our website. When users navigate to a website, they perform a GET request from that URL. server.js is the logic responsible for the website, so we’d need to specify what the site should do when it gets a GET request.</p><p>In order to do so, we’d need our app to listen and respond to requests. We should install another npm package to help us with that. Run the following command in the terminal (don’t forget to hit the return button)</p><pre>npm install express</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AVQd4vR_weiKrARRNTbpvg.png" /></figure><p>6. Now we’ll create a service using the express package to listen to requests and handle the responses. Add the following code to the server.js file (note the explanation comments for each line</p><pre>const express = require(&#39;express&#39;);//add the service to our file to use it&#39;s functions<br>const app = express();//create a constant named app that will utilize express service</pre><pre>const PORT = process.env.PORT; //get the active port our heroku app is runnin on. This is also the port we&#39;ll listen to</pre><pre>app.listen(PORT, function() {});//our app is set to listen to the port<br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.sendFile(__dirname + &#39;/index.html&#39;)<br>})//when our app will get a get request for our app base url, without any file specified, it will respond with the index.html file that resides in the root of our website</pre><p>7. Save the server.js and index.html files, add, commit and push them to git</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TrgsogWncUAZy80qcUWDHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aHeshmsFCJiazyJhF34wrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aHeshmsFCJiazyJhF34wrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gRJnoGU_GYBUofrHxs1xDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EsHLBOPddDK-9_0QVEQ2EQ.png" /></figure><p>8. Check the app website on Heroku, you should get the index.html content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZS3zs9Vubj0iCW-KYm_yDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0VhJhiz23rx0bcCdt4xkTA.png" /></figure><h3>Let’s recap so far:</h3><ul><li>We’ve set app a web service (server.js)</li><li>Using the express npm package, the service listens to a server port</li><li>For when the client gets to the homepage, our service serves the client with the index.html page</li></ul><p>That’s some serious stuff there! Way to go🎉</p><h3>Add the “Add to Slack” button to our website</h3><p>(7 steps)</p><p>1. Go to <a href="http://api.slack.com/">api.slack.com</a> , choose your app and go to B<em>asic information&gt;Manage distribution</em> menu and click the “Distribute App” button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GpRfabc0duNnkfZ-KZKZWw.png" /></figure><p>2. Under <em>Add OAuth Redirect URLs </em>click the <em>Set Up Redirect URLs</em> button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QN6ZH6oqmBUEqHHNM7gksg.png" /></figure><p>3. Under <em>Redirect URLs</em>, click the <em>Add New Redirect URL</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vm2YBWxsau1IQQH0WczIpQ.png" /></figure><p>4. Copy the Herokus website address and paste it here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*noSWrli8TTcWZ-IgY8OMlg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4hdUPJrHSfSVB40wlS9x_Q.png" /></figure><p>And then add <em>slack</em> at the end of the URL and click <em>Add</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OP8jAj0ueG25CI6TL38N7g.png" /></figure><p>5. Save the URL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*niBnJ6CI3__ChKyJT2jSXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7xgtYq7pxxN0-opwMrZbA.png" /></figure><p>6. Now go to <em>Manage Distribution</em> and copy the code for the “Add to Slack” button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AzHicommiwOtxo37LpW2eg.png" /></figure><p>7. Paste the copied code right below the h1 closing tag in the index.html file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gVNkQuMmfcNr6p-lKby_tw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBpTsZrX3cWnkRQAqjUtNQ.png" /></figure><h3>Make the “Add to Slack” button work</h3><p>When a user will click on your “Add to Slack” button and agree to the terms in the popup, Slack will send a GET request to the Redirect URL that we’ve set up earlier (https://slackappwebsiteformedium.herokuapp.com/slack). This request will contain a temporary authorization code. We’d need to extract that code, and send a request to slack with our credentials and temporary authorization code to receive an access token to send messages to the user that just installed our app.</p><p>(9 steps)</p><ol><li>Install Axios npm package that will help us send the temporary authorization token and our credentials to slack</li></ol><p>Run this in the terminal</p><pre>npm install axios</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dC8mdTK2tCN76fouJY1O-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UjXNLDyiQn-6gQF0QnQuGw.png" /></figure><p>And create a constant named axios to use the Axios services by adding this line to the beginning of the code</p><pre>const axios = require(&#39;axios&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pYIoAjU-kpjI8IIdBnC2bw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*86sGlyN0rdJiqfeK9ZXjGQ.png" /></figure><p>2. Create a new parameter called params. It will include the temporary authorization code and our credentials that we’ll send to Slack once a user will install the app. Add this at the beginning of the server.js file</p><pre>const params = new URLSearchParams(); // a const named param is initialized as a URL parameter type object</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ot97ZXe2uz7g02Nm8SiHzg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GaRGamytZgD9b9_JUUFFrw.png" /></figure><p>3. Set our code to listen to GET requests to the Redirect URL that we’ve set up earlier (https://slackappwebsiteformedium.herokuapp.com/slack)</p><p>Install this npm package to help us parse (process) different types of information, by typing the following code to the terminal:</p><pre>npm install body-parser</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfYZUEO8BiqPHlNrUpOdow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BaQmp9FaZAT54tzQhtcIDg.png" /></figure><p>And then add this code, so we will be able to parse different types of information formats</p><pre>const bodyParser = require(&#39;body-parser&#39;)<br>app.use(bodyParser.urlencoded({ extended: true }));<br>app.use(bodyParser.json());</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-ifNxBkPu1wR6UlA9phRg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1T5-50FsEKeZuO3Lnds9cQ.png" /></figure><p>then add the listener for ‘/slack’ path, by adding the below</p><pre>app.get(&#39;/slack&#39;,(req,res) =&gt; {</pre><pre>})</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cmATskh2k4Y-wk1DtKX99A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_2EHJ3EhdfqJfZ92MKskQ.png" /></figure><p>4. Extract the temporary authorization code from the request, and add it under the <em>code</em> parameter in the <em>params</em> object we’ve created, by adding the following code inside the listener we’ve just created. Note the code comments.</p><pre>if(req.query.code){ //check if the request query contains a parameter named code<br>  params.append(&#39;code&#39;, req.query.code)//add to the params object a parameter named code, that has the value of the code recieved in the request query<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9T8NGFz7YH6VWTS9Cj6F7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b2l2_gANrH7Jdb_6bKtXhw.png" /></figure><p>5. For the message we need to send to Slack in order to get the access token, we’d need to add our <em>client ID</em> and <em>client secret</em>. We’ll do the following:</p><ul><li>Get them from Slack</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kmlQXMB-0YA97qh_g1tsw.png" /></figure><ul><li>Store them as environment parameters in Heroku (note the key names, we’ll use them later)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-tD-cqKXRddjTv7Q_gtieA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hwPtPnW7n3UK6m0zJODqRA.png" /></figure><ul><li>Append them to the params object. Add this to the listener:</li></ul><pre>params.append(&#39;client_id&#39;, process.env.client_id)//appending to the params object as client_id the client_id variable stored on the server <br>params.append(&#39;client_secret&#39;, process.env.client_secret)//appending to the params object as client_secret the client_secret variable stored on the server</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KiFKUUexVgFqG4yMLab3Tg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x4GBbst-4zSSrsXNvz_trQ.png" /></figure><p>6. Now that we have our data to get the access token from Slack, we need to send a post request to Slack. Add this to our main function to send the params object to slack and then to print out the data section of the result in the server log, to see what we’ll get from Slack:</p><pre>axios.post(&#39;https://slack.com/api/oauth.v2.access&#39;, params, {headers: {&#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded&#39;}})</pre><pre>.then(async (result) =&gt; {//after the prevous operation will finish, use the results output of that operation and execute this function</pre><pre>console.log(result.data)//prints out the data section of the result into the server logs</pre><pre>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tCB4VDo2OPbHqYjpdRcnnw.png" /></figure><p>We are sending Slack our credentials along with the temporary authorization code we got (all in the <em>params </em>object, encoded by the setting in the config object that we’ve configured early on), the response to this call contains the authorization token to that specific user who installed our app with some basic user info.</p><p>7. Then finally we’ll redirect the user back to the index page for after when the user confirmed our app on Slack’s page, by adding this line right after the closing parentheses of the <em>if</em> statement, so that the user will always be taken to our landing page, regardless of authorization.</p><pre>res.sendFile(__dirname + &#39;/index.html&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Flb6K62KEvNr3wF_dadq4Q.png" /></figure><p>8. Save, commit, and push</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6icPjQFXc0ZHKvTT5i4ivA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QoArTQmrnyBK8Nbh7egGyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJ0VyySGakS3xkMT64B7pw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFoUc5IezU2A3sjXgyIrgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BTn9x2okKuo7mNX-Cw_MIA.png" /></figure><p>9. Open the server log, then run our page (by clicking “Open app”) and install the slack app again. After which, we’ll look at the server logs to see how Slack’s response looks like after our app is installed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_h5Ej3rc5_DH1Fd7dli8A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9YqEz2GFPJe7raT6u4iZPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zd0ZPiw6serQNZPzCfrhyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RxdY8AYcn91KVZajzh3rfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*78EELEQ4HDjIPdi6D3IIQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wEBSVoq1ADzl8zKp4biFfA.png" /></figure><p>The 2 most important pieces of information that we’ll use are the authed_user.id (to specify the channel for sending a message) and the access_token (the token to use to send the message to that user)</p><p>let’s review what we’ve accomplished like a boss:</p><ul><li>Created a server application that responds to GET messages</li><li>Created a website that has an “Add to Slack” button</li><li>Built an Oauth2 authentication process where we get from Slack a temporary authorization code and exchange it for an access token</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*fAgRKBU5SwqiPb6Bi0TasQ.gif" /></figure><h3>In the next (and final) part you will:</h3><ol><li>Create a new collection in Mongo DB to store user credentials</li><li>Using the website app, upon every app installation, store the user credentials in Mongo DB</li><li>Using the worker app and the for loop, set the app to go over all the user info and send them a message once a week</li></ol><h4><a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part6-245ae99dbca9?source=friends_link&amp;sk=d4686254e6ce89e63f0919736caf430d">Let’s go to part 6&gt;&gt;</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*Yi15yckj-Ca44-2Nx_LSpw.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=820fdb708cf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part6]]></title>
            <link>https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-part6-245ae99dbca9?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/245ae99dbca9</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Sat, 13 Nov 2021 10:52:57 GMT</pubDate>
            <atom:updated>2021-11-13T10:52:57.413Z</atom:updated>
            <content:encoded><![CDATA[<h3>Crash course on backend programming for Product Managers//Building a Slack app from scratch — Part 6</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TbpSgrFg7anXcYaqXG1Yxg.png" /></figure><p>OK, this is the last part <a href="https://medium.com/@maxim.bassin/crash-course-on-backend-programming-for-product-managers-building-a-slack-app-from-scratch-4fcff93da387">series</a> where we are actually going to finish this app and make it available for all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*ACS7xHoRjZLgBwn4yAzcPA.gif" /></figure><h3>In this final part you will:</h3><ol><li>Create a new collection in Mongo DB to store user credentials</li><li>Using the website app, upon every app installation, store the user credentials in Mongo DB</li><li>Using the worker app and the for loop, set the app to go over all the user info and send them a message once a week</li></ol><h3>Let’s finish this one!!</h3><h4>Push user data to a new collection in MongoDB</h4><p>(7 steps)</p><ol><li>Create a new collection in MongoDB named <em>users</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pWxOYzUkYzIgFd-68kGkcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qLY2ECQAi-lCdh-hDdgfCg.png" /></figure><p>2. Let’s install the npm package for MongoDB (to enable sending info to MongoDB). Enter the following line to the terminal in VSCode and click enter:</p><pre>npm install mongodb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*91M17AeyMk7jeDNadiXdCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otcOXYiL7iGJxjbRx9r1gg.png" /></figure><p>3. Copy the mongouri environment variable from Heroku’s slackappformedium to Heroku’s slackappwebsiteformedium to enable our service to connect to our database and place there the user information.</p><p>Go back to Heroku, choose the slackappformedium app, go to settings, and copy the value under the mongouri:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*43Lg85xpfYtmPNTRcF8HKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BbEGCT7WW8WOnU-JhL70Kw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UoXVmzz219C6RML8hzvn5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8xjPXTzaY4jpuiSju7jlzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4i0vmnOc2U2hgc__s7J9bA.png" /></figure><p>Now go to Heroku’s slackappwebsiteformedium, and create a new variable there named mongouri, with the value you’ve just copied:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ycu6YB_tp4MMVT252O-u0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RXYzk-c8L5u6d1q_dFS9aA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRjGNool6Zr7wHAdUItnrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZE13mVbexCNsPKyvvgkfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jEJMgnxqOPIcwP3qzqfQMw.png" /></figure><p>4. Add these lines to the top part of the code to include the MongoDB capabilities, and establish the service that will use the connection string to our database</p><pre>const MongoClient = require(&#39;mongodb&#39;).MongoClient<br>const mongouri = process.env.mongouri<br>const mongoclientinstance = new MongoClient(mongouri) </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bzNcTZgKqnzOo1JLdBm-TA.png" /></figure><p>5. Store the access token and the user ID, by adding the following lines right after we get the user data. The following code establishes a connection to the <em>slackapp</em> database, and then inserts one doc to the <em>users</em> collection</p><pre>MongoClient.connect(mongouri, {</pre><pre>useUnifiedTopology: true</pre><pre>}).then(mongoclientinstance =&gt; {</pre><pre>let userscollection = mongoclientinstance.db(&quot;slackapp&quot;).collection(&quot;users&quot;)</pre><pre>doc = {</pre><pre>authedUserId: result.data.authed_user.id,</pre><pre>access_token: result.data.access_token</pre><pre>}</pre><pre>userscollection.insertOne(doc)</pre><pre>})</pre><pre>.catch(error =&gt; console.error(error))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*asEYX4MeQJOus-fF4ie_ag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b3Y_dWKKb43h2a7mAP5IjQ.png" /></figure><p>6. Save the server.js file, commit and push</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nd19xdWEO7Jhv-xEskw9zw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ha2EjptED3nG4efYms8Crw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JRefrmWU-XpQIaJ0O5FG5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2NH5bVHIUzldDIDlVLigjg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6A9FxZ0CFCA1agJGgT3CIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q8laCO09UmAqMnGtGEOlyA.png" /></figure><p>7. Install the app again to see if our code indeed pushes the user info into MongoDB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OGZVLrZPIzPn0F2nyJRz3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fun803xUqk6fsIn9KC_QXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rNrz3nu36OZTRxLQDfSBIQ.png" /></figure><p>Hooray!</p><p>Now we’ll use that data in our Slack app. So once a week, the app will get the list of all user ids and their tokens, find the latest message to send, send it, and update the messages collection for the sent message and find the message that should be sent next.</p><h4>Retrieve user data from Mongo DB and send a message to each user</h4><p>(11 steps)</p><ol><li>In VSCode, open the app.js file in the SlackApp project</li></ol><p>2. Add this to the top part of the code:</p><pre>let users;// the users parameters will hold the user data</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QdK633AOt1OmJGOeDp-QJQ.png" /></figure><p>3. Add the following lines to the code right next to where we retrieve the jokes data from MongoDB, to retrieve the users into and store it under the <em>users </em>variable.</p><pre>//get users data</pre><pre>usersCollection = db.collection(&#39;users&#39;)// set the reference to the messages collection as messagesCollection</pre><pre>users=await usersCollection.find({}).toArray()// this line will find all the documents from the users collection and store each one as an object in an array</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*syvtGDQ5sZyZzvp7fraWew.png" /></figure><p>4. Since we will pull the user data from the database, let’s delete this hardcoded user data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nyol2SwBuFQCZUR11qf1gw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*83-GxJQ-LFMk0_rZySlzAw.png" /></figure><p>and define a slackclient array variable that we’ll use later</p><pre>let slackclient=[];</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1BI6ExHy9jA-wDaB-C5qHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ABdOzsoWMt5uIt9cH3uP_A.png" /></figure><p>5. Using the <em>for</em> loop, we’ll go over the entire users array, and for each user, send the message of the week. Let’s wrap the existing code for sending a message with a for loop. For each loop iteration (every user), we’ll create a new client with the user credential and id.</p><pre>for (let index=0; index&lt;users.length; index++){<br>   accessToken=users[index].access_token<br>   userid=users[index].authedUserId</pre><pre>   slackclient[index] = new WebClient(accessToken, {<br>     // LogLevel can be imported and used to make debugging simpler<br>     logLevel: LogLevel.DEBUG<br>   });<br>   // ID of the channel you want to send the message to<br>   channelId = userid</pre><pre>//THE EXISITNG CODE FOR SENDING A MESSAGE<br>    <br> </pre><pre> }<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o88UJYUMsEHaerTOo5VCWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k5CIjfWj6K7UlIi_reIyEw.png" /></figure><p>6. Change the <em>result</em> variable to be dynamic instead of constant, by makeing it the type of <em>let</em> instead of <em>const</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JeKsyuK4bD_BDX_P9thN5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BOdAQNPKX0ePjTAomoWv_A.png" /></figure><p>7. Change the <em>client</em> to <em>slackclient[index]</em> to hold the unique user data in each iteration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oakFAbflYhvm42Ejeubenw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ye-WnOmb1FtOJ56Jr57N1g.png" /></figure><p>8. In MongoDB, in <em>messages</em> collection, set all messages for <em>sent</em>: false, and mark the first one as <em>nextup</em>: true</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pVYdrvX8eApAMRTcARAEpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T6kLe4JqJjn3nYN_YlXhQw.png" /></figure><p>9. Set the cron job to run in 5 minutes from now. In my case it’s Saturday, 20:50: UTC time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lRB4W-90t1zPIICV80GQeA.png" /></figure><p>10. Save the app.js file, commit and push</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oAz1TaiZrBSZKCEQbXpo-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2aNHYuMLrsbaYZ2__Jpgqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-QVt61gvgPIfncWszSw50w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kFiMRaNejnANYVOS3-Ry3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1WQD_jyhUjvC-t6-e57pHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F_Jj4TEd-AA40FV1GU2mEA.png" /></figure><p>Got the message? AWESOME! That means that we successfully pulled the user info from MongoDB, and we’re ready for the masses.</p><p>11. Now, it would be a good idea to adjust the cron job timing, to pick the suitable day in the week and the time (remember the server time is UTC timezone) to send your weekly messages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lRB4W-90t1zPIICV80GQeA.png" /></figure><p>(Don’t forget to save the file, commit and push for every change)</p><p>Your app is now ready to be installed by others, and they all will get the weekly messages. Just don’t forget to always have enough messages in Mongo DB ahead.</p><p>Use the website link to share with the users. You can get it by entering the website app in Heroku and clicking “Open app”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kBNQ9xW-J8_VC714l0VFlQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qSWclBg5yfe2UE0e0ZKMbg.png" /></figure><h3>AND WE’RE DONE!</h3><h4>Easy peasy:)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*18Otjd7eDq0Bduq75ufBCA.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=245ae99dbca9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running A Successful Product Workshop, Utilizing “Design Sprint” Principles]]></title>
            <link>https://medium.com/@maxim.bassin/successful-product-workshop-utilizing-design-sprint-principles-1ab7e63ed424?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ab7e63ed424</guid>
            <category><![CDATA[meetings]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[design-sprint]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Tue, 28 Jan 2020 20:38:30 GMT</pubDate>
            <atom:updated>2020-01-28T20:38:30.144Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.youtube.com/watch?v=08IPOsrytz4">“Design Sprint”</a> is great for starting big projects, here is a practical guide on how it can be utilized in a half-day workshop to jump-start a new feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TvDyP0s1XbaHdWl3" /><figcaption>“I hope it’s not a permanent marker”</figcaption></figure><p>So there I was, 3 weeks into my new position as a product manager in a SaaS startup, and my director of product told me: “Hey Max, we have our roadmap vision presentation in 3 weeks and we need to figure out what we are planning for feature X next quarter. You should schedule a half-day workshop for the team”. It was exciting to lead my own feature from the beginning. I’ve scheduled the meeting for the next week and got down to work. My goal was to plan a productive 4.5 hours workshop for 6 people that will not cause everyone to kill themselves after 2 hours (3 Product Managers, 1 product director, 1 designer, and 1 developers’ team lead).</p><h3>Framing the workshop concept</h3><p>First thing first, I’ve refined the workshop high-level goal: “Formulate the product vision for the feature, define the MVP concept and create enough clarity to allow rough effort estimation for roadmap planning”. Once I was clear on the goal, I’ve got to define the method. In a previous company I was hosting a Design Sprint, that changed my perception of group meetings, and I knew that I’ll have to follow the same principles in my workshop (more on DIY hosting of Design Sprint can be found in my previous article: <a href="https://medium.com/swlh/a-diy-design-sprint-notes-from-a-first-time-facilitator-6e0c310469d3">A DIY Design Sprint — notes from a first-time facilitator</a>). The core principles that I’ve set for the workshop were:</p><ol><li>Everyone should have the same starting point (user needs, opportunity, competitive solutions)</li><li>No more than 20 minutes for a group task/activity</li><li>No open-ended group discussions — first we think, then formulate our thoughts, then present them on paper with everyone else, vote, and only then discuss — no egos, no time waste</li></ol><h3>Workshop preparations</h3><p>Now I had to plan the way to align the team on the needs, opportunities, and competition before the meeting. I’ve decided that the best thing to do was to have 2 short meetings (25 minutes each) with everybody BEFORE the workshop:</p><ol><li>Meeting 1: Sharing the user voice and common use cases</li><li>Meeting 2: Share inspiration from similar products</li></ol><p>The main guideline for those meetings was pure knowledge sharing sessions and not discussions. The reason to have those meetings before the workshop is to allow everyone to “sleep on it”, digesting the new information and formulate their own take on the subject, before the workshop.</p><p>I’ve headed to bridge my knowledge gap on the subject. I’ve collected all the feedback related to the feature and references from products with similar functionality. The first meeting was a bit challenging since it’s hard to keep a bunch of product people to focus on listening, and not discussing. Luckily, with my <a href="https://medium.com/swlh/a-diy-design-sprint-notes-from-a-first-time-facilitator-6e0c310469d3">Design Sprint hosting</a> experience, I was able to cut the unnecessary discussions and to pass the entire meeting scope in only 25 minutes. For the references meeting, I asked everyone to prepare 2–3 examples that they found useful from similar products, to share at the meeting. The meeting went great, and although not everyone had the time to prepare, we had a good spectrum of references to kick off our creativity.</p><p>After the meeting on references, the designer and the development team lead told me that the meetings got their creative juices flowing and each of them had a whole bunch of ideas on how we could tackle the feature — that was the perfect state of mind for the workshop that was happening in few days.</p><h3>Workshop planning</h3><p>For the planning of the workshop itself, I’ve used some of the concepts from the Design Sprint to make it as much efficient as possible. The final agenda for the meeting was:</p><p><strong>14:30–14:45 (15 min) — Workshop intro and setup</strong></p><p><strong>14:45–15:25 (40 min) — Vision formulation</strong></p><ul><li>(5 min) User’s voice</li><li>(15 min) Main use-cases and pain points</li><li>(5 min) Individual vision formulation (“In 2 years time…”)</li><li>(15 min) Presentation and discussion + decision</li></ul><p><strong>15:25–15:55 (30 min) — High-level product architecture</strong></p><ul><li>(5 min) Presenting baseline scope to start with</li><li>(10 min) Adding missing parts and concerns (individual work)</li><li>(15 min) Discussion + decision</li></ul><p><em>15:55–16:05 (10 min) — Break</em></p><p><strong>16:05–16:55 (50 min) — High-level UX concept</strong></p><ul><li>(20 min) Map</li><li>(5 min) References recap</li><li>(15 min) Sketch</li><li>(10 min) Discussion and voting</li></ul><p><em>16:55–17:10 (15 min) — Break</em></p><p><strong>17:10–17:55 (45 min) — MVP</strong></p><ul><li>(15 min) Choosing the high impact/low effort case</li><li>(10 min) Mapping the user flows</li><li>(20 min) Addressing the user flows</li></ul><p><strong>17:55–18:10 (15 min) — Summary and Action items</strong></p><p>With the plan above, I was aiming to set the product vision, have a product architecture, a high-level UX concept, and a clear MVP.</p><h3>The day of the workshop</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-3NlDIeOuwy1B7I4" /><figcaption>Trying to figure out everyone’s handwriting</figcaption></figure><p>In the morning of the workshop, I’ve personally talked with everyone on the team, to make sure that they aware of the workshop and I need them there on time, fully minded to the meeting — no phones, no laptops.</p><p>A few minutes before the meeting I’ve printed out the meeting schedule for everyone. I’ve washed some fresh fruits and put them in the meeting room, along with a few soda bottles and glasses, making sure that everyone has everything they need to stay focused and productive. I brought a pile of sticky notes, A4 sheets, adhesive tape, sharpies, and pens. We were ready to rock!</p><p>I’ve started off by aligning everyone that we are going to move fast and that I was going to cut some discussions, but we will achieve great progress.</p><p>The meeting went great. For some items, we weren’t able to achieve the exact planned outcome, but thanks to the workshop, we were able to progress and collaboratively come up with great ideas that brought the feature into a very clear shape that everyone was aligned on. Based on everyone’s feedback after the meeting, it was a great team experience that everyone felt involved and was amazed by the progress we’ve achieved.</p><h3>Key takeaways from the process</h3><ol><li>Aligning everyone to the same baseline of knowledge prior to the workshop turned out to be super effective</li><li>Having a strictly constructed short meetings for knowledge sharing are very much achievable and productive, and can fit into almost everyone’s calendar in a short notice</li><li>Time constraint is a great tool for making decisions</li><li>A strict workshop schedule should be taken as a guideline — as a workshop host, you have the power to bend or change the schedule based on the reality of discussions and insights during the meeting (after all, that’s us being agile)</li><li>Not every workshop goal must be achieved during the workshop, as long as you got to the point where you have all the data to complete it offline</li></ol><p>I encourage you to question the current methods of conducting ideation meetings and to bring a fresh spirit of innovation into your organization as well🤘</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ab7e63ed424" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Acing the Product Manager home assignment]]></title>
            <link>https://medium.com/@maxim.bassin/acing-the-product-manager-home-assignment-c3ecb2fc93fa?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3ecb2fc93fa</guid>
            <category><![CDATA[new-product-manager]]></category>
            <category><![CDATA[home-assignment]]></category>
            <category><![CDATA[job-hunting]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Sat, 19 Oct 2019 21:10:59 GMT</pubDate>
            <atom:updated>2019-10-20T18:38:48.006Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*xKFayo_3QOsWB4V-" /></figure><p>Home assignments became very popular in the PM interview process. Although they are a bit controversial, they are still widely used by big and small companies. Just as your frontal interview, home assignments should be taken seriously, and you should be well prepared.</p><p>Whenever given a home assignment for a PM position, you should consider it as an opportunity to show off your fundamental skills as a PM and also show off your unique edge in the field.</p><p>After excelling in 8 home assignments in 8 weeks during my last job hunt round, here are some basic principles for passing them (also a few tips and tricks as well).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*oYLPBSUFsGEi3h_YzptkEQ.gif" /></figure><h4>1. The goal of the assignment is not to get to the answer, but to get to that next interview.</h4><p>If you only get to the answer without showing off your unique skills you will probably not stand out from the crowd of applicants. As in a regular interview, list the things you want to highlight, and add them to the assignment (e.g. I want to show my unique business strategy thinking/I want to highlight my user research skills…).</p><p><strong><em>*TIP* </em></strong><em>Always cover a bit more than what you were asked to do. For example, if asked to list 3 ideas, suggest shortly another wildcard idea showing your out-of-the-box thinking. Or for example, if asked to plan the next quarter, add a few words about your vision for the next of the year.</em></p><h4>2. It’s all about sharing the process</h4><p>When you get to describe your answer, focus on the process that got you there. Recruiters want to understand the way you think, how you prioritize and how do you make decisions. In most cases, there is no 1 right answer, what actually matters is the way you think about the challenges and how you make decisions.</p><p><strong><em>*TIP*</em></strong><em> Interview real users. For the part where you share your research, distinguish yourself by qualitative research insights from real users. It could be your friends and family, past co-workers or some online survey — as long as they are in the target group of the product. Insights from 5–8 people would be a great input to your assignment. When adding them to the slides, use their pictures, names and classification data to make it more personal.</em></p><h4>3. Assume at will</h4><p>There would be times when there is certain uncertainty in the assignment, that will bring confusion. Instead of asking for clarification or guidance, make an assumption.</p><p><strong><em>*TIP*</em></strong><em> Don’t take the easy or the hard road with the assumption. Take the middle ground and don’t forget to elaborate on the assumption and the reasoning behind it</em></p><h4>4. Emailing vs Presenting — mind the format</h4><p>For the email submission of the assignment, add all the explanations inside the presentation. For frontal presentation, keep your slides light and add the explanations verbally. Sometimes it would be the combination of both (they will review the emailed assignment and then will ask you to come and present it frontally), in that case, send the presentation with the inline explanations over email, and when called to present it on-site, modify it for frontal presentation.</p><p><strong><em>*TIP*</em></strong><em> For the presentation itself use Google Slides for easy sharing. When emailing the assignment, use link tracking services like </em><a href="https://bitly.com/"><em>bit.ly</em></a><em> to shorten the presentation sharing link, so you would be able to track when and how many times your presentation was viewed.</em></p><h4>5. Mind the time</h4><p>Usually, the company giving the assignment will evaluate the effort for completion in a range of 2–6 hours. It&#39;s OK to take a bit more time if needed, but don’t over do it. The result should be at a level matching the time allocated for the assignment. If you will present a very detailed assignment, it will clearly show that you spent more time than they requested.</p><p><strong><em>*TIP*</em></strong><em> There will be cases when you’d be asked to give your estimation on when you are planning to complete the </em>assignment<em>. I’d suggest to give it at least 3 days, so you’d have time to do quick research, soak in the data overnight, complete the </em>assignment<em>, and on the last day to review and correct it with a fresh perspective.</em></p><h3>Now that we got our principles in place, let’s dive into the practice of acing the home assignment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*koepuTAsZKSaLtthErY-hQ.gif" /></figure><p>Most of the PM home assignments have a pretty similar format. It is usually about defining a product or a feature for a certain market or opportunity with certain constraints, and the best way to approach it is to <strong>systematically </strong>get to the solution</p><p>The general format for the assignment that will do the job will look similar to this:</p><h4>1. Problem definition/Rephrasing</h4><p>It helps clarify the aspect of your solution/ align everyone on the problem statement. It also helps people who will review your assignment to know what was the problem statement (not every PM in the company that checks the assignments is up to date with the current assignments, and it will save them time to look for the assignment definition)</p><p>🤓<strong><em>SHOW OFF</em></strong> your ability to clearly convey a concept</p><h4>2. Research</h4><p>Go online, open about 20 relevant tabs to explore the topic (research studies, statistics, product reviews, competitive analysis, etc.) Find 5–8 people among your friends and colleagues to talk with about the subject. Prepare 3–4 questions to cover segmentation and insights.</p><p>🤓<strong><em>SHOW OFF</em></strong> your ability to ask the right questions</p><h4>3. Insights</h4><p>Share what you got from the research. Whenever the conclusion is not certain, use non-absolute adjectives, such as “probably”, “looks like”, and so on. Remember, if 5 out of 6 people you’ve interviewed like A more than B, it doesn’t mean that it correlates with the user base. The interviews should give you only qualitative data and ideas to consider.</p><p>🤓<strong><em>SHOW OFF </em></strong>your ability to understand the real user problems and business opportunities</p><h4>4. Product/feature options and their evaluations</h4><p>List the features/product options and then present them in a prioritized manner. Use any method that you feel comfortable with. You can use options from <a href="https://www.productplan.com/strategies-prioritize-product-features/">here</a> or <a href="https://www.intercom.com/blog/rice-simple-prioritization-for-product-managers/">here</a>. I personally use a scoring table with value, effort and business strategy affinity as scoring parameters.</p><p>🤓<strong><em>SHOW OFF</em></strong> your concluding skills, creativity, and analytical mind</p><h4>5. Chosen solution</h4><p>Finally, you would have to make a decision and pick the right solution. Usually, it will not be as a simple equation solution as you would wish, but the decision should be taken either way. Add your train of thought that guided you to the decision — it&#39;s one of the most important parts of the assignment.</p><p>🤓<strong><em>SHOW OFF </em></strong>your ability to make a decision within uncertainty, and cold cut to an MVP of a solution</p><h4>6. Elaborating on how the solution should work</h4><p>Usually, you’d be asked to provide a wireframe or two for the chosen solution. The best approach here would be to start with a block diagram of the user flow within your solution — no need to cover all the edge cases at this point. This stage is good for giving the context to your wireframe. For the wireframe, elaborate on the reasoning of the main elements&#39; existence and positioning. Remember that no one looks at your ability to draw a wireframe, but rather on your UX skills and the user-centric perspective.</p><p>🤓<strong><em>SHOW OFF</em></strong> your UX skills, and your user-centric way of thinking, while keeping the business goals in mind</p><h4>* Your extra addition to the basic assignment</h4><p>Add something beyond what was asked — you need to stand out from the rest, and this is your opportunity. For example, briefly describe the strategic path that should be considered after a positive impact of the chosen solution MVP.</p><p>🤓<strong><em>SHOW OFF </em></strong>your strategic thinking, <a href="https://www.ted.com/talks/simon_sinek_how_great_leaders_inspire_action?language=en">understanding the bigger picture</a>, beyond the specific problem. No feature stands on its own.</p><p>Following a <a href="http://thepmnotebook.com/">good structure</a> is a great recipe to nail your next job opportunity and to kick ass as an awesome Product Manager.</p><p><strong>Good luck with your job hunt!</strong>🦄</p><h3><strong>PS</strong></h3><p>If you are looking to get yourself the best gift for Product Managers, you can use the code “pmfriends” to get 20% off on this <a href="http://thepmnotebook.com/">PM playbook</a>. It got you covered with everyday PM tips, spot-on templates, smoothest note-taking, and awesomeness: <a href="http://thepmnotebook.com/">http://thepmnotebook.com</a></p><p>❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3ecb2fc93fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A DIY Design Sprint — notes from a first-time facilitator]]></title>
            <link>https://medium.com/swlh/a-diy-design-sprint-notes-from-a-first-time-facilitator-6e0c310469d3?source=rss-8a5f04f51ad1------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e0c310469d3</guid>
            <category><![CDATA[design-sprint-facilitator]]></category>
            <category><![CDATA[design-sprint]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Maxim Bassin]]></dc:creator>
            <pubDate>Sun, 02 Jun 2019 07:36:15 GMT</pubDate>
            <atom:updated>2019-06-03T09:51:02.521Z</atom:updated>
            <content:encoded><![CDATA[<h3>A DIY Design Sprint — notes from a first-time facilitator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*434_KPFtp06lREDf" /><figcaption>“- Look, a dot! -Yes, I see it now!”</figcaption></figure><p><em>TL;DR — with good preparation, it’s totally possible to facilitate a </em><a href="https://www.youtube.com/watch?v=K2vSQPh6MCE"><em>Design Sprint</em></a><em> on your own. And it can even improve your daily team interactions as well. Tips and tricks are below.</em></p><p>Being a Product Manager for the last decade, I’ve led many initiatives, and the most crucial part was to start them. No matter what the company was, or how the teams were structured, it always took an endless amount of meetings, brainstorming, research, and resources to decide what to do and how to execute it. When I stumbled upon Design Sprint concept, it was clear to me that its the way to actually get things moving fast.</p><p>I’ve suggested to our product team to facilitate a Design Sprint for one of the other squads in the company, and we all decided to give it a go. Here is what happened:</p><p>I’ve dived into the videos from <a href="https://www.gv.com/sprint/">Google Ventures </a>about the design sprint, to be able to speak about it with the team. I’ve read also few posts by Design sprint first-timers, and finally got to the videos by <a href="https://www.youtube.com/watch?v=Z8MOwcqZuuU&amp;list=PLxk9zj3EDi0X5CgoFckoheIFAx-uT2i7j">AJ&amp;Smart</a> about the Design Sprint 2.0. I’ve decided to go with the AJ&amp;Smart version of the sprint to keep things simple.</p><p>Our first internal kickoff meeting was about setting expectations, deciding on roles and responsibilities and setting the action items until the beginning of the sprint. I held a meeting with the Product manager from the squad that is planning to kick off the project, and the Director of Product. The major outcomes of the meeting were:</p><ol><li>The sprint will take place in one of the unused spaces in the office, that is pretty isolated from the rest of the office</li><li>The Sprint core team will be the entire squad (1 PM, 1 Designer, a technical team leader, 1 FE developer and 1 BE developer), Customer success manager, Director of Product and VP Product.</li><li>The Product Manager of the squad will be responsible for bringing the experts and setting the meetings with clients (we are a B2B SaaS platform, so all the meetings should be scheduled few weeks ahead of time)</li><li>The Product Manager of the squad together with the Product Director will come up with the question for the sprint. (I’ve shared with them some examples from <a href="https://designsprint.academy/email/facilitation-guide.pdf">DESIGN SPRINT MASTER Facilitator’s Guide</a>)</li><li>The decider’s hierarchy will be in the following order: VP Product, Director of Product, and then the Product Manager (so it will be clear who is the decider at all times since the VP Product might not be there all the time)</li><li>I will be responsible for sharing the day-to-day schedule (I used<a href="https://app.sessionlab.com/sessions/i6u1t0/print?t=VXkwNwjDa7H8hvloiZ3u-g"> this template</a> for scheduling — I’ve also printed it and had it as my guide for the day-to-day of the sprint), marking key meetings for experts and external stakeholders to participate. Also, I will take care of food and supplies logistics</li></ol><h3>Day 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*84qruvpXMlsB-hLd" /><figcaption>HMW notes</figcaption></figure><p>We’ve started off in our conference room, next to the design sprint area. We’ve gathered the sprint team and a few of our key developers. I’ve explained about the sprint and the HMW note taking. The most wakening part was the explanation of how to tear off a post-it note (from a side, not the bottom), which woke up most of the sprint participants and broke the morning ice. We’ve synced on different aspects of the main subject. During the meeting, I had to remind the participants several times to write down the HMW notes since most of them didn’t. At some point, I’ve started to take down notes myself, just to make sure we had enough for the next exercise. Turned out it was a good bet since my notes were about 40% of total notes taken. We moved on to the dedicates sprint area, without the guest experts. During the HMW notes categorization, I’ve added a bit more stickers for everyone just to get enough variance on the notes vote. The exercises went by the book until we got to the “Map” exercise. The team found it hard to understand what kind of scenarios should be mapped: “Should we map the first scenarios we should tackle right after the sprint?”, “Should we map the scenarios for the state of 2 years from now?”. I suggested the team to focus on 4–5 major scenarios to be tackled right after the sprint. As for choosing the scenario to focus on for the rest of the sprint, I told the team to choose the most tricky scenario that they don’t have a straight forward solution to.</p><p>When we got to the Ideas exercise, some people thought that only one idea was expected, so it&#39;s a good thing to emphasize that 2–3 ideas are expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QsstcPk60g9kowg0" /><figcaption>Ideas exercise</figcaption></figure><p>When we got to “Crazy 8s” exercise, only half of the team actually managed to create more than 2 different variations, that didn’t interfere with the energy level that stayed high. During the exercise, one of the team members had to go home early, so I’ve asked him to complete the solution sketch at home, as homework. We finished the day with everyone hanging their solution sketch on the wall.</p><h3>Day 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gkop1mqTol63-2lq" /><figcaption>Heat Map Vote results</figcaption></figure><p>During the Heat Map Vote exercise, I’ve put the post-its and sharpies into everyone’s hand to encourage them to add questions to the sketches. When I’ve started to present the ideas (Speed Critique), it was too hard to convey the right message, so we switched to everyone presenting their own idea. During the Straw Poll Vote, I had to clarify that the voting sticker should be put on the post-it, to visually connect between the dot and the explanation for the vote. During the exercise, there were several guests, including the CEO, that took part in voting. When we got to Supervote, we’ve skipped the sticker ceremony and let the VP Product decide on the winning solution, which based one of the ideas, and another 2 key elements from other 2 ideas. Storyboarding exercise is where the sprint became a bit tricky. Since its a 90 minutes exercise that for the first time had a group discussion it felt very different from the rest. VP Product and the Director of Product were off to their meetings, so we had a bit less driving power. We were stuck too much on each step and at some point, we got lost. Everyone was exhausted and we decided that tomorrow morning we will finalize the Storyboard.</p><h3>Day 3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sU7A3bgzr2Kj9tjX" /><figcaption>Finished Storyboard</figcaption></figure><p>We picked up from where we finished the day before. When the discussion was starting to repeat itself without progress, I’ve decided to cut it. I told everyone to sketch their own idea to the sub-flow we were discussing and put it on the wall (I also added mine as well). Everyone presented their concept. I gave everybody 1 sticker to vote. Everyone put their sticker and explained their choice. I told the Product Manager (who was the decider at the time) to decide, and we’ve moved on — it was very liberating and got us our sprint mojo back. The designer had the entire flow to work with, we’ve left him alone to start designing. The developers got to their other tasks, Product Manager was preparing the interview, Customer Success Manager and I got back to our own day-to-day. At about 3 PM, we gathered to review the progress so far. Everyone gave their feedback and we made a decision on how it should be wrapped. Since the interviews that were scheduled were starting from the evening of the 4th day, we had time to do several runs of refinement.</p><h3>Day 4</h3><p>In the morning we had a meeting with the CEO to show the outcome of the progress (CEO was part of several exercises during the sprint, so he was aware of our general direction). We had it as a user interview and it was a great usability practice that added valuable inputs to refine the prototype. The first 2 interviews were happening during that day, and they were very insightful. The other interviews were scheduled during the rest of the week and the week after.</p><h3>The retrospective meeting</h3><p>On the 5th day, we had a retrospective meeting with all the participants, where we have shared our thoughts on the process and suggestions for future improvements. The key takeaways were:</p><ul><li>“We probably saved over a month of work”</li><li>“Sometimes the process seemed awkward, but it worked”</li><li>“We have to stick with short timeframes, long exercises are less effective”</li><li>“It is very important to have the core team dedicated to the entire process of the sprint, without going to any other meetings”</li></ul><h3>Conclusion and lessons learned:</h3><ul><li>The Design Sprint is a great tool to jumpstart a project, getting everyone into the “business” state of mind (even the developers) and bonding the team</li><li>The Design Sprint is definitely something that you can do on your own, with the proper preparation</li><li>Keeping track of the time, and getting the conversations rolling is a very demanding task</li><li>One of the most important roles of the facilitator is to keep the ball rolling. Don’t be shy to cut a pointless/repeating discussion and ask the decider to pick a direction to move on</li><li>Group discussions (brainstorms) are far less effective than when everyone makes their decision individually based on the shared information, presenting their point and having a decider to continue</li></ul><p>As a Product Manager facilitating a design sprint, I gained a great set of tools for optimizing group meetings and discussions for my day-to-day. It’s only when you experience it for yourself, you understand how powerful and effective those methods are.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e0c310469d3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/a-diy-design-sprint-notes-from-a-first-time-facilitator-6e0c310469d3">A DIY Design Sprint — notes from a first-time facilitator</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>