Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Status
colourGreen
titleready

...


If you would like to see this Leave Absence Request Use Case in Slack in action, click here to watch the this video below.

Widget Connector
urlhttps://www.youtube.com/watch?v=7QEtHp_GuLc&t=4s

General Description


This example shows the user how to use ProcessMaker I/O in combination with Slack. Both software programs provide the tools that allow the user to build effective processes while satisfying a variety of business needs. One of the added benefits of using ProcessMaker I/O with Slack is the ability to work directly from the Slack bot interface, meaning that the user only needs to work in one window rather than switching between windows.

Leave Absence Request Use case 

...

Process name

Description

Requester

The user who requests a day off

Approver

A user or group of users who have permission to approve a day off in the company

Slack Action Receiver

The technical process for receiving and processing button responses from Slack

Process Items

The tasks in the process are listed in the table below:

Task

Type

Process

Connector

Description

Time Off Request

Start Event

Requester

 

Starts the Requester process

Initiate SlackBot

Script Task

Requester

 

This technical task runs script and sets up the Slack application parameters, such as AppNumber, Dates, Slack bot token and Slack channel name

Send Time Off Request

Service Task

Requester

Slack\APIConnector

This is where the user requests the time off.

Slack Request Sent

Intermediate Message Event

Requester

 

This message event sends the request for approval

Approve Request

Start Message Event

Approver

 

This start event is initiated by the Slack Request Sent message event and launches the approver process

Slack Response Received

Start Event

Slack Action

 

This event launches the Slack API when the "Approve" or "Reject" button is clicked

Parse Payload

Script Task

Slack Action

 

This script decodes JSON and prepares the data to send in the Slack API response to the approver

Get Slack Callback

Intermediate Message Event

Slack Action

CorrelationKeys

Gets the callback and sends the Slack response to the appropriate process instance

Response Confirmation

Service Task

Slack Action

Slack\SendMessageConnector

This connector sends the Slack webhook

Get Slack Response

Intermediate Message Event

Approver

 

When the approver gets the response from the Slack webhook, the approver can continue with the approval process

Send Approval/Send Decline

Service Task

Approver

Slack\APIConnector

This is where the approver makes a decision

Send Confirmation Request Accepted

Service Task

Requester

Slack\SendMessageConnector

This is where the requester gets a message notifying them that their request is being reviewed

Decision Made

Intermediate Message Event

Requester

CorrelationKeys

This message event sends a notification to the requester with the approver's decision

Forms

Since there are no forms because everything is accessed through Slack, we only need to define the fields that will house the data for each case.

...

*ProcessMaker I/O is designed to be installed in the cloud, so in this document an instance refers to an installation of ProcessMaker in a virtual machine or a container.

If you don't have a ProcessMaker I/O instance yet, please:

  1. Go to the Instance page.
  2. Click Create an Instance and follow the instructions provided.


If you already have a ProcessMaker I/O instance, please:

  1. Launch an instance of ProcessMaker I/O on the Instance page.
  2. Copy/remember the instance URL link, these will be required later
  3. Click on Form examples link
  4. Switch to Slack tab on the top
  5. Download Slack BPMN file  on your computer
  6. Click on Import tab on the top left and upload BPMN file from your PC. 

How to Set Up a Slack Bot

  • Create a Slack app
    • Go to https://api.slack.com/apps and click Create New App
    • Fill in the App Name field
    • Choose the Development Slack Team
    • Click on Create App




The next step is important for creating interactive buttons in Slack Messages:

  • Create a Slash Command
    • On the Basic Information page of your app, go to Add features and functionality > Slash Commands
    • Click Create New Command
    • Command: Fill in any name for the Slack command. In our example it's "absence_request".
    • Request URL: Enter the direct instance link. For example:
    • Usage Hint: Define some parameters for your slash command. For example:
      • [fromDate m/d/Y]
      • [toDate m/d/Y]
    • Save all changes.


  • Test the new slash command
    • Click on Install App


Go to Slack and run the command you've created:

  • Activate the Slack Bot

    • On the Basic Information page of your app, go to Add features and functionality > Bots
    • Click Add a Bot User
    • Fill in the Default username field, for example: @Absence Request
    • Click on Add Bot User


The steps listed above are not required, but are useful for modifying communication between Slack and your ProcessMaker I/O instance. To follow along with our example, it is necessary to do these steps as listed.

...

When your Slack bot is created and installed to your team, get a Slack bot token via the Oauth & Permissions tab, accessed under Features in the left menu.
In the Oauth Tokens & Redirect URLs section, click on Copy in the Bot User OAuth Access Token field to copy the Slack bot token to your clipboard.
In ProcessMaker I/O, go to the "Initiate SlackBot" service task and paste the bot token (bot tokens start with "xoxb") into the DataModel 'bot_token' variable.
e.g. $aData['bot_token']='xoxb-161650023927-8rz0xMGgrwsgbGUJj5lMaWiH';

How to Set Up a Channel Name for Approvers

In the "Initiate SlackBot" service task, define the channel name in the DataModel 'channel_name' variable.
e.g. $aData['channel_name']='#testprocess';
Your channel can be private, just create the appropriate permissions in Slack in advance.

Slack Connectors

There are 2 type of connectors available for integration with Slack services:

...