Vai al contenuto

Recupera il contenuto di Slack

GET /discussions/{discussion_id}/contents/

Retrieve the contents of a discussion by ID. A discussion can be a Slack or Discord chat.

Returns the content of the discussion with the specified ID. A discussion can be a Slack or Discord chat. The response contains two fields: discussion_content, which includes the main messages of the chat, and thread_contents, which contains the threads of the discussion.

Parameter In Type Required Description
discussion_id path integer yes The ID of the discussion to retrieve contents for. Discussions are either Slack or Discord chats.
integration_type query string yes Indicate the integration of the discussion. Currently, it can only be "slack" or "discord".
from query string Indicate the starting time when we want to retrieve the content of the discussion in ISO 8601 format at GMT+0. If not specified, the default time is now.
to query string Indicate the ending time when we want to retrieve the content of the discussion in ISO 8601 format at GMT+0. If not specified, it is 7 days before the "from" parameter.

Responses

  • 200 — Main and threaded messages of the discussion in a time range.
  • 404 — Discussion not found.
  • 500 — Internal server error.

Esempi di Richieste

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"

Info

Sostituisci YOUR_JWT_TOKEN con il tuo token JWT effettivo e 12345 con un ID discussione reale.

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);
};

// Ottieni i contenuti Slack per la settimana scorsa
const toDate = new Date().toISOString();
const fromDate = new Date();
fromDate.setDate(fromDate.getDate() - 7);
const fromDateStr = fromDate.toISOString();

getSlackContents(12345, fromDateStr, toDate);

Info

Sostituisci YOUR_JWT_TOKEN con il tuo token JWT effettivo e 12345 con un ID discussione reale.

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)

Ottieni i contenuti di Slack per la settimana scorsa

to_date = datetime.now().isoformat() + "Z" from_date = (datetime.now() - timedelta(days=7)).isoformat() + "Z"

get_slack_contents(12345, from_date, to_date)

!!! info

    Sostituisci `YOUR_JWT_TOKEN` con il tuo vero token JWT e `12345` con un ID discussione reale.

## Parametri del percorso

| Parametro      | Tipo    | Descrizione                                                                 |
|----------------|---------|-----------------------------------------------------------------------------|
| discussion_id  | intero  | **Obbligatorio.** L'ID del canale Slack o della discussione da cui recuperare i contenuti. |

## Parametri di Query

| Parametro | Tipo | Descrizione |
|-----------|------|-------------|
| integration_type | string | **Obbligatorio.** Impostare su "slack" per recuperare il contenuto di Slack. |
| from | string | Orario di inizio nel formato ISO 8601 a GMT+0. Se non specificato, il valore predefinito è adesso. |
| to | string | Orario di fine nel formato ISO 8601 a GMT+0. Se non specificato, è 7 giorni prima del parametro "from". |

## Formato di Risposta

```json
{
  "discussion_content": "Utente A [2023-06-01 10:30:00]: Buongiorno team!\nUtente B [2023-06-01 10:32:15]: Buongiorno! Come sta andando a tutti oggi?\n...",
  "thread_contents": {
    "2023-06-01T10:30:00Z": "Utente C [2023-06-01 10:35:00]: @Utente A Sto bene, grazie per aver chiesto!\nUtente A [2023-06-01 10:37:30]: Felice di sentirlo @Utente C!",
    "2023-06-02T14:15:22Z": "Utente D [2023-06-02 14:20:45]: Ecco l'aggiornamento sul progetto...\nUtente B [2023-06-02 14:25:10]: Grazie per l'aggiornamento!"
  }
}

Risposte di Errore

Codice di Stato Descrizione
404 Discussione non trovata
500 Errore interno del server

Questo endpoint recupera i contenuti di un canale Slack o di una conversazione in messaggi diretti. Restituisce sia i messaggi principali del canale (discussion_content) che le risposte in thread (thread_contents). I dati sono organizzati cronologicamente e includono informazioni sugli utenti, rendendo facile comprendere il contesto delle conversazioni.

I parametri dell'intervallo di tempo consentono di concentrarsi su periodi specifici, il che è particolarmente utile per rivedere l'attività recente o le discussioni storiche.