Link Search Menu Expand Document

NCCO (Nexmo Call Control Object) is the format for describing the various actions that will take place during a call. Check the NCCO reference on the developer portal for full details, but examples of each action are included in the sections below.

The basic approach is to create an NCCO, then create actions to add into it:

	MyNcco := ncco.Ncco{}
	talk := ncco.TalkAction{Text: "Greetings from the golang library", VoiceName: "Nicole"}
	MyNcco.AddAction(talk)

Talk Action

Create a talk action to read some text into the call:

	talk := ncco.TalkAction{Text: "Greetings from the golang library", VoiceName: "Nicole"}

Notify Action

Use notify to send a particular data payload to a nominated URL:

	url := []string{"https://example.com/webhooks/notify"}
	data := make(map[string]string)
	data["stage"] = "Registration"
	ping := ncco.NotifyAction{EventUrl: url, Payload: data}

This feature is useful for marking progress through a call and that the user is still connected.

Record Action

Send a record action to start a recording:

    record := ncco.RecordAction{BeepStart: true}

When the recording completes, Vonage sends a webhook containing the recording URL so that you can download the file.

Conversation Action

Adds the call to a conversation:

    conversation := ncco.ConversationAction{Name: "convo1"}

Stream Action

Play an mp3 file into a call as an audio stream:

    stream := ncco.StreamAction{StreamUrl: []string{"https://example.com/music.mp3"}}

Connect Action

Connects the current call to another endpoint (currently only phone is supported):

    endpoint := []ncco.PhoneEndpoint{Number: "44777000777"}
	connect := ncco.ConnectAction{Endpoint: endpoint, From: "44777000888"}

The from field when connecting to a phone endpoint should be a Vonage number that you own.