> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chamelio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Hub Use Case: Upload Contracts From Slack to the Repository

> Build an Agent Hub agent that uploads contracts posted in a Slack channel to your contract repository: which file types work, how approvals work, how to set the counterparty and document type, and how to troubleshoot

If your team already shares contracts in Slack, an Agent Hub agent can file them for you. The agent watches one Slack channel, uploads the contracts posted there to your contract repository, and replies in the message's thread with the result.

## At a Glance

| Question | Answer |
| - | - |
| **Starts when** | Someone posts a top-level message in the channel, or mentions the agent, depending on the **Message type** you choose |
| **File types it can upload** | PDF and DOCX. DOCX files are converted to PDF. See [Which files work](#which-files-work). |
| **Approval** | Your choice: upload without asking, or approve each upload first |
| **Replies** | In the Slack thread of the original message, as **Chamelio** |
| **Where uploads appear** | The [Activity Monitor](/features/core/activity-monitor), then the contract repository once processed |

## Before You Start

* Connect Chamelio to your Slack workspace. See [Slack integration](/guides/integrations/slack).
* Create the channel the agent should watch, for example `#contracts-to-upload`.
* Add the Chamelio app to that channel. The agent can only listen to channels Chamelio has been added to.

## Build the Agent

<Steps>
  <Step title="Describe the agent">
    In **Agent Hub**, open **Agents** and click **New agent**. In **Let's build your agent**, describe what you want in plain language. Pick the version that matches the files your team posts:

    <Tabs>
      <Tab title="PDF only">
        ```text theme={null}
        Create an agent that reads messages in the Slack channel #contracts-to-upload.
        If the attached document is a PDF, upload it to the repository.
        If not, reply in the thread asking what to do with this file.
        ```
      </Tab>

      <Tab title="PDF and Word">
        ```text theme={null}
        Create an agent that reads messages in the Slack channel #contracts-to-upload.
        If the attached document is a PDF or DOCX file, upload it to the repository.
        If not, reply in the thread asking what to do with this file.
        ```
      </Tab>
    </Tabs>

    To have the agent fill in details from the message, add a line such as: `If the message states a counterparty or document type, set them on the upload.` See [Set the counterparty and document type](#set-the-counterparty-and-document-type).
  </Step>

  <Step title="Answer the builder's questions">
    The builder asks questions to fill in the details, for example:

    | Question | Example answer |
    | - | - |
    | Should uploading to the repository pause for your approval each time, or run unattended? | **Pause for approval** while you're trying it out. Switch to unattended later. |
    | Should the agent reply in the Slack thread when a file isn't one it uploads? | **Yes** |
    | Which channel should the agent listen to? | Pick your channel. If it isn't listed yet, say so and set it on the Trigger step. |
    | Should the agent run on every top-level message, or only when someone @mentions it? | **Every top-level message** |

    When the builder shows **Update this agent?**, review the summary and click **Apply to draft**.
  </Step>

  <Step title="Set the Slack trigger">
    On the **Trigger** step, select **Slack**, then:

    * Under **Channels**, select your channel. If it's missing, check that Chamelio is in the channel, then click **Click here to update the list**.
    * Set **Message type** to **Any message** to run on every top-level message, or **Mention agent** to run only when someone mentions the agent.
  </Step>

  <Step title="Review the task">
    The **Task** step holds the instruction the builder wrote, plus an optional **Definition of done** (for example, every file has a reply in the thread) and **Expected outputs** (for example, one reply per file confirming the upload or explaining why not). Edit anything you want to change.
  </Step>

  <Step title="Check the tool permissions">
    On the **Capabilities** step, expand the tool groups and check these two tools:

    | Tool | Group | Permission |
    | - | - | - |
    | **Upload to Repository** | Contracts | **Require human approval** to approve each upload, or **Always allow** to upload without asking |
    | **Send Slack, Email, or Teams Messages** | Communication | **Always allow** so the agent can reply in Slack without waiting for you |

    To send approval requests to someone other than you, turn on **Customize human review assignee** and choose a Slack user.
  </Step>

  <Step title="Publish and activate">
    Click **Publish**. A newly published agent starts out **Paused**. Open it from **My Agents** and click **Activate**. Its status changes to **Active**.
  </Step>
</Steps>

## Try It

Post a contract in the channel. Within a few seconds:

1. The agent adds a reaction to your message.
2. A new run appears on the agent's **Runs** tab with **Slack** as the trigger.
3. If uploads need approval, the run shows as **Pending** until you approve it. See [Approve uploads](#approve-uploads).
4. The agent uploads the file and replies in the thread with the file name and the result.
5. The file appears in the [Activity Monitor](/features/core/activity-monitor) and is processed like any other upload.

## Which Files Work

| File posted in Slack | What happens |
| - | - |
| **PDF** | Uploaded |
| **DOCX** | Converted to PDF and uploaded, if the instruction allows Word files |
| **DOC, TXT, CSV, images, and other types** | Not uploaded. These attachments don't reach the agent, so it replies that no file was attached. |
| **A message with no file** | The agent replies in the thread asking what to do |

To upload a file type that isn't supported, convert it to PDF or DOCX first, then post it again.

## Approve Uploads

When **Upload to Repository** is set to **Require human approval**, each run that wants to upload waits as **Pending** on the agent's **Runs** tab. Open the run to see what the agent plans to upload, add an optional note, and click **Approve** or **Reject**. If a message has several files, you approve all of them in one step.

<Tip>
  Require approval for the first few runs. Switch **Upload to Repository** to **Always allow** once you're happy with the results.
</Tip>

## Set the Counterparty and Document Type

If the instruction tells the agent to, it reads the message text and sets the counterparty and document type on the upload. For example, posting a file with this message:

```text theme={null}
Counterparty: Acme Ltd. Document type: NDA
```

uploads it with **Acme Ltd.** as the counterparty and **NDA** as the document type. The document type must match one of your organization's document types. If the counterparty doesn't match an existing one, Chamelio resolves it when it processes the document. If the message doesn't state them, the agent leaves them empty.

## Post Several Files at Once

A message can have more than one attachment. The agent handles all of them in the same run and posts one reply in the thread with a result for each file.

## Troubleshooting

<AccordionGroup>
  <Accordion title="The agent doesn't react to my message">
    * Check that the agent is **Active**. A newly published agent starts out **Paused**.
    * Check that the Chamelio app is in the channel.
    * If **Message type** is **Mention agent**, the agent only runs when someone mentions it.
  </Accordion>

  <Accordion title="The agent says no file was attached, but I attached one">
    The file type isn't supported. Only PDF and DOCX attachments reach the agent. Convert the file to PDF or DOCX and post it again. See [Which files work](#which-files-work).
  </Accordion>

  <Accordion title="The agent didn't upload a DOCX file">
    Check the instruction on the **Task** step. If it only allows PDFs, the agent replies instead of uploading. Change it to allow PDF and DOCX files.
  </Accordion>

  <Accordion title="The run is stuck on Pending">
    The run is waiting for approval. Open it from the agent's **Runs** tab and click **Approve** or **Reject**.
  </Accordion>

  <Accordion title="My channel isn't in the Channels list">
    Add the Chamelio app to the channel, then click **Click here to update the list** on the **Trigger** step.
  </Accordion>

  <Accordion title="The upload shows as Skipped in the Activity Monitor">
    **Skipped** usually means the document appears unsigned. See the statuses in the [Activity Monitor](/features/core/activity-monitor).
  </Accordion>

  <Accordion title="The Activity Monitor shows Desktop as the source">
    That's expected. Files the agent uploads are listed with **Desktop** as their source, not Slack.
  </Accordion>
</AccordionGroup>

## Related

<Columns cols={2}>
  <Card title="Agent Hub" icon="users-gear" href="/features/core/agent-hub">
    Build agents, set triggers and tool permissions, and track runs
  </Card>

  <Card title="Slack Integration" icon="slack" href="/guides/integrations/slack">
    Connect Chamelio to your Slack workspace
  </Card>

  <Card title="Activity Monitor" icon="chart-line" href="/features/core/activity-monitor">
    Track uploaded documents and their processing status
  </Card>
</Columns>
