Create a Slack Bot

Written By Chetan Iterate (Administrator)

Updated at January 5th, 2021

Slack is a very good conversation platform for developers and professionals alike, as other messaging platform slack also provides functionality to deploy the chatbot like Facebook messenger. In this example, we will create an HR Handbook project.

Prerequisites:

1) You should have a slack developer account and the bot Token and credential to parse flow messages to bot: create a 'slack bot'

2) Save its credentials such as

  • Bot name
  • Bot Token
  • Bot Oauth Token : (In case of parsing Multimedia files)

Which are important in later stages.


Steps

1 ) Drag the slack nodes 'Slack in' and 'Slack out' which are like this:

double click 'slack in' to edit its properties

Click on next to 'Bot Configuration (Development)'

to edit important configurations such as 

A similar process is to be followed for 'Slack out' Node.

Upon successful connection, the nodes would tag themselves like this

The 'connected' Tag signifies it can get data from the bot handle.

2) Drag the Function node and write a simple node.js code as follows

Here we are only switching the content based on payload.

3) Search and drag 'Switch' node and for this example, we are setting its properties like this (These are only arithmetic comparisons based on input payload value).4) Drag the 2 nodes of 'function' specifically for Welcome and for Farewell messages and for this example these are the examples:

Welcome message:


For Farewell:

 5) For 3rd flow, we are using the combination of subflows for the NLP engine.

(for creating subflows refer: Creating subflows)

Initial pre-processing:

NLP1:

6) Until now we routed the NLP engine and added the query. again search and drop ''Function" modify them as below:

HR FAQ (HTTP Request for finding first entry parsed to NLP)

Get First Pick: it essentially captures the HTTP response from NLP engine and injects into the next 'Text' Node to encapsulate data into Parsable Slack Bot Response.


7 ) Find and select 'Text' Which looks like This (Exists in Redbot Section).

And drop in editor.

8) Connect and verify nodes are connected like this figure:

9) Click on Deploy and see your Slack Bot Answering HR personnel's first pick!



Was this article helpful?