Subscribing to an Existing Connection
To subscribe to an existing connection, you can use the subscribeToConnection
method with the Subscribe API.
The Subscribe API allows you to connect to a conversation or a meeting in listen-only mode. Read more about Subscribe API here.
Authentication
Your Symbl API Credentials, that is, your App ID and App Secret are required for authentication. Learn how to get them in the Authenticate section.
View the Importing section for the various ways to import the Web SDK.
(async () => {
try {
// We recommend to remove appId and appSecret authentication for production applications.
// See authentication section for more details
const symbl = new Symbl({
appId: '<your App ID>',
appSecret: '<your App Secret>',
// accessToken: '<your Access Toknen>'
});
// Open a Symbl Streaming API WebSocket Connection.
const connection = await symbl.subscribeToConnection("<YOUR SESSION ID>");
// Retrieve real-time transcription from the conversation
connection.on("speech_recognition", (speechData) => {
const { punctuated } = speechData;
const name = speechData.user ? speechData.user.name : "User";
console.log(`${name}: `, punctuated.transcript);
});
// This is just a helper method meant for testing purposes.
// Waits 60 seconds before continuing to the next API call.
await Symbl.wait(60000);;
// Closes the WebSocket connection.
connection.disconnect();
} catch(e) {
// Handle errors here.
}
})();
Updated 4 days ago
Did this page help you?