
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@sinch/conversation
Advanced tools
This package contains the Sinch Conversation SDK for Node.js for use with Sinch APIs. To use it, you will need a Sinch account. Please sign up or log in if you already have one.
We recommend to use this SDK as part of the @sinch/sdk-core package as it will take care about the authentication plugins to use.
However, it's still possible to use this SDK standalone is you need to access the Conversation API only.
npm install @sinch/conversation
yarn add @sinch/conversation
The Conversation API uses the Sinch unified authentication with OAuth2. You will need to provide the following credentials:
If you are using this SDK as part of the Sinch SDK (@sinch/sdk-core) you can access it as the conversation property of the client that you would have instantiated.
import {
ConversationService,
SinchClient,
UnifiedCredentials,
Conversation,
} from '@sinch/sdk-core';
const credentials: UnifiedCredentials = {
projectId: 'PROJECT_ID',
keyId: 'KEY_ID',
keySecret: 'KEY_SECRET',
};
// Access the 'conversation' service registered on the Sinch Client
const sinch = new SinchClient(credentials);
const conversationService: ConversationService = sinch.conversation;
// Build the request data
const requestData: Conversation.SendMessageRequestData = {
sendMessageRequestBody: {
app_id: 'CONVERSATION_APP_ID',
message: {
text_message: {
text: 'Text message from Sinch',
},
},
recipient: {
contact_id: 'CONTACT_ID',
},
channel_priority_order: [
'WHASAPP',
],
},
};
// Use the 'conversation' service registered on the Sinch client
const result: Conversation.SendMessageResponse
= await conversationService.messages.send(requestData);
The SDK can be used standalone if you need to use only the Conversation APIs.
import {
UnifiedCredentials,
} from '@sinch/sdk-client';
import {
ConversationService,
Conversation,
} from '@sinch/conversation';
const credentials: UnifiedCredentials = {
projectId: 'PROJECT_ID',
keyId: 'KEY_ID',
keySecret: 'KEY_SECRET',
};
// Declare the 'conversation' service in a standalone way
const conversationService = new ConversationService(options);
// Build the request data
const requestData: Conversation.SendMessageRequestData = {
sendMessageRequestBody: {
app_id: 'CONVERSATION_APP_ID',
message: {
text_message: {
text: 'Text message from Sinch',
},
},
recipient: {
contact_id: 'CONTACT_ID',
},
channel_priority_order: [
'WHASAPP',
],
},
};
// Use the standalone declaration of the 'conversation' service
const result: Conversation.SendMessageResponse
= await conversationService.messages.send(requestData);
All the methods that interact with the Sinch APIs use Promises. You can use await in an async method to wait for the response, or you can resolve them yourself with then() / catch().
// Method 1: Wait for the Promise to complete
let result: Conversation.SendMessageResponse;
try {
result = await conversationService.messages.send(requestData);
console.log(`Message sent successfully. Message Id: ${result.id}`);
} catch (error: any) {
console.error(`ERROR ${error.statusCode}: `);
}
// Method 2: Resolve the promise
conversationService.messages.send(requestData)
.then(response => console.log(`Message sent successfully. Message Id: ${result.id}`))
.catch(error => console.error(`ERROR ${error.statusCode}: `));
Developer Experience team: devexp@sinch.com
FAQs
Sinch Conversation API
We found that @sinch/conversation demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.