Skip to main content

Receive Live AI Insights

This example goes over how you can use the Symbl Streaming API to receive Insights, which are what the Symbl API determines to be the most important keywords or phrases used in a conversation. This example uses both the Symbl's Javascript SDK, which is meant to be run using Node.js, and native Javascript which can be run in the browser:

Connect#

The first thing we do is connect to the Web Socket using the SDK. If you're using the SDK you can use onInsightResponse handler after the connection is established, otherwise you'll have to parse the response in the onmessage callback for the WebSocket.

const {sdk} = require('symbl-node');
const uuid = require('uuid').v4;
(async () => {
try {
// Initialize the SDK
await sdk.init({
appId: appId,
appSecret: appSecret,
basePath: 'https://api.symbl.ai',
})
// Need unique Id
const id = uuid()
// Start Real-time Request (Uses Real-time WebSocket API behind the scenes)
const connection = await sdk.startRealtimeRequest({
id,
insightTypes: ['action_item', 'question'],
config: {
meetingTitle: 'My Test Meeting',
confidenceThreshold: 0.7,
timezoneOffset: 480, // Offset in minutes from UTC
languageCode: 'en-US',
sampleRateHertz: 44100,
},
speaker: {
// Optional, if not specified, will simply not send an email in the end.
userId: 'emailAddress', // Update with valid email
name: 'My name'
},
handlers: {
/**
* When Symbl detects an insight, this callback will be called.
*/
onInsightResponse: (data) => {
console.log('onInsightResponse', JSON.stringify(data, null, 2))
},
}
});
} catch (e) {
console.error(e);
}
})();

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 uuid. Now in the terminal run

$ node app.js

If successful you should receive a response in the console.

Handlers Reference#

  • handlers: This object has the callback functions for different events

    • onInsightResponse: This callback provides you with any of the detected insights in real-time as they are detected. As with the onMessageCallback this would also return every speaker's insights in case of multiple streams.

      [{
      "id": "94020eb9-b688-4d56-945c-a7e5282258cc",
      "confidence": 0.9909798145016999,
      "messageReference": {
      "id": "94020eb9-b688-4d56-945c-a7e5282258cc"
      },
      "hints": [{
      "key": "informationScore",
      "value": "0.9782608695652174"
      }, {
      "key": "confidenceScore",
      "value": "0.9999962500210938"
      }, {
      "key": "comprehensionScore",
      "value": "0.9983848333358765"
      }],
      "type": "action_item",
      "assignee": {
      "id": "e2c5acf8-b9ed-421a-b3b3-02a5ae9796a0",
      "name": "John Doe",
      "userId": "emailAddress"
      },
      "dueBy": {
      "value": "2021-02-05T00:00:00-07:00"
      },
      "tags": [{
      "type": "date",
      "text": "today",
      "beginOffset": 39,
      "value": {
      "value": {
      "datetime": "2021-02-05"
      }
      }
      }, {
      "type": "person",
      "text": "John Doe",
      "beginOffset": 8,
      "value": {
      "value": {
      "name": "John Doe",
      "id": "e2c5acf8-b9ed-421a-b3b3-02a5ae9796a0",
      "assignee": true,
      "userId": "emailAddress"
      }
      }
      }],
      "dismissed": false,
      "payload": {
      "content": "Perhaps John Doe can submit the report today.",
      "contentType": "text/plain"
      },
      "from": {
      "id": "e2c5acf8-b9ed-421a-b3b3-02a5ae9796a0",
      "name": "John Doe",
      "userId": "emailAddress"
      }
      }]