In this document we will guide you how to setup webhooks for both Slack and BusinessMate (BM), so both applications will be able to send and receive messages.
We will build a Slack app that will consist of:
In BusinessMate we will add:
Too add a webhooks in BusinessMate we need to go the webhooks table.
From the default/home page in BusinessMate, we can find the table.
Figure 1. Go to the webhooks table
On the right click on the “New Webhook” to create a webhook.
Figure 2. Create new webhook
In the name field write “slack” and then click save button to the right.
Figure 3. Set parameters for webhook
Now that we have created a webhook in BusinessMate, copy the URL it will be used later in Slack.
Figure 4. Webhook URL
Go to the webhooks requests table.
We need a workflow to handle incoming message from Slack, so go to webhooks request table.
From the default/home page in BusinessMate, we can find the table.
Figure 5. Go to webhooks request table
From the click on the three dots on the right and open side menu, then click on the workflows button.
Figure 6. Go to workflows
Now create a new workflow by clicking on the “New Workflow” button on the right.
Figure 7. Create workflow
For the workflow we are going to add an update record step, this step will add the Slack message to the chat.
Connect the begin step to the update record steps by left hold click on begin and drag the arrow.
Figure 8. Add update record step
Click on the begin step to open the begin menu.
We are going to set the trigger on create, meaning every time we receive a message form Slack, this workflow will run.
Figure 9. Set trigger for the begin step
For filters we are going to set one, so it only runs if we get massage from Slack webhook.
So go to the filters in the begin step and add filter, set webhook is equal the slack-webhook we create before.
To save click on the done button.
Figure 10. Set filter for the begin step
Next, we will setup the update record step.
In description we will write “update chat” since it will add the Slack message to the chat.
We want to update a record in a table, select the “Message handler” table.
Add a field that will be updated and select “chat” then click on <> to the right because we are going to add code as parameter in the “add message”.
Figure 11. Setup the update record step
The code below is the payload form Slack:
currentRecord.payload.event.blocks[0].elements[0].elements[0].text
We only want to update one record, so we will also add a filter for update record step.
To the right of Table there is a button to add filters, click on it and filter menu will show up.
Add a filter for name is equal to “slack” and to save click the done button.
Figure 12. Set filter for the update record step
Now connect update record step with end step.
To save and activate workflow give it a name and then click activate changes button to right bottom.
Figure 13. Save and activate workflow
We have now enough things from BusinessMate to create an event subscription in Slack.
So go back to your Slack and go to the “Event Subscriptions”.
Figure 14. Go to Event Subscriptions
On the right top corner switch to on and then we can add request URL from BusinessMate.
The URL can be found from the webhook record “slack” from chapter 2.
When you have the request URL from BusinessMate add the link. Slack will verify the URL.
Figure 15. Enable Events and add request URL
We can now add what kind of events that will trigger the subscriptions. In this example we will add bot user events.
Click on the “Add Bot User Event” and select “message.channels”.
As you can see it requires scope to be used.
Figure 16. Adding Events
The event subsrcription needs scopes, so go to “OAuth & Permissions”.
Figure 17. Go to OAuth & Permissions
Now scroll down and find Scopes and add “Channel:history”.
Figure 18. Add scopes
After adding webhooks and subscriptions, we can install the app into workspace.
Go to basic information and click “Install to Workspace” to install your app.
Figure 19. Install app
Click Allow to apply all changes in the app.
Figure 20. Add app to workspace
Now after install app we can now add the app to channel starting the communication between Slack and BusinessMate.
Figure 21. Add app to channel
You are now ready to use the system.
Try write something in the relpy field in the record on the table “Message handler” and click save.
You will now see the chat update in both BusinessMate and Slack.
Figure 22. Send and receive messages
This is the end of second part.
Hope this quide helped you giving a introduction to Slack and BusinessMate.
Start your 3 months of free trial now. Sign up and start your business flow right away
Get your business mate now