<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks so much, William. This gives me a great start.<br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">--</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Greg</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><br></p></div></div></span><br class="Apple-interchange-newline"> </div><br><div><div>On Aug 4, 2009, at 7:04 PM, William Suffill wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>I wrote some notes on this but have yet to wiki it.<br><br>example of an outbound socket connection where the call is answered, a<br>variable is set then perhaps play one of the pre-installed files and<br>hangup.<br>ivrd<br><br>fs_ivrd comes with freeswitch. It being a small daemon just invokes<br>the script defined in a variable and passes data from it via STDIN/OUT<br><br>Since this is an outbound socket connections it needs to be defined in<br>the dialplan.<br><br><br><br>Ex:<br><br><extension name="outbound-socket"><br><br> <condition field="destination_number" expression="^55(522)$"><br><br> <action application="set"<br>data="ivr_path=/usr/local/freeswitch/scripts/ivrd-demo.php"/><br><br> <action application="socket" data="127.0.0.1:8084 async full"/><br><br> </condition><br><br> </extension><br><br><br><br>The above dialplan sample would invoke ivr-demo.php when 55522 is<br>called as long as fs_ivrd is running. To start fs_ivrd:<br><br>/usr/local/freeswitch/bin/fs_ivrd -h 127.0.0.1 -p 8004<br><br><br><br>It takes 2 arguments -h for hostname and -p for port.<br><br><br><br>PHP Code<br><br>#!/usr/bin/php -q<br><br><?php<br><br><br><br> // set a couple of things so we dont kill the system<br><br> ob_implicit_flush(true);<br><br> set_time_limit(30);<br><br><br><br><br><br> // Open stdin so we can read the AGI data in<br><br> $in = fopen("php://stdin", "r");<br><br> // Connect<br><br> echo "connect\n\n";<br><br> // Answer<br><br> echo "sendmsg\n";<br><br> echo "call-command: execute\n";<br><br> echo "execute-app-name: answer\n\n";<br><br><br><br> // Play a prompt<br><br> echo "sendmsg\n";<br><br> echo "call-command: execute\n";<br><br> echo "execute-app-name: playback\n";<br><br> echo "execute-app-arg:<br>/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav\n\n";<br><br><br><br> // Wait<br><br> sleep(5);<br><br><br><br> // Hangup<br><br> echo "sendmsg\n";<br><br> echo "call-command: hangup\n\n";<br><br><br><br>fclose($in);<br><br><br><br>?><br><br><br><br>ivrd will call this script for each call. All itdoes is answer the<br>channel tell FreeSWITCH to play the “welcome to freeswitch” prompt.<br>Since the script is now controlling all call flow I needed to add a<br>wait or it would send the hangup immediately before the prompt was<br>played.<br><br>Some improvements possible but that's 1 way to do it. It would be<br>possible to do the socket directly in PHP but fs_ivrd is a nice option<br>too.<br><br>-- W<br><br>_______________________________________________<br>FreeSWITCH-users mailing list<br><a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br>http://www.freeswitch.org<br></div></blockquote></div><br></body></html>