Superface

Chat Threads

chat/threads@1.0.2
1 provider

Get Threads

Retrieve list of threads from the whole workspace.

Input
Workspace
Result
Threads
Rate Limit

1.Choose a provider

2.Use GetThreads with mock in your code

Below instructions are for our Node.js SDK. Use OneService for other languages.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('chat/threads@1.0.2');

  // Use the profile
  const result = await profile
    .getUseCase('GetThreads')
    .perform({
      workspace: 'workspace_id'
    }, {
      provider: 'mock'
    });

  // Handle the result
  try {
    const data = result.unwrap();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

run();

Structure details

Input (object)

workspace
Identifier of a workspace, for example a Discord guild or a Slack workspace.

Example

{
  "workspace": "workspace_id"
}

Result (object)

threads
List of retrieved threads
id
Unique identifier of the thread
createdAt
UNIX timestamp (in milliseconds, e.g. 1095379198750) when the thread was created
channel
Unique identifier of the channel where the thread is located
archiveAt
UNIX timestamp (in milliseconds, e.g. 1095379198750) when the thread will be archived Some providers limit the lifetime of threads and automatically archive them after some time period of inactivity.
name
Name of retrieved thread
membersCount
Number of users participating in the thread
messagesCount
Number of messages in the retrieved thread
lastMessageAt
UNIX timestamp (in milliseconds, e.g. 1095379198750) when was the last message sent to thread.
rateLimit
Rate limit details.
bucket
Different parts of API may have different rate limits. Bucket identifies to which part of API the rate limits apply.
totalRequests
Total requests available in the time window.
remainingRequests
Remaining requests available in the time window.
remainingRequestsPercentage
Remaining requests available in the time window in percents.
resetTimestamp
Timestamp when the rate limits will reset (in Unix Timestamp ms format).
resetAfter
Number of seconds until reset of rate limit
retryAfter
Number of seconds until user can retry the request

Example

{
  "threads": [
    {
      "id": "1",
      "createdAt": 1546167104000,
      "channel": "random"
    }
  ]
}

Implementation details

Provider
mock
Use case
GetThreads
Author
@superface
Source
Verified