<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: indiraJeldi</title>
    <description>The latest articles on DEV Community by indiraJeldi (@indirajeldi).</description>
    <link>https://dev.to/indirajeldi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F425034%2F8e9aa602-b06a-4bf8-826d-4bcb4301035f.png</url>
      <title>DEV Community: indiraJeldi</title>
      <link>https://dev.to/indirajeldi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/indirajeldi"/>
    <language>en</language>
    <item>
      <title>Slack bot for slack channel and Harvest Forecast App</title>
      <dc:creator>indiraJeldi</dc:creator>
      <pubDate>Wed, 14 Oct 2020 13:25:52 +0000</pubDate>
      <link>https://dev.to/indirajeldi/slack-bot-for-slack-channel-from-forecast-3dhc</link>
      <guid>https://dev.to/indirajeldi/slack-bot-for-slack-channel-from-forecast-3dhc</guid>
      <description>&lt;p&gt;Purpose of this project is to fetch the details from the Harvest Forecast app and automate the details to sales and consulting teams to see who are allocated to which project before making daily call. It helps to include only to whom the allocation is necessary which reduces the call time and use the time and resources effectively.&lt;/p&gt;

&lt;p&gt;Creating a slack bot for a slack channel using the harvest forecast app. Before getting into the details of creating slack bot would like to give a foreground about the harvest forecast app.&lt;/p&gt;

&lt;p&gt;Harvest Forecast app can be accessed using forecast-api which is an npm package. To get desired results as per requirement we need to understand that Harvest Forecast is like a database with tables. Will show you later how to make changes to the forecast-api and embed in the docker before creating your docker image if you are using docker.&lt;/p&gt;

&lt;p&gt;Now, let's jump into the prerequisites to develop slack bot.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Slack account &lt;/li&gt;
&lt;li&gt;Forecast account&lt;/li&gt;
&lt;li&gt;NodeJs&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: If you don't have slack account, you can &lt;a href="https://slack.com/intl/en-de/downloads/mac?geocode=en-de"&gt;download&lt;/a&gt;. Set up your account and create a workspace.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. Creating slack  Channel, slack App  and configuration&lt;/strong&gt;:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step1&lt;/strong&gt;: Once you have a slack workspace, now let's create a slack channel. In your slack workspace click on "+" icon next to channels as shown in the image below.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7QTV0opk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mpbrziht4eizc7kbd8xj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7QTV0opk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mpbrziht4eizc7kbd8xj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On click you will get a drop down &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yuDGk_nq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/49nq19ek4oxtvlsg5831.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yuDGk_nq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/49nq19ek4oxtvlsg5831.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
click on "create channel", give name and description as desire for your channel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step2&lt;/strong&gt;: Now, as you have a dedicated channel, let's create a slack bot to communicate with the external api and push data into slack channel.&lt;/p&gt;

&lt;p&gt;Let's see how to build a slack bot, we have &lt;a href="https://api.slack.com"&gt;slack-api&lt;/a&gt; for slack to do different integrations and apps to build. There is lot of  scope and information to dive in, let me help you with building slack bot easily.&lt;/p&gt;

&lt;p&gt;Go to &lt;a href="https://api.slack.com/start/overview#creating"&gt;creating slack app url&lt;/a&gt; and scroll down to creating and managing slack app section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--weK7zpJY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kqwy4kwwe5034rcc41b1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--weK7zpJY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kqwy4kwwe5034rcc41b1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On click green button "Create a Slack app" you will be redirected to pop up as shown in the image below, Fill in your desired App name and select the workspace name where you have created the slack channel in step1.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qMnpk-zK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nj7pkl53v5a4x20hvlmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qMnpk-zK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nj7pkl53v5a4x20hvlmp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step3&lt;/strong&gt;: Now, You need to configure your slack app by adding features and functionality. Once you create slack app, you will be redirected to page with "Basic Information" which has many sections.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0FKQ4HuF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ph6xvj314wxuei5mi524.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0FKQ4HuF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ph6xvj314wxuei5mi524.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For forecast data communication to slack, we need to allow the external sources into the slack, hence enable the webhooks. click on "Incoming Webhooks" and you will be redirected to page as show below. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8yoZLEW8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jbw65lgl6hj59yo2dsrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8yoZLEW8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jbw65lgl6hj59yo2dsrx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, enable the webhooks and you can see  some curl script down the page once it finishes reload.&lt;/p&gt;

&lt;p&gt;Go back to Basic Information by clicking on the menu in left panel, where you will see "Basic Information" Page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XqiqpHoG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0q8ra4zwgm3jiunr3s2t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XqiqpHoG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0q8ra4zwgm3jiunr3s2t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we enable the &lt;em&gt;Incoming webhooks&lt;/em&gt;, we see "Bots" and "Permissions" are been enabled in the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--abUYY5dN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0lmrwd0ht2n9rtr1lpko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--abUYY5dN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0lmrwd0ht2n9rtr1lpko.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, click on Bots and it redirects to "App Home", enable Bot to show as online always. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vbqLFQ6G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4n2m7gptupdv0az66xkk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vbqLFQ6G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4n2m7gptupdv0az66xkk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then, In "Basic Information" page you will see  next section  "Install App in your workspace", click on it and select the dedicated channel that was created in Step1.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4HayLRcA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dw74zwc0bnpykttn3g1m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4HayLRcA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dw74zwc0bnpykttn3g1m.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, Check your slack app, you can see the slack bot that was created for slack channel under Apps Section,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RyUfTWmF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hjiqltb6jix5hoc8rtg7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RyUfTWmF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hjiqltb6jix5hoc8rtg7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, We need to add the scope of the slackApp, In "Basic Information" page  under  Add  features and functionality we have "Permissions", On click it redirects to OAuth&amp;amp;Permissions page , you can also navigate to this page from the left panel under Features.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eLKUPJhu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n3lcqr99587dc1j42lgd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eLKUPJhu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n3lcqr99587dc1j42lgd.png" alt="Alt Text"&gt;&lt;/a&gt; or &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uCd_gt6t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0dsjqhws2h961n6fvfq6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uCd_gt6t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0dsjqhws2h961n6fvfq6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In OAuth&amp;amp;Permissions  section we need to enable permissions under Scopes, We have here  two types of Scopes:&lt;/p&gt;

&lt;p&gt;1.Bot token scopes:  select app_mentions:read which enables to view messages directly mention  @AppName in conversation that App in &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Kqi14Qv3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/28zrq4nx8802lidm37co.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Kqi14Qv3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/28zrq4nx8802lidm37co.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.User Token Scopes: select channels:write option which manages a user's public channels and create new ones on a user's behalf.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K_lkpKgA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9i7orritgv7ehddic14d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K_lkpKgA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9i7orritgv7ehddic14d.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For now,  we  are done with the setting up slack bot.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;:  Please check the next post for configuring Harvest Forecast  App&lt;/p&gt;

</description>
      <category>slack</category>
      <category>forecast</category>
      <category>node</category>
      <category>harvest</category>
    </item>
  </channel>
</rss>
