Sends message to one destination
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();
{
"destination": "C1H9RESGL",
"text": "Our app has 1,000,000 subscribers!"
}
{
"destination": "C1H9RESGL",
"messageId": "1503435956.000247"
}