指名された会話を録音する

会話を録音する方法を示すコード・スニペット。着信に応答し 着信に応答し、発呼側を指定された会話に参加させるNCCOを返す。によって 設定 record をtrueに設定すると、会話が録音され、通話が完了すると に送信されます。 eventUrl を指定します。ウェブフックには 録画のURL

Prerequisites

npm install express body-parser

Write the code

Add the following to record-a-conversation.js:

const Express = require('express');
const bodyParser = require('body-parser');

const app = new Express();
app.use(bodyParser.json());

const onInboundCall = (request, response) => {
  const ncco = [
    {
      'action': 'conversation',
      'name': VOICE_CONF_NAME,
      'record': 'true',
      'eventMethod': 'POST',
      'eventUrl': [`${request.protocol}://${request.get('host')}/webhooks/recordings`],
    },
  ];

  response.json(ncco);
};

const onRecording = (request, response) => {
  const recording_url = request.body?.recording_url;
  console.log(`Recording URL = ${recording_url}`);

  response.status(204).send();
};

app
  .get('/webhooks/answer', onInboundCall)
  .post('/webhooks/recordings', onRecording);

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`);
});

View full source

Run your code

Save this file to your machine and run it:

node record-a-conversation.js

試してみる

必要なのは

  1. Vonage番号(このコードスニペット)にダイヤルして会話を録音します。
  2. 録画をダウンロードするを見る 録音をダウンロードする のコード・スニペットで説明している。

さらに読む

  • 通話録音 - 通話相手からの音声入力を録音したり、2人の通話相手の会話を録音する。