Skip to main content

Connect to Endpoints

The code snippet below dials in using PSTN and hangs up after 60 seconds.

const {
sdk
} = require('symbl-node');
sdk.init({
// APP_ID and APP_SECRET come from the Symbl Platform: https://platform.symbl.ai
appId: APP_ID,
appSecret: APP_SECRET,
basePath: 'https://api.symbl.ai'
}).then(() => {
sdk.startEndpoint({
endpoint: {
type: 'pstn', // This can be pstn or sip
phoneNumber: PHONE_NUMBER, // Use international code.
dtmf: DTMF_MEETING_ID // if password protected, use "dtmf": "<meeting_id>#,#<password>#"
}
}).then(connection => {
console.log('Successfully connected.', connection.connectionId);
// Scheduling stop endpoint call after 60 seconds for demonstration purposes
// In real adoption, sdk.stopEndpoint() should be called when the meeting or call actually ends
setTimeout(() => {
sdk.stopEndpoint({
connectionId: connection.connectionId
}).then(() => {
console.log('Stopped the connection');
console.log('Summary Info:', connection.summaryInfo);
console.log('Conversation ID:', connection.conversationId);
}).catch(err => console.error('Error while stopping the connection', err));
}, 60000);
}).catch(err => console.error('Error while starting the connection', err));
}).catch(err => console.error('Error in SDK initialization.', err));

We recommend using SIP whenever possible instead of PSTN as it provides higher audio quality options as compared to PSTN. SIP endpoint provides an optional audio configuration as well.

Testing#

Create a javascript file named app.js and copy this code into the file. Fill in the placeholder values with the proper values. Use npm to install the required libraries: npm install symbl-node. Now in the terminal run

$ node app.js

If successful you should receive a response in the console.

info

If you have any questions or concerns about our API, you can join our Support Slack or send us an email at developer@symbl.ai