# Building a Slack LLM Secretary with Tool Chaining

> Source: <https://dev.to/nodabnodab/building-a-slack-llm-secretary-with-tool-chaining-3ol9>
> Published: 2026-07-09 07:19:51+00:00

This will be my second project.

AS I know there are three main types of representative AI agents: Claude Code, Open Claw, and Hermes. This time, I attempted to build a small AI assistant utilizing 'Open Claw'.

I believe the most powerful aspect of Open Claw is its ability to "bring together and utilize various tools."

Although it is not a large project, I intend to leverage this feature to issue commands in natural language and demonstrate that it can "act like a personal assistant."

The details are as follows: If you issue a command via the Slack chat window, the AI agent receives the response and executes the command.

There are four main types of commands.

Let me introduce just three key technologies for implementing this.

```
SELECT_TOOLS_SCHEMA = {
    "type": "function",
    "function": {
        "name": "select_tools",
        ...
        "tools": {
            "type": "array",
            "items": { "enum": [...] },
        },
    },
}
python
def describe_chain_semantics(tools):
    if tools == ["TEXT_SUMMARY", "PDF_CONVERT"]:
        return "요약 내용을 PDF로 생성합니다."
    if tools == ["PDF_CONVERT", "TEXT_SUMMARY"]:
        return "원본 문서를 PDF로 변환하고, 내용을 요약합니다."

# ...
if previous_tool == "TEXT_SUMMARY" and last_summary:
    create_summary_docx(last_summary, ...)  # 요약본 → PDF
else:
    convert_docx_to_pdf(input_path, ...)    # 원본 → PDF
```

3.It has a session memory feature. It can remember past chats.

However, that is how the system stores the state. LLM only reads it.

I wanted to prevent the project from becoming too large.

``` python
def make_session_key(channel_id, user_id, thread_ts=None):
    if thread_ts:
        return f"{channel_id}:{thread_ts}"
    return f"{channel_id}:user:{user_id}"
```

This involved attempting to retrieve its tools immediately by reading the last conversation within Slack right after stopping and restarting the agent.

The cause was that, initially, `last_seen_ts`

was stored only in memory (dict).

When the bot is turned off and on again, this value is initialized to {}, and `last_seen = 0`

.

Then, the 10 most recent messages in the channel plus thread replies all satisfy the condition `ts > 0`

, so they are processed all at once.

The key is to persist the cursor (watermark) based on the message ID (ts).

``` python
# polling_state.py
class LastSeenStore:
    def mark(self, channel_id, ts):
        if float(ts) > self.get(channel_id):
            self._state[channel_id] = float(ts)
            self._save()  # saving disk!
last_seen_store = LastSeenStore()  # last_seen.json 로드
channel_last_ts = last_seen_store.get(channel_id)
pending = collect_pending_messages(channel_id, channel_last_ts)
python
def seed_channel(...):
    latest = max(Channel Message + replys' ts)
    self._state[channel_id] = latest  # read cheack
```

So, here is the answer: Save processed Slack message ts to a file by channel and process only subsequent messages.

We were able to prove that it is possible to create a decent AI assistant by combining ideas from Slack and OpenClaw! I am pleased with the results, as they were much better than expected. The important point is that processing tasks with the help of algorithmic programming, rather than relying too heavily on LLM, helps improve accuracy.

Thanks you for reading!
