Slack

A team collaboration tool, Slack allows users to participate in group message channels and send individual, private messages to colleagues. Skuid users can access their Slack team’s messages and content as a Skuid data source via the pre-configured data source type.

Automatically send a “New Opportunity Alert!” message to your company’s Slack sales channel every time there’s a new opportunity added within Skuid, add a link back to the Opportunity page in that message, it’s all easy to do using the Slack data source type.

To use Slack with Skuid, you’ll need to do three things:

  1. Create an app on the Slack’s API and acquire OAuth credentials.
  2. Set up a new authentication provider for Slack.
  3. Use those OAuth credentials to set up a new data source in Skuid.

Configuration

In Slack API

First you’ll need to create an app in Slack’s API settings. Doing so will provide you with the credentials Skuid needs for its data source connection. To create the app in the Slack API:

  1. Navigate to api.slack.com.
  2. Click Your Apps.
  3. Click Create an App.
  4. Name the app.
  5. Select your Development Slack Team.
  6. Click Create.

Development Slack Teams

When you create your app, you’re asked to designate which Slack “team” the app belongs to.

There are two approaches to selecting a Development Slack Team:

Use your company’s Slack instance. For example if you work for the Acme Corporation, your Slack instance might be acme.slack.com, and you would select this option from the picklist as your “development team.”

  • Pros: You’ll be creating the data source for the target Slack team, meaning your app is essentially “deployed.”
  • Cons: Messages used to test the data source will be sent to actual channels in your company’s Slack team.

Create a new “development team.” By creating a specific “testing” team for building and testing your data source, you can bug test your Skuid pages without cluttering production-use Slack channels for your team.

  • Pros: When you use a “dummy” development team to build and test the app, your test messages are not blasted to your company’s Slack channels. However, you cannot change this team later.
  • Cons: Creating the app for this dummy team means that when you have completed testing, you will need to recreate the app within Slack’s API settings using your company’s Slack instance. You’ll also need to ensure that your models and their conditions are appropriately configured for the actual Slack team.

Credentials

Once the app is created, Slack provides two important app credentials:

  • Your client ID
  • Your client secret (Need to read this? Click Show.)

Like a username and password, these credentials are important when setting up authentication for a Slack data source in Skuid, so keep them handy.

Need to find your credentials?

Oops. You clicked away from the Slack page, and now you need to dig up those credentials again.

  1. Navigate to api.slack.com.
  2. Click Your Apps. Your app should be listed in the middle of the page. Click it to reveal your client ID and client secret.

Set up OAuth and Permissions

Since the Skuid data source will use the OAuth 2.0 protocol to connect to Slack’s API, you’ll need to enter a redirect URL for Slack to send its authorization tokens.

  1. Now navigate to Slack’s OAuth & Permissions page.

  2. Enter the redirect URL, also known as a callback URL, for your Skuid site.

    Skuid Platform [[]]

    For Skuid Platform sites, simply append /auth/oauth/callback to your Skuid site’s domain URL.

    Some examples:

    • For https://example-us-trial.skuidsite.com/, use https://example-us-trial.skuidsite.com/auth/oauth/callback
    • For https://gui-construction.skuidsite.com/, use https://gui-construction.skuidsite.com/auth/oauth/callback
    • For https://asgard-talent-management.skuidsite.com/, use https://asgard-talent-management.skuidsite.com/auth/oauth/callback

    Skuid on Salesforce [[]]

    When using Skuid on Salesforce, the callback URL will depend on several things:

    • Whether or not the Remove Instance Names from URLs critical update is activated
      • If the above critical update is not activated, then the Salesforce org’s instance
    • If set, the Salesforce org’s My Domain
    • Whether the org is a developer edition or sandbox org

    Each of these variables will change parts of the callback URL.

    There are also different URLs needed based on whether the Skuid page is deployed using the Redirect or skuid:page Visualforce component override method. Because of this, it’s best to enter two callback URLs for Skuid on Salesforce orgs.

    To ensure the accuracy of your callback URLs, fill out the form below to generate the appropriate Salesforce callback URLs for your org:

    Note

    Unsure what your instance and My Domain are? The URL of the Skuid Pages list within the Salesforce Classic layout is a quick way to find the information needed for callback URLs. For example:

    https://customMyDomain-dev-ed--skuid.na30.visual.force.com/apex/PageList

    From the above URL you can deduce the following:

    • customMyDomain is the My Domain
    • -dev-ed indicates this is likely a developer’s edition org
    • na30 is the instance.

    How these URLs are formed [[]]

    If the Remove Instance Names critical update is activated, and the org’s My Domain is configured, the callback URLs should be:

    • https://<myDomain>--skuid.visualforce.com/apex/skuid__oauthcallback
    • https://<myDomain>--c.visualforce.com/apex/oauthcallback

    If the org’s My Domain is configured, their format should be:

    • https://<myDomain>--skuid.<Instance>.visual.force.com/apex/skuid__oauthcallback
    • https://<myDomain>--c.<Instance>. visual.force.com/apex/oauthcallback

    If the org’s My Domain is not configured, then the URLs will be:

    • https://skuid.<Instance>.visual.force.com/apex/skuid__oauthcallback
    • https://c.<Instance>.visual.force.com/apex/oauthcallback

    If the org is a developer’s edition or sandbox, the skuid/c section of the URL will be prepended with -dev-ed– or –sandboxName– respectively.

  3. Click Save Changes.

In Skuid

Once you’ve got the app set up in Slack’s API settings, you’ll need to set up both a new authentication provider and a new data source for Slack within Skuid.

Authentication provider

  1. Navigate to Configure > Data Sources > Authentication Providers.

  2. Click New Authentication Provider.

  3. In the New Authentication Provider window:

    • Name: Give the new provider a name.
    • Authentication Method: Select OAuth 2.0 / OpenID.
    • Provider Type: Slack. Once you select this, the Authorize Endpoint URL and the Token Endpoint URL will update.
    • Grant Type: Authorization Code.
    • Default scopes: Authorization scopes let you restrict access to specific Slack data and accounts. To learn more about Slack scopes, visit their OAuth Scopes page for a detailed listing of the available options.

    Note

    You can enter more than one scope; simply separate them with a blank space.

    • Client Credentials: use the client ID and client secret provided by Slack.
  4. Click Save.

Data Source

Now to add Slack as a data source for your Skuid pages.

  1. Navigate to Configure > Data Sources > Data Source s.
  2. Click New Data Source.
  3. In the New Data Source/Select Data Source Type window:
    • Data Source Type: Select Slack
    • Name: Give the new datasource a name.
  4. Click Next Step.
  5. Select the authentication provider you configured.
  6. Click Save new Data Source.
  7. Click OK to create the required remote site setting.

Usage

To set up Slack as a datasource in a Skuid page, select Slack as a model’s data source type, and then select the data source you have created. After creating your model, you’ll need to select a model entity, a Slack data object, from the following:

  • Channel: the full channel list with all messages and users
  • Channel message: individual messages in the specified channel
  • IM: private channel for communicating with a specified user
  • IM message: private messages between you and other user in the IM channel.
  • Group: “private” channel for communicating with a specified group of users
  • Group message: private messages between you and a specified group of users.
  • User: a list of all users on the Slack team.
  • File: a list of file and snippets uploaded to Slack.

Creating conditions for Channel, IM, or Group messages

For each message model entity in Slack, there is a corresponding channel model entity:

  • Channel messages are part of their corresponding channels
  • Group messages are part of the group of users
  • IM messages are part of the IM relationship between two users

Skuid will create default model conditions for the appropriate channel for each message model entity. Without setting this default condition, Skuid will pull in and display all messages that the user has access to, regardless of channel.

To properly set the channel conditions for your message models, that condition must associated with the specific master channel, IM, or group where those messages live. You do this using the numeric ID (not the name) of the channel, IM, or group.

Use case

Let’s say you created a Slack model entity for channel messages, and you want to set a condition that filters for messages only from the company’s Inside Sales channel. You’ll need to know the numeric ID of the Inside Sales Slack channel.

Here’s how to find that number and use it to set up the model condition.

Locate the numeric ID:

  1. Create a model for the appropriate channel entity. (Following the use case cited above, we’ll use channel.)
    • Model ID: use a name that identifies the model, such as SalesChannel
    • Data Source Type: Slack
    • Model Entity: channel
  2. Add two fields to this model: id and Name.
  3. Drag a table into the Skuid page, and associate it with the channel model via the Properties panel.
  4. In the table, click Add Fields, and add ID and Name to the table.
  5. Click Save, and then Preview.

The table will display the name of all the channels in the Slack instance, and their corresponding ID numbers. Use this number to create a model condition on the message model.

Create message model conditions

  1. Create a model for the message entity, in this case, Channel.
    • Model ID: SalesChannelMessage
    • Data Source Type: Slack
    • Model Entity: channelmessage
  2. In the channel condition, click Value.
    • Content: Single specified value (this is the default; do not change it for this purpose)
    • Value: add the numeric ID for the channel you want to affect.

With this condition, you’ve restricted this message model so that it will only return message data associated with the Sales Channel.

Note

This process is the same to create a condition on an IM message model or group message model.

The asBot condition

When sending channel, IM, or group messages, there are two options: users can send the message as themselves or send the message as a bot. These option are controlled by a default condition added to each model that takes a message entity.

Why use the bot?

  • If the messages are intended to be official “blasts,” messages or announcements from the team to the team, using the bot message conveys that. (This particularly useful for channel and group messages.)
  • If, on the other hand, messages should be to and from distinct individuals, don’t use the bot. (This may be more useful for IM messages.)

To manage whether messages are sent as an individual or a bot:

  1. Click the model, and click Conditions under the model.
  2. Click on the asBot condition. The URL Merge Parameter name and the State are set by default. Click Value:
    • Checked (the default) = True; all messages sent from a Skuid pages to this Slack channel will be sent as a bot of the channel.
    • Unchecked = False; all messages sent from a Skuid pages to this Slack channel will be sent as the individual user sending the message.

Use Cases

Once you’ve got a Slack data source and Slack models, what can you do with them?

  • Have an action on a Skuid page automatically send a message to a Slack channel.
  • Display messages from a Slack group on Skuid pages.

You can conditionally render displayed Slack messages, filter them, or search messages.

Warning

When setting search properties, we recommend selecting Client as the search method. This means that Skuid loads the data for the model, and when the user enters a parameter in the search field, Skuid searches that loaded data.

When using server-side search, Skuid searches Slack data on the server before loading it into the page, which can create unanticipated results for the user—often disregarding model conditions and settings.

Unless you have a very specific requirement for server-side search, always set up client-side search.

Example: sending a message using model actions

Let’s look at the use case mentioned at the top of the page: automatically sending a “New Opportunity Alert!” message to your company’s Slack sales channel every time there’s a new opportunity created in Skuid.

Set up models

  1. Set up your channel model.
  2. Set up the channel message model.
    • Create a condition that associates this model with the sales channel.
  3. Set up an Opportunity model using the Salesforce data source.

Create model actions

  1. In the Opportunity model, click Actions.

  2. Click the New Action.

  3. Select the new action, and set its Initiating Event to New row created in model.

  4. Click the Actions tab.

  5. In the Actions tab, click Add Action. For this new action:

    Action Type: Create new row(s).

    Model: Choose your channel message model from the drop down.

    Place row at: Start of Model Data.

    Have associated Components initially show in this row in …: Edit mode.

  6. On the Model Action, click Add Default Value.

    Field: text.

    Content: Single specified value.

    Value: enter the message to be posted in the Slack channel, for example, “A new opportunity has been created!” You can append this message with a URL to a reference to the opportunity page.

  7. Add another action.

    Action Type: Save Model changes.

    Models to Save: select your message model from the picklist.

    If desired, check Roll back entire save on any error.

Next time you create a new opportunity, it’ll be automatically announced to your Sales team. Nice, huh?

Working with messages

Text formatting

It’s easy to add text enhancements to the Slack messages sent from Skuid pages:

Enhancement Formatting Comment
Bold text *text* No spaces between the formatting and the text.
Italic text _text_ No spaces between the formatting and the text.
Strikethrough text -text- No spaces between the formatting and the text.
Code text `text`

Use the backtick (above the tilde), not the single quote mark.

No spaces between the formatting and the text.

Working with Files

Slack allows you to share document files, image files, and snippets. To see a list of the files uploaded to a specific channel:

  1. In the Models pane, click fa-plus-circle Add Model to create a new model and edit the settings:
    • Model Id: Name the model.
    • Data Source Type: Slack
    • Data Source: Your Slack datasource
    • Model Entity: File
  2. Add fields to the model.
  3. Drag and drop a table into the Skuid page, and associate it with the file model via the Properties panel.
  4. In the table, click Add Fields. Some helpful fields to include:
    • File name
    • File ID
    • File type
    • Size
    • Thumbnail or Preview
    • Created Date
  5. Click Save and then Preview.

Voila! A list of all the files in uploaded in the Slack instance.

Too many files?

Set a model condition to limit the channel:

  • Channel equals: channel
  • Value:
    • Content: Single specified value
    • Value: Channel Id
  • State:
    • Condition State: Filterable, Required
    • Condition Name: channel

File Upload

Want to upload files into Slack? Use the File Upload component and fill in the standard properties:

  1. Parent Model: Use the Slack mode created for the page.
  2. File Storage Location: Skuid fills this in as “Direct Upload.”
  3. Label: Add a label to the Upload button.
  4. Snippet to run on Completion: (optional) Enter the name of a JavaScript snippet to be run once the file has been uploaded.

There are additional properties specific to file uploading in Slack:

  1. File Name: Use this field to rename any files uploaded through the file component.
    • The field is compatible with merge syntax.
      • Using a dot within this field will cause the file type to be overwritten as well:
        • If used to rename “spreadsheet.xlsx” to “budget, the resulting filename would be “budget.xlsx.”
        • If used to rename “spreadsheet.xlsx” to “budget.csv, the resulting filename would be “budget.csv.”
      • If blank, files will retain their original name.
  2. File’s Title: A title for the file upload message envelope on Slack.
  3. Initial Comment: An introductory comment included in the file upload message envelope on Slack.
  4. Channels to Send: Enter the channel ID for where the file will be uploaded.
    • More than one channel? Separate IDs with a comma

Troubleshooting

The ability to integrate apps and services into your Slack instance is controlled by the type of Slack service you have. Before you start working with Slack as a data source, make sure you have a least one integration “seat” open, so you can add a Skuid integration, and thereby access Slack data.