Last active
April 12, 2021 11:34
-
-
Save mjg123/913904cfa6ec7edde06fd8c26d9aa6fc to your computer and use it in GitHub Desktop.
Kotlin code generating some TwiML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.twilio.twiml.VoiceResponse | |
import com.twilio.twiml.voice.Pause | |
import com.twilio.twiml.voice.Record | |
import com.twilio.twiml.voice.Say | |
fun main(args: Array<String>){ | |
val record = Record.Builder() | |
.timeout(8).transcribe(true) | |
.recordingStatusCallback("https://webhook.site/a6340ade-e239-4276-b488-67f4428c6cab") | |
.transcribeCallback("https://webhook.site/a6340ade-e239-4276-b488-67f4428c6cab") | |
.recordingStatusCallbackEvents(listOf( | |
Record.RecordingEvent.IN_PROGRESS, | |
Record.RecordingEvent.COMPLETED, | |
Record.RecordingEvent.ABSENT | |
)) | |
.build() | |
val say = Say.Builder("Please say your unique id to confirm registration.") | |
.voice(Say.Voice.ALICE) | |
.build() | |
val pause = Pause.Builder().length(8).build() | |
val voiceResponse = VoiceResponse.Builder() | |
.say(say) | |
.record(record) | |
.pause(pause) | |
.build() | |
println(voiceResponse.toXml()) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Response> | |
<Say voice="alice">Please say your unique id to confirm registration.</Say> | |
<Record recordingStatusCallback="https://webhook.site/a6340ade-e239-4276-b488-67f4428c6cab" | |
recordingStatusCallbackEvent="in-progress completed absent" | |
timeout="8" | |
transcribe="true" | |
transcribeCallback="https://webhook.site/a6340ade-e239-4276-b488-67f4428c6cab"/> | |
<Pause length="8"/> | |
</Response> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment