right  Talk To Us!

Code Bites


  • Answer a call and use Text-to-speech (TTS) to say a message to the caller:

    CallState state = channel.Answer();
    if (state == CallState.Answered)
    {
    	channel.FilePlayer.Say("Hello. Thank you for calling.");
    }

    Play a media file, allowing the caller to press a key to interrupt:

    FilePlayerCause playCause = channel.FilePlayer.Play("welcome.wav", true);
    if (FilePlayerCause.BargeIn == playCause)
    {
    	this.Trace.TraceInfo("Playback was interrupted by a keypress");
    }

    Record a message from the caller, allowing the caller to press a key to end the recording:

    string recordFileName = "recordedMessages/MessageFrom" + channel.CallDetails.CallFrom + ".wav";
    channel.FileRecorder.Start(recordFileName, true);
    
    // Play a tone to signal that recording has started
    channel.DtmfPlayer.Play("0");
    
    channel.FileRecorder.WaitUntilFinished(60);
  • Answer a call and use Text-to-speech (TTS) to say a message to the caller:

    state = channel.answer()
    if state == channel.State.ANSWERED:
    	cause = channel.FilePlayer.say("Hello. Thank you for calling.")

    Play a media file, allowing the caller to press a key to interrupt:

    cause = channel.FilePlayer.play("welcome.wav", barge_in=True)
    if cause == channel.FilePlayer.Cause.BARGEIN:
    	my_log.info("Playback was interrupted by a keypress")

    Record a message from the caller, allowing the caller to press a key to end the recording:

    record_file_name = "recorded_messages/message_from_{0}.wav".format(channel.Details.call_from)
    channel.FileRecorder.start(record_file_name, barge_in=True)
    
    # Play a tone to signal that recording has started
    channel.DTMFPlayer.play('0')
    
    channel.FileRecorder.wait_until_finished(seconds_timeout=60)
  • Answer a call and use Text-to-speech (TTS) to say a message to the caller:

    Dim state = channel.Answer()
    If state = CallState.Answered Then
    	channel.FilePlayer.Say("Hello. Thank you for calling.")
    End If

    Play a media file, allowing the caller to press a key to interrupt:

    Dim playCause = channel.FilePlayer.Play("welcome.wav", True)
    If playCause = FilePlayerCause.BargeIn Then
    	Me.Trace.TraceInfo("Playback was interrupted by a keypress")
    End If

    Record a message from the caller, allowing the caller to press a key to end the recording:

    Dim recordFileName = "recordedMessages/MessageFrom" + channel.CallDetails.CallFrom + ".wav"
    channel.FileRecorder.Start(recordFileName, True)
    
    ' Play a tone to signal that recording has started
    channel.DtmfPlayer.Play("0")
    
    channel.FileRecorder.WaitUntilFinished(60)
  • Answer a call and use Text-to-speech (TTS) to say a message to the caller:

    if channel.Answer() = CallState.Answered then
    	channel.FilePlayer.Say("Hello. Thank you for calling.") |> ignore

    Play a media file, allowing the caller to press a key to interrupt:

    let playCause = channel.FilePlayer.Play("welcome.wav", true)
    if playCause = FilePlayerCause.BargeIn then
    	obj.Trace.TraceInfo("Playback was interrupted by a keypress")

    Record a message from the caller, allowing the caller to press a key to end the recording:

    let recordFileName = "recordedMessages/MessageFrom" + channel.CallDetails.CallFrom + ".wav"
    if channel.FileRecorder.Start(recordFileName, true) then
    					
    	// Play a tone to signal that recording has started
    	channel.DtmfPlayer.Play("0") |> ignore
    
    	channel.FileRecorder.WaitUntilFinished(60) |> ignore