Chat Messages

chat/messages@1.0.1
Supported by 2 providers
D
S

Get chat messages

Retrieve paginated list of messages

Input
Destination
After Timestamp
Before Timestamp
Limit
Page
Result
Messages
Next Page
Rate Limit

1.Choose a provider

2.Use GetMessages with mock in your code

npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

const sdk = new SuperfaceClient();

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

  // Use the profile
  const result = await profile
    .getUseCase('GetMessages')
    .perform({
      destination: 'general',
      limit: 2
    }, {
      provider: 'mock'
    });

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

run();

Structure details

Input (object)

destination
Representation of a messaging destination. Can be ID or channel name, depending on the provider capability.
afterTimestamp
Retrieve only messages after the given UNIX timestamp (in milliseconds, e.g. 1095379198750)
beforeTimestamp
Retrieve only messages before the given UNIX timestamp (in milliseconds, e.g. 1095379198750)
limit
Maximum number of messages to retrieve in one page
page
Identification of page with paginated results (cursor)

Example

{
  "destination": "general",
  "limit": 2
}

Result (object)

messages
List of retrieved messages
nextPage
Cursor to the next page for pagination forwards
rateLimit
Rate limit details.

Example

{
  "messages": [
    {
      "id": "1",
      "author": {
        "id": "U01",
        "username": "user1"
      },
      "createdAt": 1643835553658.259,
      "text": "test 1"
    }
  ]
}

Implementation details

Provider
mock
Use case
GetMessages
Author
@superface
Source
Verified