/webrtc-bot-example

Electron-based Bot utilizing the WebRTC capabilities of the Circuit JS SDK

Primary LanguageJavaScriptApache License 2.0Apache-2.0

webrtc-bot-example

Electron-based Bot utilizing the WebRTC capabilities of the Circuit JS SDK.

Electron is based on node.js and Chromium and is therefore able to utilize the Circuit JS WebRTC APIs unlike a regular node.js app.

Scenarios covered in this example:

Greet participants by name when joining a conference

  • Using callStatus event listen for participants joining
  • Use IBM Text to Speech service to generate audio buffer for greeting
  • Use the AudioContext of the Web Audio API to convert the audio buffer to a MediaStream
  • Use the new setAudioVideoStream API to transmit the greeting to the conference

Detect 5s of silence and play an announcement

  • Use client.getRemoteStreams and attach remote audio stream to an audio element (could also be done via call.remoteAudioStream)
  • Use client.getLastRtpStats to get AudioLevelOutput statistics to detect 5s of silence
  • Use IBM Text to Speech, Web Audio API and setAudioVideoStream to play audio as in scenario above

Getting Started

Run the app

    git clone https://github.com/circuit/webrtc-bot-example.git
    cd webrtc-bot-example
    cp config.json.template config.json
    // Edit config.json with your credentials
    npm install
    npm start // or npm run dev