DEV Community

Cover image for Slack bot for slack channel and Harvest Forecast App

Slack bot for slack channel and Harvest Forecast App

indirajeldi profile image indiraJeldi ・Updated on ・4 min read

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.

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.

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.

Now, let's jump into the prerequisites to develop slack bot.

  1. Slack account
  2. Forecast account
  3. NodeJs

Note: If you don't have slack account, you can download. Set up your account and create a workspace.

1. Creating slack Channel, slack App and configuration:

Step1: 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.
Alt Text

On click you will get a drop down
Alt Text
click on "create channel", give name and description as desire for your channel.

Step2: 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.

Let's see how to build a slack bot, we have slack-api 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.

Go to creating slack app url and scroll down to creating and managing slack app section.

Alt Text

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.

Alt Text

Step3: 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.

Alt Text

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.

Alt Text

Now, enable the webhooks and you can see some curl script down the page once it finishes reload.

Go back to Basic Information by clicking on the menu in left panel, where you will see "Basic Information" Page.

Alt Text

As we enable the Incoming webhooks, we see "Bots" and "Permissions" are been enabled in the image below.

Alt Text

Now, click on Bots and it redirects to "App Home", enable Bot to show as online always.

Alt Text

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.

Alt Text

Now, Check your slack app, you can see the slack bot that was created for slack channel under Apps Section,

Alt Text

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&Permissions page , you can also navigate to this page from the left panel under Features.
Alt Text or Alt Text

In OAuth&Permissions section we need to enable permissions under Scopes, We have here two types of Scopes:

1.Bot token scopes: select app_mentions:read which enables to view messages directly mention @AppName in conversation that App in

Alt Text

2.User Token Scopes: select channels:write option which manages a user's public channels and create new ones on a user's behalf.

Alt Text

For now, we are done with the setting up slack bot.

Note: Please check the next post for configuring Harvest Forecast App


Editor guide