We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Conditionally Deliver Message if Voicemail Detected.

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
headpill
Posts: 40
Joined: Mon Aug 17, 2015 9:34 pm

Conditionally Deliver Message if Voicemail Detected.

Post by headpill »

Hello, We are trying to write a VXML where we would like to do something like this.

IF "Voicemail" detected THEN

Play recorded message xxx.wav

IF "Voicemail" NOT detected THEN

Play a different message yyy.wav which will be followed by Menus/Choices (which will be also a recorded message) to choose and record User Input.

Here is the code for review, only issue we think is it doesnot know when to terminate the call, even the Voicemail detected it plays the correct wav file but goes to menu option as well.

Code: Select all


<form id="mainmsg">

<var name="callee_type" expr="'@callee_type'" /> 

<record cond="callee_type=='answeringmachine'" finalsilence="2000ms"/>
<block>
<prompt cond="callee_type=='answeringmachine'">
<audio src="http://myservername.com/Scripts/sample2.wav">
This message is for Answering Machine. 
</audio>
</prompt>

<prompt cond="callee_type!='answeringmachine'">
<audio src="http://myservername.com/Scripts/sample3.wav">
This message is for Regular Call.
</audio>
</prompt>
<goto next="#menuoptions" />
</block> 
</form>
<menu id="menuoptions" dtmf="true">
    <property name="inputmodes" value="dtmf"/>
    <prompt bargein="true" timeout="5s">
      <audio src="http://myservername.com/Scripts/menuoptionsforagnwithtransfer.wav">
      <voice name="Mike">
        To repeat this message, Press 1.
        To transfer this call to our office, Press 2.
        To put yourself on Do Not Call List, Press 9.
        To disconnect this call simply hang up.
      </voice>
      </audio>
    </prompt>
    <nomatch count="1">
      <prompt>
        <audio src="http://myservername.com/Scripts/nomatchcount12.wav">
        <voice name="Mike">
          Your input was not valid. Please Try again.
        </voice>
        </audio>
      </prompt>
      <reprompt/>
    </nomatch>
    <nomatch count="2">
      <prompt>
        <audio src="http://myservername.com/Scripts/noinputcount3.wav">
        <voice name="Mike">
          Thank You, Good Bye!
        </voice>
        </audio>
      </prompt>
      <exit/>
    </nomatch>

    <noinput count="1">
      <prompt>
        <audio src="http://myservername.com/Scripts/noinputcount12.wav">
        <voice name="Mike">
          You did not enter anything. Please try again.
        </voice>
        </audio>
      </prompt>
      <reprompt/>
    </noinput>
    <noinput count="2">
      <prompt>
        <audio src="http://myservername.com/Scripts/noinputcount3.wav">
        <voice name="Mike">
          Thank You, Good Bye!
        </voice>
        </audio>
      </prompt>
      <exit/>
    </noinput>
      
    <choice dtmf="1" next="#repeat">Repeat</choice>
    <choice dtmf="2" next="#transfer">Transfer</choice>
    <choice dtmf="9" next="#optout">Opt Out</choice>
  </menu>

  <form id="repeat">
    <block>
      <prompt bargein="true">
        <audio src="http://myservername.com/Scripts/timesheetreminder.wav">
        <voice name="Mike">
          This call is from xxx, to remind that your timesheet is due today, Please email us your approved timesheet at ts@xxx.com.
          Failure to submit your timesheet may result in not being paid or loss of accured leave.
          If you have any questions or need assistance regarding your timesheet, we can be reached during normal business hours at 1234567890
        </voice>
        </audio>
      </prompt>
      <goto next="#menuoptions" />
    </block>
  </form>

  <form id="transfer">
    
    <block>
      <assign name="CALL_RESULT" expr="'2'" />
      <data src="http://myservername.com/callresults.aspx" namelist="CALL_RESULT" method="post" />
    </block>
    <transfer dest="tel:+11234567890">
      <prompt bargein="false">
        <audio src="http://myservername.com/Scripts/reschedulewithtransfer.wav">
        <voice name="Mike">
          Please wait while we connect your call to our office.
        </voice>
        </audio>
      </prompt>
    </transfer>
    
  </form>
  
 <form id="optout">
    <block>
      <prompt bargein="true">
        <audio src="http://myservername.com/Scripts/optout.wav">
        <voice name="Mike">
          Sorry for the inconvenience; We will take you out from our calling list, please give us 24 hours time for the same.
        </voice>
        </audio>
      </prompt>
      <assign name="CALL_RESULT" expr="'9'" />
      <data src="http://myservername.com/callresults.aspx" namelist="CALL_RESULT" method="post" />
      <goto next="#finish" />
    </block>
  </form>

  <form id="finish">
    <block>
      <prompt bargein="true">
        <audio src="http://myservername.com/Scripts/goodbye.wav">
        <voice name="Mike">
          Thank you. Goodbye!
        </voice>
        </audio>
      </prompt>
    </block>
  </form>
</vxml>

Any help will be highly appreciated, let me know if you need more details.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Conditionally Deliver Message if Voicemail Detected.

Post by support »

Hi,

It looks like you're only missing a tiny detail that's causing your script to continue past the answering machine message. To manually trigger a disconnect, you can use the <disconnect> tag. This tag will manually trigger a connection.disconnect.hangup event (the normal event that occurs when a caller hangs up during a call).

We wrote your mainmsg form as such to accommodate this disconnect after playing the answering machine message (note we hard coded the callee_type, just for testing):

Code: Select all

<form id="mainmsg">
	<var name="callee_type" expr="'answeringmachine'" />

	<block>
		<if cond="callee_type=='answeringmachine'">
			<prompt>
			This message is for Answering Machine.
			</prompt>
			<disconnect/>
		<else/>
			<prompt>
			This message is for Regular Call.
			</prompt>
			<goto next="#menuoptions" />
		</if>
	</block>
</form>
This will basically branch on the callee_type and play a message and either move on, or end the call, based on the value. We weren't entirely sure what you were looking to do with the <record> tag at the beginning of your script, but if you're looking to record the call, you can use the recordcall property to record your whole call. Details can be found here:
http://www.plumvoice.com/docs/dev/voice ... recordcall

One additional thing we though would be beneficial to mention: By default, when you encounter the end of a <form> without any branching logic (no goto, submit, etc) the default behavior is to terminate the call when there is no valid option. For instance, this is why after your finish form the call ends. There's no <disconnect> or <exit> tag at the end, but as you can see, the call ends anyways. This, however, was not occurring, and your mainmgs form was falling through to your menu options because the last line of your mainmsg form was a <goto next="#menuoptions"/> which was causing your script to always flow through to your menu options, regardless of the callee_type.

Hopefully that helps. Please let us know if you have any additional questions.

Regards,
Plum Support

headpill
Posts: 40
Joined: Mon Aug 17, 2015 9:34 pm

Re: Conditionally Deliver Message if Voicemail Detected.

Post by headpill »

Thank You very much!
However, while message is delivered to Voicemail it is cutting off for first 17 sec of the 33 sec msg.
I think i need some final silence tag or something.
Since i am not using record tag where i can mention finalsilence, i do not know how to do this.

Can you help me in your same sample code how to prevent it from not cutting off the voicemail?

Code: Select all


<?xml version="1.0"?>
<vxml version="2.0">
<form id="mainmsg">
       <var name="callee_type" expr="'@callee_type'" />
	   
       <block>
          <if cond="callee_type=='answeringmachine'">
             <prompt>
			 
             This message is for Answering Machine.
			 
             </prompt>
             <disconnect/>
			
          <else/>
             <prompt>
			 
             This message is for Regular Call.
             
             </prompt>
             
          </if>
       </block>
  </form>
 </vxml>

Thanks.

headpill
Posts: 40
Joined: Mon Aug 17, 2015 9:34 pm

Re: Conditionally Deliver Message if Voicemail Detected.

Post by headpill »

Never mind i figured it out. I added <record cond="callee_type=='answeringmachine'" finalsilence="2000ms"/> and it is delivering msg perfectly on Voicemail.

However, i would like you to review the below vxml to confirm that this is going to work in long run.

Below is the code for review -

Code: Select all

<form id="mainmsg">

       <var name="callee_type" expr="'@callee_type'" />
	   
	   <record cond="callee_type=='answeringmachine'" finalsilence="2000ms"/>
	   
       <block>
	   
          <if cond="callee_type=='answeringmachine'">
		  
			  <prompt bargein="false">
				<audio src="http://myservername.com/Scripts/timesheetreminder.wav">
				  <voice name="Mike">
					Hello, This call is from xxxx., to remind that your timesheet is due today, Please email us your approved timesheet to xxxx@xxx.com. Failure to submit your timesheet may result in not being paid or loss of accured leave.
					If you have any questions or need assistance regarding your timesheet, we can be reached during normal business hours at 1234567890
				  </voice>
				</audio>
			  </prompt>
			  
			  <goto next="#finish" />
			  
             <disconnect/>
			
          <else/>
                <prompt bargein="false">
				<audio src="http://myservername.com/Scripts/timesheetreminder.wav">
				  <voice name="Mike">
					Hello, This call is from xxxx., to remind that your timesheet is due today, Please email us your approved timesheet to xxxx@xxx.com. Failure to submit your timesheet may result in not being paid or loss of accured leave.
					If you have any questions or need assistance regarding your timesheet, we can be reached during normal business hours at 1234567890
				  </voice>
				</audio>
			  </prompt>
			
             <goto next="#menuoptions" />
			 
          </if>
		  
       </block>
	   
  </form>

<menu id="menuoptions" dtmf="true">
    <property name="inputmodes" value="dtmf"/>
    <prompt bargein="true" timeout="5s">
      <audio src="http://myservername.com/Scripts/menuoptionsforagnwithtransfer.wav">
      <voice name="Mike">
        To repeat this message, Press 1.
        To transfer this call to our office, Press 2.
        To put yourself on Do Not Call List, Press 9.
        To disconnect this call simply hang up.
      </voice>
      </audio>
    </prompt>
    <nomatch count="1">
      <prompt>
        <audio src="http://myservername.com/Scripts/nomatchcount12.wav">
        <voice name="Mike">
          Your input was not valid. Please Try again.
        </voice>
        </audio>
      </prompt>
      <reprompt/>
    </nomatch>
    <nomatch count="2">
      <prompt>
        <audio src="http://myservername.com/Scripts/noinputcount3.wav">
        <voice name="Mike">
          Thank You, Good Bye!
        </voice>
        </audio>
      </prompt>
      <exit/>
    </nomatch>

    <noinput count="1">
      <prompt>
        <audio src="http://myservername.com/Scripts/noinputcount12.wav">
        <voice name="Mike">
          You did not enter anything. Please try again.
        </voice>
        </audio>
      </prompt>
      <reprompt/>
    </noinput>
    <noinput count="2">
      <prompt>
        <audio src="http://myservername.com/Scripts/noinputcount3.wav">
        <voice name="Mike">
          Thank You, Good Bye!
        </voice>
        </audio>
      </prompt>
      <exit/>
    </noinput>
      
    <choice dtmf="1" next="#repeat">Repeat</choice>
    <choice dtmf="2" next="#transfer">Transfer</choice>
    <choice dtmf="9" next="#optout">Opt Out</choice>
  </menu>

  <form id="repeat">
    <block>
      <prompt bargein="true">
        <audio src="http://myservername.com/Scripts/timesheetreminder.wav">
        <voice name="Mike">
          This call is from xxx, to remind that your timesheet is due today, Please email us your approved timesheet at ts@xxx.com.
          Failure to submit your timesheet may result in not being paid or loss of accured leave.
          If you have any questions or need assistance regarding your timesheet, we can be reached during normal business hours at 1234567890
        </voice>
        </audio>
      </prompt>
      <goto next="#menuoptions" />
    </block>
  </form>

  <form id="transfer">
    
    <block>
      <assign name="CALL_RESULT" expr="'2'" />
      <data src="http://myservername.com/callresults.aspx" namelist="CALL_RESULT" method="post" />
    </block>
    <transfer dest="tel:+11234567890">
      <prompt bargein="false">
        <audio src="http://myservername.com/Scripts/reschedulewithtransfer.wav">
        <voice name="Mike">
          Please wait while we connect your call to our office.
        </voice>
        </audio>
      </prompt>
    </transfer>
    
  </form>
  
 <form id="optout">
    <block>
      <prompt bargein="true">
        <audio src="http://myservername.com/Scripts/optout.wav">
        <voice name="Mike">
          Sorry for the inconvenience; We will take you out from our calling list, please give us 24 hours time for the same.
        </voice>
        </audio>
      </prompt>
      <assign name="CALL_RESULT" expr="'9'" />
      <data src="http://myservername.com/callresults.aspx" namelist="CALL_RESULT" method="post" />
      <goto next="#finish" />
    </block>
  </form>

  <form id="finish">
    <block>
      <prompt bargein="true">
        <audio src="http://myservername.com/Scripts/goodbye.wav">
        <voice name="Mike">
          Thank you. Goodbye!
        </voice>
        </audio>
      </prompt>
    </block>
  </form>
</vxml>
Thank You.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Conditionally Deliver Message if Voicemail Detected.

Post by support »

Hi,

We were in the middle of a reply, but yes, that is exactly the solution we were envisioning.

Briefly looking at your code, we did not find anything that would cause problems in the long run.

Regards,
Plum Support

Post Reply