Transfer a call with inline NCCO

A code snippet that shows how to transfer control of the current call to control using inline NCCO.


Replace the following variables in the example code:

Key Description
UUID The UUID of the call to modify.
action The action to use in updating the call. In this case transfer.


Use your existing application

Modifying an existing call requires that the UUID provided is a currently active call. To modify a call, you must use the same NEXMO_APPLICATION_ID and private key that were used to create the call.

Install dependencies

gem install nexmo
Initialize your dependencies

Create a file named transfer-a-call-ncco.rb and add the following code:

Copy to Clipboard
require 'nexmo'

client =
  application_id: NEXMO_APPLICATION_ID,

View full source

Write the code

Add the following to transfer-a-call-ncco.rb:

Copy to Clipboard
ncco = {
  "type": 'ncco',
  "ncco": [
    "action": 'talk',
    "text": 'This is a transfer action using an inline NCCO'

response = client.calls.transfer(UUID, destination: ncco)

puts response.inspect

View full source

Run your code

Save this file to your machine and run it:

ruby transfer-a-call-ncco.rb

Try it out

You will need to:

  1. Set up a call and obtain the call UUID. You could use the 'connect an inbound call' code snippet to do this.
  2. Run the example code to transfer the call.
  3. Control will be transferred to a new NCCO, and you will hear a text-to-speech message to confirm this.