This post is part of a multi-part series that focuses on specific examples of how to connect Claris FileMaker to Slack. This article will make more sense if you have read our introduction, and we invite you to dive into the whole series here:
Slack FileMaker Integration Overview
FileMaker + Slack: A Claris Connect Integration
FileMaker + Slack: A Simple API Integration
FileMaker + Slack: Putting It All Together
Assumptions
We expect that you have at least a passing knowledge of Claris FileMaker and Slack. If you could use refreshers, please visit Use Claris FileMaker to Build Business Applications and/or slack.com.
It’s also useful (though not essential) if you’ve got a basic understanding of consuming APIs with Claris FileMaker. If you’re unfamiliar with this topic, you can certainly copy and paste the code that you find here or just explore the included demo file, but you might get bogged down pretty quickly if you run into issues.
Why Use the Slack API?
If you’re a seasoned developer and familiar with API integrations, it may be a natural choice to dive right in with the (very well documented) Slack API. With a direct API integration you’ve undoubtedly got a larger canvas of possible features than with Claris Connect. That said, there are a few more moving pieces with an API integration and that can translate into more roadblocks to success.
Our Goal – Slack Notifications from FileMaker
It can be useful to get notifications in Slack when things happen in your organization. For example, we use Atlassian Jira for project management at Codence, and when an issue gets assigned to a person, we trigger a Slack notification with a link to the issue in Jira.
If you’ve got a custom Claris FileMaker application, getting notified in Slack when something happens can be incredibly useful.
In this demo, we will walk through how to build a basic API connection with Slack and configure a Claris FileMaker app to send a brief message to Slack (via a custom Slack App) when a record gets modified.
Note that we’ve also created a demo using Claris Connect. In this case, we’re delivering the same functionality to compare techniques. Claris Connect is a great turn-key option if the functions it supports serve your needs. When you need more options, using the approach we describe here will get you started.
…and this shows up in your Slack workspace:
The Pieces
We’ll use three elements for this demo: an OnObjectSave script trigger within FileMaker to watch for a field modification, the Insert from URL script step, and the Slack API.
As with most API integrations, the first and often trickiest part is authentication. Slack is no different. With many APIs, you’ll need to log in to the remote system and generate an API key (also called a token) which you’ll use as part of your API request to authenticate to the remote application. The Slack API is pretty sophisticated and we don’t just generate a token, we create what’s called a Slack app that we can configure in all sorts of ways. We will communicate with this app which in turn will interact with our Slack workspace. When we create our Slack app, a token (called a bot token) is generated automatically. We will use this bot token to authenticate to our Slack app.
See it in Action
We have assembled a short video of this example in action, check it out!
The Slack App and Manifest
To create a Slack App, log in to your Slack Workspace in a browser, then navigate to api.slack.com/apps. From here you can “Create New App” – select “From an App Manifest, choose your workspace, and select “Next”.
Copy and paste the text from the Example Manifest section below into your Slack App. Note that we have chosen to use the same Slack App (and consequently, the same app manifest) for all of our FileMaker/Slack demos, so this Example Manifest includes components that aren’t strictly necessary for this lightweight API integration.
Don’t worry too much about the contents of this manifest; this is essentially a set-it-and-forget-it step. A copy/paste should do for now. You’re welcome to use our simple version shared here. The important part for this specific demo is the “bot:” section where we are configuring the scope of the bot token access to Slack.d
What is an app manifest? “Manifests are YAML-formatted configuration bundles for Slack apps. With a manifest, you can create an app with a pre-defined configuration, or adjust the configuration of an existing app.” Reference: Slack API Documentation
Example Manifest
_metadata:
major_version: 1
minor_version: 1
display_information:
name: FM Slack Integration Demo
features:
app_home:
home_tab_enabled: true
messages_tab_enabled: false
messages_tab_read_only_enabled: false
bot_user:
display_name: FM Slack Demo
always_online: true
shortcuts:
- name: FM Integration
type: global
callback_id: fm_integration
description: FM Integration
oauth_config:
redirect_urls:
- https://fms.example.com/redirectURL.html?protocol=fmp19&host=fms-test.codence.com&file=FilemakerSlackIntegration&script=Slack | Get User Token
scopes:
bot:
- channels:read
- chat:write
- groups:read
- im:read
- mpim:read
- team:read
- usergroups:read
- users:read
- incoming-webhook
- commands
settings:
interactivity:
is_enabled: true
request_url: https://34h3b9.apps.connect.claris.com/api/hooks/v1/catch/slack/42ed6hPge
org_deploy_enabled: false
socket_mode_enabled: false
token_rotation_enabled: false
Save your App Manifest. Navigate to the OAuth and Permissions section of your Slack App configuration page and copy the ‘Bot User OAuth Token’, you’ll need it in the next step.
Configuring Your Custom Claris FileMaker App
Now that the App Manifest is in place the next step is to configure the Claris FileMaker App. If you are using the demo file we supplied, then navigate to the demo 2 tab and paste the Bot Token into the Bot Token field. You’ll also need to specify a Channel ID to uniquely identify the Slack channel into which you plan to post.
Note that we are intentionally working with a public channel in this example since that’s the easiest to configure. To view a Channel ID in your Slack Workspace, right-click on any channel in your channel directory with the Slack desktop application and select Open channel details, then copy the Channel ID from the bottom of the dialog.
Triggering the Slack Message
In this demo, we have chosen to initiate our action with an OnObjectSave trigger attached to the status field for a contact. Take a look at the Demo 2 tab in the Contact interface in layout mode. You’ll see that we have configured a script trigger on the Status field. Select the field and choose Format > Set Script Triggers… which points to the script “Send message to Slack using bot token”. The script takes a parameter (a JSON object with a single name value pair) which becomes your outbound message. The script makes a single outbound POST request to https://slack.com/api/chat.postMessage with the bot token, channel, and message.
Build on our Foundation
This demo serves as the most straightforward API integration of our series, but you have just scratched the surface of what’s possible! This is a super easy way to get a message from your custom Claris FileMaker application into a public channel in your Slack workspace. With a little more work, you can extend this process to work with a private channel too. Arguably, the hardest part is configuring the Slack App. The POST to the API can certainly also be tricky to get right (just getting the syntax correct can take a few tries!), but hopefully, the example we provided can get you well oriented.
We’ve also fleshed out a more in-depth example for allowing a user to choose from among their channels as they post a message to Slack.
There’s a world of options once you get your Slack App connection working. Other possibilities include sending a report to Slack on a schedule. Using a server side script, it’s not too hard to extend on this idea and send a larger message to Slack on a repeating schedule. At Codence for example, we send a daily report to a sales channel in Slack that lists all leads that need a follow up.
You could easily do something similar listing all orders that were created in the past hour, or perhaps a list of patients that will be arriving during the day. The opportunities for Slack integration with your custom application are limitless. Let us know what you come up with, we’re really interested to see what folks do with this capability.
Built with you in mind
Speak to one of our expert consultants about making sense of your data today. During
this free consultation, we'll address your questions, learn more about your business, and
make some immediate recommendations.