Triggering Workflow Process by Slack Post

In the article “Posting a Message to Slack,” we explained how to integrate Questetra’s workflow app with Slack, a business-oriented chat tool, allowing for automatic posting messages from workflow to Slack.

In this article, we will explain the inverse linkage setup, in which a posting inside Slack triggers a Questetra workflow app.

Questetra Automatic Steps

Start: Slack: Message Received

Start: Slack: Message Received

This item waits for an HTTP request from Slack, and upon receiving it, a Process is initiated. You create a dedicated app in Slack and use it in conjunction with this item.

Slack: Sending messages (Block Kit supported)

Slack:  Post Message (Block Kit support)

This is the item we used in “Posting a Message to Slack.” This time, we will set the Channel ID and Thread ID so that a reply message will be posted to the original Slack thread.

Creating a Slack App and Setting up Linkage with Questetra

The integration between Questetra and Slack is facilitated through an auto-step installed in Questetra’s workflow app and a Slack app installed in Slack Workspace (Slack’s utilization platform). The Slack app Directory offers apps created and distributed by Slack Inc. and third parties. Additionally, users can also create and install their own custom apps.

In “Posting Messages to Slack,” a Slack app (Bot) prepared by Questetra Inc. in advance is used. The installation into the workspace is automatically carried out during the integration setup procedure.

The item used in this article, [Start: Slack: Message received], is assigned a unique launch URL when installed as an auto-step in a workflow App. The Slack app sends an HTTP request to this URL to initiate a Questetra Process. The Slack app with the registered launch URL is created, installed, and used by the users themselves.

Referring to the help page for the [Start: Slack: Message received] step, let’s create a Slack app following the procedures below.

1.Create & Install a Slack App

  1. [Create & Install Slack App] Open Your Apps and create a new Slack app using one of the manifests shown in the Appendix section of this page
    • Remember to install your app onto your workspace
[Start: Slack: Message Received] Help page

Open the Your Apps page (https://api.slack.com/apps/) in a browser where you are logged into your Slack account (Fig 1). Click on [Create New App] and in the screen that opens (Fig 2), select [From an app manifest] to move to the screen where you specify your workspace (Fig. 3).

After selecting a workspace and clicking [Next], you will reach the manifest registration screen (Fig 4). In Slack, a manifest is a collection of the app’s settings in either YAML or JSON format, allowing for bulk configuration. The Appendix section in the [Start: Slack: Message Received] help page provides two types of manifests for use. Copy and paste one of them. Here, we will use the “Bot to react to direct messages” (Fig 5).

After going through the confirmation screen (Fig. 6), the Slack app will be created. There are still a few settings that need to be configured, but let’s proceed to install your app by clicking on [Install your app].

The default name of the created Slack app and Bot user name is “Questetra Bot (Direct Messages)” as listed in the manifest. After you create, you can change the name to anything you like by the following method.
・App Name: Slack App Details Page > [Basic Information] > [Display Information]
・Bot User Name: [Home] > (Target App) > [Workspace Info] > [Settings].

2.Create & Release Questetra Workflow App

  1. [Create & Release Questetra Workflow App] Create a Workflow app on Questetra BPM Suite using “Start: Slack: Message Received”, and release it
    • Your Signing Secret to set in C1 is shown on the Basic Information page of the Slack app created in the Step 1
[Start: Slack: Message Received] Help page

In order to finalize the launch URL for the [Start: Slack: Message received], create a workflow app and activate it. Prepare a minimal app with only the following settings and then [Release] it.

  • [Start: Slack: Message received]
  • [Human Tasks]
  • [End Event]
  • Required Data Item “message” (String-type multiple lines)

Set the required configuration item [C1: Authorization Setting in which Signing Secret is set*] in the [Start: Slack: Message received] step. Open the HTTP Authentication Settings screen by clicking [Set up Setting], and add a setting to the [Workflow app specific settings] field. The value to be entered for [Token] is the string displayed in the [Signing Secret] listed in the [App Credentials] section under [Basic Information] on the left side of the Slack app page that you created. Click the [Show] button to display it and then copy it. Save it with a name of your choice in the [Name] field.

Slack App detail screen

Go back to the app edit screen and select the name of the setting you just created in [C1:Authorization Setting in which Signing Secret is set*]. If the setting does not appear, reload the page in your browser. Specify the Data Item “Message” in [C2: Data item to save message], then the app definition error will be resolved so you can [Release] the app.

3. Change Event URL

  1. [Change Event URL] Copy the URL shown in “Start: Slack: Message Received”, and set it as Request URL on the Event Subscriptions page of the Slack app created in the Step 1
    • Confirm that the Request URL is verified and click “Save Changes”
[Start: Slack: Message Received] Help page

From the page side menu of the Slack app, open [Event Subscriptions]. In the [Request URL],

https://example.questetra.net/System/Event/Start/
is listed as is in the registered manifest. This is a temporary URL that does not exist and is therefore an error. If you overwrite it with the URL shown in the configuration screen for the [Start: Slack: Message Received], Slack will automatically attempt a test access to the URL. When the display above changes to “Verified✓”, click [Save Changes] at the bottom.

Verification of launch URL

If you have created a Bot to react to mentioned messages, you will also need to “Invite the Bot to a Channel.”

Coming to this far, you have finished setting up the linkage with the [Start: Slack: message received] step.

Select “Questetra Bot (Direct Messages)” from [Apps] on [Home] screen of Slack, write some message and send it. If it is received, you will see the task in [My Tasks] within the Questetra workflow.

Sample App

To the Released workflow app that we confirmed to work with Slack above, edit it to create a “Flow for Receiving Requests from External.” That is a scheme for a Questetra Process will be started when a Slack user who does not have a Questetra account posts a message in Slack.

An input form is created on the web by [Receiving Task (Form)], and its URL is notified to the thread of the message posted in Slack. Once the form has been submitted, the form cannot be accessed from the outside.

In this example, the Data Items are set assuming a Leave request. The processes after approval are omitted, and only the result is notified.

Data Items

Data Item NameTypeField NameRequired“Approval” Stepmessage(Markdown)
TitleProcess Title
MessageString (multiple lines)q_MessageSlack message body
Slack User IDString (single line)q_User_IDSlack User ID
Channel IDString (single line)q_Channel_IDSlack channel ID
Thread IDString (single line)q_Thread_IDSlack thread ID
NameString (single line)q_NameName entered in the form
Leave StartDate (Y/M/D)q_Start_dateStart date entered in the form
Leave EndDate (Y/M/D)q_Until_dateEnd date entered in the form
DaysNumericq_DaysNumber of days of leave entered in the form
DescriptionString (multiple lines)q_ReasonReason for leave entered on form

Start: Slack: Message Received

Set up Start: Slack

Item NameRequiredMessage(Markdown)
C1: Authorization Setting in which Signing Secret is set *This has already been set up in “Creating a Slack App and Setting Up Integration with Questetra”.
C2: Data item to save Message *Specify the Data Items for storing postings in Slack. This has already been set in “Creating Slack App and Setting Up Integration with Questetra”.
C3: Data item to save Slack user IDSpecify the ID of the user who posted in Slack. In this case, specify “Slack user ID”.
C4: Data item to save Channel IDSpecify the Data Item to store the ID of the channel where the post was made in Slack. In this case, specify the “Channel ID”.
C5: Data item to save Thread IDSpecify the Data Item to store the ID of the thread of the post made in Slack. In this case, specify the “Thread ID”.

Slack: Send Message (Block Kit Supported)

Set up Form URL Notification, Approval Notification, Rejection Notification respectively.

Item NameRequiredmessage(Markdown)
C1-a: HTTP Authentication Settings (when Questetra uses a registered Bot)Not used this time.
C1-b: HTTP authentication settingsAdd an HTTP authentication setting and specify the setting name*.
C2: Channel ID (name is also acceptable)Specify the Data Item for which the channel ID will be saved in the start event. In this case, specify “channel ID”.
C3: Thread IDSpecify the Data Item for which the channel ID will be stored in the start event. In this case, specify “Thread ID”.
C4: Broadcast reply to entire channelNot used this time.
C5: Message (Block Kit)Not used this time.
C6: Message (Markdown)Set up the text to be posted. (Each of the three processes has different content**)

* Add HTTP authentication settings and specify the name of the setting

This sample app will work with the Slack app created above. Even though the same Slack app is the target, the tokens used for authentication are different between [Slack: Post Message (Block Kit supported)] and [Start: Slack: Message Received]. Click [Set up Setting] to add HTTP Authorization Setting and specify [Bot User OAuth Token] in the [Token] field. [Bot User OAuth Token] can be found in the Slack app settings page under [OAuth & Permissions].

It works even if the same settings as in ”Posting a Message to Slack” are made to the [C1-a: HTTP Authentication Settings (When Questetra uses a registered Bot)]. In this case, the Slack user who sent the message will receive a reply from a different Bot than the one to which he sent first.

** C6: Message (Markdowm) settings

Item NameSetting details
Form URL NotificationPlease enter your leave request details in the web form below.
${var[applicationRoot]}System/ReceiveTask/Form/#{processModelInfoId}/9/#{processInstanceId}/#{#q_User_ID}/view
(see figure below)
Approval NotificationYour request is accepted!
Rejection Notice Sorry, your request is rejected.
Web Form URL

(Receiving Tasks (Forms)

Set up Application Form.

[Editing Permission] tabs
Data Item NameData Permission to Edit
Title
Message
Slack User ID
Channel ID
Thread ID
Name
Leave Start
Leave End
Days
Description
[General] tab
API KeySpecify the data item, Slack User ID

(Timer intermediate event)

It holds replying to Slack until the web form for the application is published.

#now.addMinutes(1)

Data update

Set up Title set.

Data ItemValue or Formula
Title【Request for leave】#{#q_Start_date}-#{#q_Name}

The Title of the Process is automatically entered using the information entered on the application form.
For details, please refer to Let’s set the Title automatically.

Operation Check

[Release] the workflow app and then verify that it works.

In this case, we will post from the Slack mobile app. Open “New Message” from the icon and check “Questetra Bot (Direct Messages)” to go to the posting screen. Post an appropriate message and wait for a while to receive a reply. Tap the link in the reply message, and an input form will open. Fill in the necessary information and [Send].

Operate the Task that has arrived as a new Issue in Questetra’s [My Tasks]. A message based on the selected button, either [Approve] or [Reject], is sent as a reply to the Slack thread.

Scroll to Top

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading