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.
- Slack account
- Forecast account
Note: If you don't have slack account, you can download. Set up your account and create a workspace.
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.
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.
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.
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.
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.
As we enable the Incoming webhooks, we see "Bots" and "Permissions" are been enabled in the image below.
Now, click on Bots and it redirects to "App Home", enable Bot to show as online always.
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.
Now, Check your slack app, you can see the slack bot that was created for slack channel under Apps Section,
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.
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
2.User Token Scopes: select channels:write option which manages a user's public channels and create new ones on a user's behalf.
For now, we are done with the setting up slack bot.
Note: Please check the next post for configuring Harvest Forecast App