# 檢索 Slack 的內容

## 擷取 Slack 的內容

{% openapi src="/files/WF90zszaISusKGEBimez" path="/discussions/{discussion\_id}/contents/" method="get" %}
[rememberizer\_openapi.yml](https://2492455604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTVKmtXKPeA8gAZJsuGLA%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media\&token=3b4a9db2-4dd7-440f-b670-9555703d351d)
{% endopenapi %}

### 範例請求

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X GET \
  "https://api.rememberizer.ai/api/v1/discussions/12345/contents/?integration_type=slack&from=2023-06-01T00:00:00Z&to=2023-06-07T23:59:59Z" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
```

{% hint style="info" %}
將 `YOUR_JWT_TOKEN` 替換為您的實際 JWT 令牌，並將 `12345` 替換為實際的討論 ID。
{% endhint %}
{% endtab %}

{% tab title="JavaScript" %}

```javascript
const getSlackContents = async (discussionId, from = null, to = null) => {
  const url = new URL(`https://api.rememberizer.ai/api/v1/discussions/${discussionId}/contents/`);
  url.searchParams.append('integration_type', 'slack');
  
  if (from) {
    url.searchParams.append('from', from);
  }
  
  if (to) {
    url.searchParams.append('to', to);
  }
  
  const response = await fetch(url.toString(), {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_JWT_TOKEN'
    }
  });
  
  const data = await response.json();
  console.log(data);
};

// 獲取過去一週的 Slack 內容
const toDate = new Date().toISOString();
const fromDate = new Date();
fromDate.setDate(fromDate.getDate() - 7);
const fromDateStr = fromDate.toISOString();

getSlackContents(12345, fromDateStr, toDate);
```

{% hint style="info" %}
將 `YOUR_JWT_TOKEN` 替換為您的實際 JWT 令牌，並將 `12345` 替換為實際的討論 ID。
{% endhint %}
{% endtab %}

{% tab title="Python" %}

```python
import requests
from datetime import datetime, timedelta

def get_slack_contents(discussion_id, from_date=None, to_date=None):
    headers = {
        "Authorization": "Bearer YOUR_JWT_TOKEN"
    }
    
    params = {
        "integration_type": "slack"
    }
    
    if from_date:
        params["from"] = from_date
    
    if to_date:
        params["to"] = to_date
    
    response = requests.get(
        f"https://api.rememberizer.ai/api/v1/discussions/{discussion_id}/contents/",
        headers=headers,
        params=params
    )
    
    data = response.json()
    print(data)
```

{% endtab %}
{% endtabs %}

## 獲取過去一週的 Slack 內容

to\_date = datetime.now().isoformat() + "Z" from\_date = (datetime.now() - timedelta(days=7)).isoformat() + "Z"

get\_slack\_contents(12345, from\_date, to\_date)

````

{% hint style="info" %}
將 `YOUR_JWT_TOKEN` 替換為您的實際 JWT 令牌，並將 `12345` 替換為實際的討論 ID。
{% endhint %}
{% endtab %}
{% endtabs %}

## 路徑參數

| 參數 | 類型 | 描述 |
|-----------|------|-------------|
| discussion_id | 整數 | **必填。** 要檢索內容的 Slack 頻道或討論的 ID。 |

## 查詢參數

| 參數 | 類型 | 描述 |
|-----------|------|-------------|
| integration_type | 字串 | **必填。** 設定為 "slack" 以檢索 Slack 內容。 |
| from | 字串 | 以 ISO 8601 格式表示的起始時間，位於 GMT+0。如果未指定，預設為現在。 |
| to | 字串 | 以 ISO 8601 格式表示的結束時間，位於 GMT+0。如果未指定，則為 "from" 參數的 7 天前。 |

## 回應格式

```json
{
  "discussion_content": "用戶 A [2023-06-01 10:30:00]: 早安，團隊！\n用戶 B [2023-06-01 10:32:15]: 早安！今天大家過得怎麼樣？\n...",
  "thread_contents": {
    "2023-06-01T10:30:00Z": "用戶 C [2023-06-01 10:35:00]: @用戶 A 我很好，謝謝你的關心！\n用戶 A [2023-06-01 10:37:30]: 很高興聽到這個 @用戶 C！",
    "2023-06-02T14:15:22Z": "用戶 D [2023-06-02 14:20:45]: 這是項目的更新...\n用戶 B [2023-06-02 14:25:10]: 謝謝你的更新！"
  }
}
````

### 錯誤回應

| 狀態碼 | 描述      |
| --- | ------- |
| 404 | 找不到討論   |
| 500 | 內部伺服器錯誤 |

此端點檢索 Slack 頻道或直接消息對話的內容。它返回主要頻道消息（`discussion_content`）和串接回覆（`thread_contents`）。數據按時間順序組織，並包含用戶信息，使理解對話的上下文變得容易。

時間範圍參數允許您專注於特定時期，這對於回顧最近的活動或歷史討論特別有用。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rememberizer.ai/zh-hk/kai-fa-zhe-zi-yuan/api-docs/retrieve-slacks-content.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
