Build a Customer Help Bot for Slack with WayScript
Tags: startup, wayscript, tutorial, serverless
Published: 2020-10-28 13:03:50

Introduction
------------

Bots today are an essential part of Customer help services. With services used by millions of people, it’s difficult for Customer service people to handle all the problems addressed to them. Bots can be easily built and integrated into any services if you are using the Wayscript Platform. So today, we are going to build a Customer help Bot for Slack.

Prerequisites
-------------

No prerequisites for this tutorial. However, you can read about the module we are going to use in this post.

*   [Working with Slack Trigger](https://docs.wayscript.com/library/triggers/slack-trigger)
*   [Working with Java](https://docs.wayscript.com/library/modules/java)
*   [Working with Slack module](https://docs.wayscript.com/library/modules/slack)

Slack Trigger
-------------

When someone writes a message in the help channel, we’ll capture the message and perform actions on it, and later send a response. For this purpose, we’ll use the Slack Trigger.

![Adding Slack Trigger](https://wayscript.com/blog_img/140/1.png)

Well, The trigger will depend on the action I add on the Slack channel. It’s a pinned message.

![Image of actions](https://wayscript.com/blog_img/140/2.png)

So basically we have three actions. But first, we have to configure the Trigger.  
We want to receive actions in A, B or C.

![Image of the configuration](https://wayscript.com/blog_img/140/3.png)

For the output, be sure to have Slack\_Message\_Text selected. This variable contains the message the user sent.

Java Module
-----------

WayScript allows you to write programs with Python, JavaScript, or Java if you want to perform more complex tasks. Here we’ll work with Java.  
Add it as a new module.

![Adding the module](https://wayscript.com/blog_img/140/4.png)

Once it’s done, click on Edit Code. We will write a script to perform actions on the Slack message we’ve received.

![Java Code](https://wayscript.com/blog_img/140/5.png)

Here nothing complex. I used Switch expression for more visibility and simplicity. By default, if we have no valid option, we’ll just ask the user to provide the right message.  
Click on Done Editing when finished. We’ll move the Slack Bot and configure it.

Slack Bot
---------

Wayscript provides a Slack module you can use to read or write messages. Then, we can use this module to create the Slack Help Bot.

![Adding the module](https://wayscript.com/blog_img/140/6.png)

Once it’s added and you have configured the workspace, be sure to have a separate channel for this bot. In my case, I called it help.

![Configuration of Slack Bot](https://wayscript.com/blog_img/140/7.png)

Now, we can add inputs. Most importantly, we need the name of the Bot and the message. You can add an image to if you want to give a face to your Bot. ;)

![Slack inputs](https://wayscript.com/blog_img/140/8.png)

Great! The Bot is ready, and if you’ve followed exactly this tutorial, your result will look like this.

![Right message](https://wayscript.com/blog_img/140/9.png)

![Wrong message](https://wayscript.com/blog_img/140/10.png)

Conclusion
----------

Questions about this script or anything else? Join our [Discord](https://discord.gg/VWbXSbj). We're always around to help. If you want to work with the full script template, just find it [here.](https://wayscript.com/user/mangabo_kolawole/wBJ1MSLZ)

[](https://wayscript.com/user/mangabo_kolawole/wBJ1MSLZ)