Superface

Send a message

chat/send-message@1.0.2
2 providers

Send Message

Sends message to one destination

Input
Destination
Text
Result
Message ID
Destination
Rate Limit

1.Choose a provider

2.Use SendMessage 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/send-message@1.0.2');

  // Use the profile
  const result = await profile
    .getUseCase('SendMessage')
    .perform({
      destination: 'C1H9RESGL',
      text: 'Our app has 1,000,000 subscribers!'
    }, {
      provider: 'mock'
    });

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

run();

Structure details

Input (object)

destination
Channel to send the message to
text
Contents of the message

Example

{
  "destination": "C1H9RESGL",
  "text": "Our app has 1,000,000 subscribers!"
}

Result (object)

messageId
Identifier of the message that was sent
destination
Identifier of the destination where the message was sent.
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

{
  "destination": "C1H9RESGL",
  "messageId": "1503435956.000247"
}

Implementation details

Provider
mock
Use case
SendMessage
Author
@superface
Source
Verified