<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>&lt;extension name="outbound-socket"&gt;<br><br> &nbsp;&nbsp;&nbsp;&lt;condition field="destination_number" expression="^55(522)$"&gt;<br><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;action application="set"<br>data="ivr_path=/usr/local/freeswitch/scripts/ivrd-demo.php"/&gt;<br><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;action application="socket" data="127.0.0.1:8084 async full"/&gt;<br><br> &nbsp;&nbsp;&nbsp;&lt;/condition&gt;<br><br> &nbsp;&lt;/extension&gt;<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>&lt;?php<br><br><br><br> &nbsp;&nbsp;&nbsp;// set a couple of things so we dont kill the system<br><br> &nbsp;&nbsp;&nbsp;ob_implicit_flush(true);<br><br> &nbsp;&nbsp;&nbsp;set_time_limit(30);<br><br><br><br><br><br> &nbsp;&nbsp;&nbsp;// Open stdin so we can read the AGI data in<br><br> &nbsp;&nbsp;&nbsp;$in = fopen("php://stdin", "r");<br><br> &nbsp;&nbsp;&nbsp;// Connect<br><br> &nbsp;&nbsp;&nbsp;echo "connect\n\n";<br><br> &nbsp;&nbsp;&nbsp;// Answer<br><br> &nbsp;&nbsp;&nbsp;echo "sendmsg\n";<br><br> &nbsp;&nbsp;&nbsp;echo "call-command: execute\n";<br><br> &nbsp;&nbsp;&nbsp;echo "execute-app-name: answer\n\n";<br><br><br><br> &nbsp;&nbsp;&nbsp;// Play a prompt<br><br> &nbsp;&nbsp;&nbsp;echo "sendmsg\n";<br><br> &nbsp;&nbsp;&nbsp;echo "call-command: execute\n";<br><br> &nbsp;&nbsp;&nbsp;echo "execute-app-name: playback\n";<br><br> &nbsp;&nbsp;&nbsp;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> &nbsp;&nbsp;&nbsp;// Wait<br><br> &nbsp;&nbsp;&nbsp;sleep(5);<br><br><br><br> &nbsp;&nbsp;// Hangup<br><br> &nbsp;&nbsp;echo "sendmsg\n";<br><br> &nbsp;&nbsp;echo "call-command: hangup\n\n";<br><br><br><br>fclose($in);<br><br><br><br>?&gt;<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>