Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to transfer current call #5

Open
AI-General opened this issue Feb 8, 2024 · 1 comment
Open

How to transfer current call #5

AI-General opened this issue Feb 8, 2024 · 1 comment

Comments

@AI-General
Copy link

Now I am in call with real number 1.

I need to transfer number 1 to number 2.

I used this code:

    transfer() {
        vonage.voice.transferCallWithNCCO(this.call_id, [
            {
                action: 'talk',
                text: 'Hello, you are being connected, please wait...'
            },
            {
                "action": "connect",
                "endpoint": [{
                    "type": "phone",
                    "number": BOSS_NUMBER,
                    "dtmfAnswer": "auto"
                }]
            }], (err, res) => {
                if (err) {
                    console.error(err);
                } else {
                    console.log(res);
                }
            });
    };

But I met following error:

            throw new vetch_1.VetchError(`Request failed with status code ${response.status}`, request, response);
                  ^

VetchError: Request failed with status code 400
    at Voice.parseResponse (/root/VoiceBot/vonage/node_modules/@vonage/server-client/dist/client.js:302:19)
    at Voice.sendRequest (/root/VoiceBot/vonage/node_modules/@vonage/server-client/dist/client.js:221:31)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Voice.sendRequestWithData (/root/VoiceBot/vonage/node_modules/@vonage/server-client/dist/client.js:196:16)
    at async Voice.callAction (/root/VoiceBot/vonage/node_modules/@vonage/voice/dist/voice.js:476:9) {
  config: {
    url: 'https://api.nexmo.com/v1/calls/60ce05e1-7c69-4281-b2f4-37e0586eeb39',
    method: 'PUT',
    type: 'application/json',
    data: {
      action: 'transfer',
      destination: {
        type: 'ncco',
        ncco: [
          {
            action: 'talk',
            text: 'Hello, you are being connected, please wait...'
          },
          { action: 'connect', endpoint: [Array] }
        ]
      }
    },
    headers: {
      'user-agent': '@vonage/server-sdk/3.0.0, node/18.17.1,',
      'content-type': 'application/json',
      Authorization: 'Bearer <My token>'
    }
  },
  response: Response {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: {
      body: PassThrough {
        _readableState: ReadableState {
          objectMode: false,
          highWaterMark: 16384,
          buffer: BufferList { head: [Object], tail: [Object], length: 1 },
          length: 146,
          pipes: [],
          flowing: null,
          ended: true,
          endEmitted: false,
          reading: false,
          constructed: true,
          sync: false,
          needReadable: false,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          errorEmitted: false,
          emitClose: true,
          autoDestroy: true,
          destroyed: false,
          errored: null,
          closed: false,
          closeEmitted: false,
          defaultEncoding: 'utf8',
          awaitDrainWriters: null,
          multiAwaitDrain: false,
          readingMore: false,
          dataEmitted: false,
          decoder: null,
          encoding: null,
          [Symbol(kPaused)]: null
        },
        _events: [Object: null prototype] {
          prefinish: [Function: prefinish],
          error: [Function (anonymous)]
        },
        _eventsCount: 2,
        _maxListeners: undefined,
        _writableState: WritableState {
          objectMode: false,
          highWaterMark: 16384,
          finalCalled: true,
          needDrain: false,
          ending: true,
          ended: true,
          finished: true,
          destroyed: false,
          decodeStrings: true,
          defaultEncoding: 'utf8',
          length: 0,
          writing: false,
          corked: 0,
          sync: false,
          bufferProcessing: false,
          onwrite: [Function: bound onwrite],
          writecb: null,
          writelen: 0,
          afterWriteTickInfo: null,
          buffered: [],
          bufferedIndex: 0,
          allBuffers: true,
          allNoop: true,
          pendingcb: 0,
          constructed: true,
          prefinished: true,
          errorEmitted: false,
          emitClose: true,
          autoDestroy: true,
          errored: null,
          closed: false,
          closeEmitted: false,
          [Symbol(kOnFinished)]: []
        },
        allowHalfOpen: true,
        [Symbol(kCapture)]: false,
        [Symbol(kCallback)]: null
      },
      disturbed: false,
      error: null
    },
    [Symbol(Response internals)]: {
      url: 'https://api.nexmo.com/v1/calls/60ce05e1-7c69-4281-b2f4-37e0586eeb39',
      status: 400,
      statusText: 'Bad Request',
      headers: Headers {
        [Symbol(map)]: [Object: null prototype] {
          date: [ 'Thu, 08 Feb 2024 20:11:53 GMT' ],
          'content-type': [ 'application/json' ],
          'content-length': [ '146' ],
          connection: [ 'close' ],
          server: [ 'envoy' ],
          'x-nexmo-trace-id': [ '7624fee7-a0f4-4dd6-babf-05136976e6fd' ],
          'x-vonage-region': [ 'us-3' ],
          'x-envoy-upstream-service-time': [ '63' ],
          'content-disposition': [ 'attachment; filename="api.txt"' ],
          'x-frame-options': [ 'deny' ],
          'x-xss-protection': [ '1; mode=block' ],
          'strict-transport-security': [ 'max-age=31536000; includeSubdomains' ],
          'x-content-type-options': [ 'nosniff' ],
          'x-ratelimit-limit': [
            '200, 200;w=1;name="crd|account_id|generic_key^nexmo-vapi.vapi|generic_key^solo.setDescriptor.uniqueValue"'
          ],
          'x-ratelimit-remaining': [ '199' ],
          'x-ratelimit-reset': [ '1' ]
        }
      },
      counter: 0
    }
  }
}

How to fix this?

Please help me.

Thank you

@AI-General
Copy link
Author

Should I use 2 vonage phone for this?

Actually, if I use 2 vonage phone numbers, is it possible,
I just need to make 2 websocket tunnel and transfer messages.
But I want to do that without vonage phone.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant