Search

Search

In this article

Overview

Use this Snap to search for messages and files in your Slack workspace based on one or more keywords.

Prerequisites

Add valid Slack Scopes based on the intended operation. See Required Slack Scopes below for details.

Required Slack Scopes

Any action you want to perform using Slack, additionally needs appropriate Scopes assigned to your appSee the Scope and Permissions article in Slack API documentation for the complete list and each Account page under Configuring Slack Accounts for information on defining Scopes for your app.

To

Bot Token Accounts
(scope)

User Token Accounts
(user_scope)

Search for messages and files

N/A

search:read

Support for Ultra Pipelines

Works in Ultra Pipelines.

Limitations

  • Search operation works with User Tokens only. Do not use Bot Token Account with this Snap.

  • Snaps in this Snap Pack use conditional display/hiding of fields. So, ensure that you always use the New Form UI (and not the classic UI) for the Snaps to function as designed/expected.

Known Issues

None.

Snap Input and Output

Input/Output

Type of View

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input/Output

Type of View

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

  • Min: 0

  • Max: 1

  • Mapper

  • Copy

  • JSON Generator

A document containing one or more search keywords. 

Output

Document

  • Min: 1

  • Max: 1

  • JSON Parser

  • XML Parser

  • Filter

A document with search results (message and/or files) matching the keyword(s) passed.

Snap Settings

Parameter Name

Data Type

Description

Default Value

Example 

Parameter Name

Data Type

Description

Default Value

Example 

Label

String

Search

Search_Messages

Query

String/Expression

Enter one or more keywords in this field to search for, in the workspace. The keywords can be passed through an upstream Snap and can include wildcard search keywords.

You can customize your search keywords to filter your search results. For messages and files:

  • From a specific user or in a channel/private group, add from:@user.name to your search keywords.

  • You sent to a specific user/channel/private group, add  in:#channel.name or to:@user.name to your search keywords.

  • By their date sent, add after:2020-10-05 before:2020-10-07 in:#support_channel from:<@user.name>

N/A

Snap*logo.*, Pipeline in:#support_channel 
from:<@user.name>, 
from:<@W01CF9AQDPS>

Scope

Drop-down list

Select one of the following options from this drop-down list.

  • All. To search for the keyword and retrieve file names and messages that contain the keyword.

  • Files. To search for the keyword in file names and retrieve only files containing the keyword.

  • Messages. To search for the keyword in messages and retrieve only messages that contain the keyword.

All

Files

Sort Key

Drop-down list

Select one of the following options from this drop-down list.

  • score. To sort the search results by their scores.

  • timestamp. To sort the search results by their timestamps when they are sent.

score

timestamp

Sort Order

Drop-down list

Select one of the following options from this drop-down list.

  • asc. To sort the search results in the ascending order of their Sort Key values.

  • desc. To sort the search results in the descending order of their Sort Key values.

desc

asc

Snap Execution

Drop-down list

Select one of the three following modes in which the Snap executes:

  • Validate & Execute. Performs limited execution of the Snap and generates a data preview during Pipeline validation, then performs full execution of the Snap (unlimited records) during Pipeline runtime.

  • Execute only. Performs full execution of the Snap during Pipeline execution without generating preview data.

  • Disabled. Disables the Snap and all Snaps downstream from it.

Validate & Execute

Execute only

Troubleshooting

Error

Reason

Resolution

Failure: Unable to perform search operation. Reason: not_allowed_token_type

A Search operation cannot be carried out in Slack using a Bot Token. 

Ensure that the Snap account uses a User Token and not a Bot Token before running the Pipeline again.

Examples

Locating a Sent Message Using Search Keywords and Deleting it

To delete a message that was sent, we can locate the sent message and delete it. The same can be done for multiple messages, at once. This example demonstrates how we can use the Search Snap to achieve this result.

This Pipeline uses a set of Pipeline Parameters as depicted in the following image.

We use the Send Message Snap to send a message defined as an expression to a Private Channel.  

Send Message Snap

Output

Search Snap supports a variety of search keywords, besides exact words, like wildcard search (using *, #, and so on), sender, or recipient of the messages and files. We use this feature to perform two different search operations and combine their results to see if our message is retrieved. 

So, after sending the message we use the Copy Snap to duplicate the output from Send Message Snap and initiate two Search operations - one based on the wildcard search and another on the sender's name/ID.

Search by wildcard text

Output

Search by Sender

Output

We combine these search results using a Join Snap to ensure the results contain the message we want to delete.

Join Snap

Output

Now, we connect a Mapper Snap to transform the contain search results data to contain only the Channel ID and the timestamps of the messages. This will enable us filter the results and identify the latest message that we want to delete.

Mapper Snap

Mapper Output

Connect a Delete Message Snap to the Mapper and pass the Channel and Timestamp values to it, to delete the message. The Snap deletes the message and shows the following output.

Delete Message Snap

Output

Download this Pipeline

Downloads

Important Steps to Successfully Reuse Pipelines

  1. Download and import the Pipeline into SnapLogic.

  2. Configure Snap accounts as applicable.

  3. Provide Pipeline parameters as applicable.




See Also