Skip to content

Commit 1dbb310

Browse files
author
marcel corso gonzalez
authored
Merge pull request #54 from zeddee/implement-onfinish-recording
implemented onFinish attribute for CallFlowRecordStep
2 parents 6f6cdb0 + 042cdb0 commit 1dbb310

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

voice/callflow.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,20 @@ type CallFlowRecordStep struct {
443443
//
444444
// Allowed values: de-DE, en-AU, en-UK, en-US, es-ES, es-LA, fr-FR, it-IT, nl-NL, pt-BR.
445445
TranscribeLanguage string
446+
447+
// (Optional) OnFinish contains the URL to get a new CallFlow from when the recording terminates and this CallFlowRecordStep ends.
448+
//
449+
// The URL must contain a schema e.g. http://... or https://...
450+
// This attribute is used for chaining call flows. When the current step ends,
451+
// a POST request containing information about the recording is sent to the URL specified.
452+
// This gets a new callflow from the URL specified, but re-uses the original Call ID and Leg ID i.e. it's the same Call.
453+
//
454+
// To get at the recording information from the POST request body, you must call (instead of relying on req.Form):
455+
// ```go
456+
// body,_ := ioutil.ReadAll(req.Body)
457+
// recordingInfo := string(body[:])
458+
// ```
459+
OnFinish string
446460
}
447461

448462
type jsonCallFlowRecordStep struct {
@@ -454,6 +468,7 @@ type jsonCallFlowRecordStep struct {
454468
FinishOnKey string `json:"finishOnKey"`
455469
Transcribe bool `json:"transcribe"`
456470
TranscribeLanguage string `json:"transcribeLanguage"`
471+
OnFinish string `json:"onFinish"`
457472
} `json:"options"`
458473
}
459474

@@ -467,6 +482,7 @@ func (step *CallFlowRecordStep) MarshalJSON() ([]byte, error) {
467482
data.Options.FinishOnKey = step.FinishOnKey
468483
data.Options.Transcribe = step.Transcribe
469484
data.Options.TranscribeLanguage = step.TranscribeLanguage
485+
data.Options.OnFinish = step.OnFinish
470486
return json.Marshal(data)
471487
}
472488

@@ -483,6 +499,7 @@ func (step *CallFlowRecordStep) UnmarshalJSON(data []byte) error {
483499
FinishOnKey: raw.Options.FinishOnKey,
484500
Transcribe: raw.Options.Transcribe,
485501
TranscribeLanguage: raw.Options.TranscribeLanguage,
502+
OnFinish: raw.Options.OnFinish,
486503
}
487504
return nil
488505
}

0 commit comments

Comments
 (0)