Slack Bot for Support Personnel build with API Led Connectivity
Tags: mulesofthackathon
Published: 2020-11-30 02:50:38

### **Overview**

This integrates slack and mule integrations to assist for support tasks such as pinging the mule server host in case of server downtime and do basic operations(start, stop, update, restart) with help of cloudhub api.

### **Functional Overview**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bhptmpl8rc7bbo9renzm.jpeg)

### **Downloadable Asset**

1. Slack Experience API [RAML](https://anypoint.mulesoft.com/exchange/ce7baec3-d597-421f-8067-6fd531fb74f9/slack-experience-api/)
2. Support Operations API [RAML](https://anypoint.mulesoft.com/exchange/ce7baec3-d597-421f-8067-6fd531fb74f9/support-operations-api/)
3. Ping API [RAML](https://anypoint.mulesoft.com/exchange/ce7baec3-d597-421f-8067-6fd531fb74f9/ping-api/)
4. Cloudhub Operations API [RAML](https://anypoint.mulesoft.com/exchange/ce7baec3-d597-421f-8067-6fd531fb74f9/cloudhub-operations-api/)

[Github Repository](https://github.com/vigvel123/mulesoft.git)

Operations Supported:

- Ping host inside mule server host to check its connectivity with help of java class.
- Start, Stop, Update, Restart cloudhub applications in bulk using Cloudhub API.

### **API Led Design**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6brqaifrkn23oa6l74fw.jpeg)


### **Slack**

Slack is basically a messaging app meant for teams and workplaces can be used across multiple devices and platforms, and is equipped with robust features that allow you to not only chat one-on-one with associates but also in groups.

#### **Slash Commmands**

**Slash Commands** allow users to invoke your app by typing a string into the message composer box.

A submitted Slash Command will cause a payload of data to be sent from Slack to the associated app. The app can then respond in whatever way it wants using the context provided by that payload.

[Slash-Command-Documentation](https://api.slack.com/interactivity/slash-commands)

With the help of slash commands, we can invoke external URLs. Using this concept we are interacting with mule API to perform operations such as pinging server inside mule runtime, starting, stopping, restarting, and updating mule applications in bulk from the slack channel itself.

**Steps to integrate slack with mule API:**

1.Install slash command application to your slack.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ji4rvlow841gi3ytnceo.jpeg)
2.Configure custom slash commands required for example since we want to ping the mule application inside the mule server let's create a slash command /ping which triggered from the slack channel will call the configured mule API URL.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/36dpn099occg12b0ows4.jpeg)

**Use Cases:**

1.Support Personnel often faced with issues like server downtime and emergency network issue during those times we currently use net-tools API to check if our client-server is reachable over mule runtime.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/abi8gbwlfn4146aj483f.jpeg)
With the help of slack integration, we can ping the host from the slack channel itself to get ping statistics.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kxgbn6t3hbjega7k7n32.jpeg)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6tbubdog16p0y4kfg2wp.JPG)
2.When server downtime happens we are required to stop several applications and start them again after maintenance which needs to be done for several applications. Currently, we use the Runtime Manager to do these activities.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ga7rc6pobs5nhngku6wh.jpeg)
With the help of slack integration, we can do this from the slack channel in bulk.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oq3ibbzhvn0xww419hcn.jpeg)