User:Birgit bachler/Freeswitch: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 30: Line 30:
</pre>
</pre>


==  
== Python Dialplan API ==
Python Dialplan API ==
So foo channel variable is set to the output of the my_script python script:
getting digits maybe via dialplan?
....getting digits for extenstion maybe via dialplan?
<action application="set"
<pre>
<action application="set"
       data="foo=${python(my_script)}"/>
       data="foo=${python(my_script)}"/>
</pre>
This is possible using channel variables. In the dialplan:
<pre>
  <extension name="foo">
    <condition field="destination_number" expression="^123$">
      <action application="set" data="foo=bar"/>
      <action application="python" data="mypackage.myscript"/>
    </condition>
  </extension>
</pre>
and in the python script:
<pre>
foo = session.getVariable("foo")
console_log("info", "\n\\n foo: %s\n\n" % foo)
</pre>
== Session Record ==
<pre>
first_name = str(row[0])
last_name = str(row[1])
record_file = first_name + '-' + last_name + '.wav'
session.recordFile(record_file,120,500,2)
</pre>
<pre>recordFile(filename, <callback_function>, <[callback_args]>, <[max_len]>, <[silence_threshold]>, <[silence_secs]>);</pre>
sessionRecordFile on FS-wiki[http://wiki.freeswitch.org/wiki/Session_recordFile]

Latest revision as of 15:59, 28 April 2011

Py PlayAndGetDigits

playAndGetDigits(int min_digits, 
		 int max_digits, 
		 int max_tries, 
	         int timeout, 
		 char *terminators, 
	         char *audio_files, 
	         char *bad_input_audio_files, 
		 char *digits_regex)


tempfile = "/path/to/song.mp3"
in_rslt = self.session.playAndGetDigits(1,
                                        1,
                                        1,
                                        1000,
                                        "*#",
                                        tempfile,
                                        "",         
                                        "")      
                    
actual_result = in_rslt[1]
if not actual_result:
    actual_result = int(actual_result)

Python Dialplan API

So foo channel variable is set to the output of the my_script python script: ....getting digits for extenstion maybe via dialplan?

 
<action application="set"
      data="foo=${python(my_script)}"/>

This is possible using channel variables. In the dialplan:

  <extension name="foo">
    <condition field="destination_number" expression="^123$">
      <action application="set" data="foo=bar"/>
      <action application="python" data="mypackage.myscript"/>
    </condition>
  </extension>

and in the python script:

foo = session.getVariable("foo")
console_log("info", "\n\\n foo: %s\n\n" % foo)

Session Record

first_name = str(row[0])
last_name = str(row[1])
record_file = first_name + '-' + last_name + '.wav'
session.recordFile(record_file,120,500,2)


recordFile(filename, <callback_function>, <[callback_args]>, <[max_len]>, <[silence_threshold]>, <[silence_secs]>);

sessionRecordFile on FS-wiki[1]