# Search

> Activity for finding the messages and files that match your search parameters in Slack

`UiPath.Slack.Activities.Channels.Search`

## Overview

The **Search** activity uses the Slack [search.all](https://api.slack.com/methods/search.all) API to find the messages and files that match your search parameters (**Query**). The search parameters follow the same modifiers that you use when searching in the Slack application (e.g., *"in:#channel-name, in:@user.name, keyword"*). For more information, see [Search in Slack](https://get.slack.help/hc/en-us/articles/202528808-Search-in-Slack#-add-search-modifiers) in the Slack help documentation.

After performing the search, the activity returns the matching `Message` objects (**FirstMessage** and **Messages**) and `SlackFile` (**FirstFile** and **Files**) objects that you can use as input variables in subsequent activities (e.g., [Download File](https://docs.uipath.com/activities/other/latest/legacy-integrations/slack-download-file)).

## How it works

The following steps and message sequence diagram is an example how the activity works from design time (i.e., the activity dependencies and input/output properties) to run time.

1. Complete the [Setup](https://docs.uipath.com/activities/other/latest/legacy-integrations/slack-setup) steps.
2. Add the [Slack Scope](https://docs.uipath.com/activities/other/latest/legacy-integrations/slack-scope) activity to your project.
3. Add the **Search** activity inside the **Slack Scope** activity.
4. Enter values for the [Input](https://docs.uipath.com/activities/other/latest/legacy-integrations/slack-search#search) properties.
5. Create and enter the following variables for your [Output](https://docs.uipath.com/activities/other/latest/legacy-integrations/slack-search#search) properties.
   * `SlackFile` and `SlackFile[]`
   * `Message` and `Message[]`
6. Run the activity.
   * Your input property values are sent to the [search.all](https://api.slack.com/methods/search.all) API.
   * The API returns the `SlackFile`, `SlackFile[]`, `Message`, and `Message[]` values to your output property variables.

     ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-179660-bec22ffc-7e9f7102.webp)

## In the Body of the Activity

* **Query** - Your search parameters (e.g., channel, user, keywords). This field supports only `Strings` or `String` variables.
* **MaxResults** - The maximum number of results that you want returned in the `Message` and `SlackFile` arrays. This field supports only `Int32` or `Int32` variables.
* **SortBy** - Specifies how you want the results sorted when they're returned. Select from three options: Relevance, Newest, Oldest. The three options are sorted accordingly:
  + Relevance - The messages and files that contain content that most matche your query.
  + Newest - The most recent messages and files that contain content matching your query.
  + Oldest - The oldest messages and files that contain content matching your query.
* **Files** - The files that contain content matching your **Query** value. Enter a `File[]` variable.
* **Messages** - The messages that contain content matching your **Query** value. Enter a `Message[]` variable.
  + If no messages are found, an empty array is returned.
  + The Message object contains file information as well. You can download files using the Message object by getting its File property (e.g. item.File(0))
  + If you plan to use the activity to process the array output, select UiPath.Slack.Models.Message as the TypeArgument.

## Properties

### Common

* **DisplayName** - The display name of the activity. This field supports only `Strings` or `String` variables.

### Misc

* **Private** - If selected, the values of variables and arguments are no longer logged at Verbose level.

### Output

* **ResponseStatus** - The status of the request (success/failure information). Enter a `ResponseStatus` variable (*UiPath.BAF.Models.ResponseStatus*). The `ResponseStatus` object includes three properties that you can use in other activities.
  + **Success** - `Boolean` - Specifies whether the API request was successful.
  + **ErrorCode** - `String` - The response error if the API request is unsuccessful (**Success**=*False*).
  + **Message** - `String` - The error message.

## Example

The following image shows an example of the activity dependency relationship and input/output property values.

For step-by-step instructions and examples, see the [Quickstart](https://docs.uipath.com/activities/other/latest/legacy-integrations/slack-quickstarts) guides.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-187606-3523ca69-96f063e2.webp)
