3

I want to write a web app that connects to freeswitch and makes outgoing call to some destination number (gateway for landline or internal sip devices) and plays some sounds (may be do some logic in lua script).

After reading freeswitch wiki, I found originate command but it doesn't work for me (I just test for internal sip number - sofia/internal/username@ip ). If originate command can do this, how to use it properly? If there is another way please tell me.

Zeeshan Hassan Memon
  • 8,105
  • 4
  • 43
  • 57
Ahmad Dehnavi
  • 1,483
  • 1
  • 17
  • 20

5 Answers5

3

Originate command is used to make the call and bridge command is used to bridge the call. You can call originate command externally by using esl socket.

Examples:

 originate {ignore_early_media=true,originate_timeout=60}sofia/gateway/name/number &playback(message)

Refer to this for esl written in node.js https://github.com/englercj/node-esl

Zeeshan Hassan Memon
  • 8,105
  • 4
  • 43
  • 57
suren
  • 455
  • 3
  • 14
1

one way that I test and it work is run a lua script from freeswitch console or ESL:(ex "luarun test.lua")

https://freeswitch.org/confluence/display/FREESWITCH/Lua+API+Reference#LuaAPIReference-session:hangupCause

obSession = freeswitch.Session("sofia/192.168.0.4/1002")
 
   -- Check to see if the call was answered
   if obSession:ready() then
    -- Play file here
   else   
    -- This means the call was not answered ... Check for the reason
    local obCause = obSession:hangupCause()
    freeswitch.consoleLog("info", "obSession:hangupCause() = " .. obCause )
    if ( obCause == "USER_BUSY" ) then              -- SIP 486
       -- For BUSY you may reschedule the call for later
    elseif ( obCause == "NO_ANSWER" ) then
       -- Call them back in an hour
    elseif ( obCause == "ORIGINATOR_CANCEL" ) then   -- SIP 487
       -- May need to check for network congestion or problems
    else
       -- Log these issues
    end
    end
Ahmad Dehnavi
  • 1,483
  • 1
  • 17
  • 20
1

You can do it very easily from dial plan:

<action function="play-file" data="myfile.wav"/>
Adam Wright
  • 129
  • 4
  • How you execute dialplan without an income call, I want make outgoingcall from web app. and about your code I think freeswitch dialplan must be like '' – Ahmad Dehnavi May 16 '17 at 17:04
  • One idea is to just use a command line based dialer to make calls via freeswitch such as the JVoIP java voip client. Actually JVoIP can also stream the voice file for you. – Adam Wright May 18 '17 at 17:58
1

You can make the wav play when someone start a call, follow these steps.

  1. Place your wave into your freeswitch/conf folder.
  2. Add the code bellow to your freeswitch/conf/autoload_configs

  3. Run a HTTP server that receives a POST request and returns your dialplan(which tells freeswitch to play your wav).

  4. Make sure your freeswitch/conf/autoload_configs/xml_curl.conf.xml looks like this
    <param name="gateway-url" value="http://yourIP:yourServerPort/dialplan.xml" bindings="dialplan"/>

Hope this helps.

ArthurG
  • 335
  • 2
  • 11
  • thanks for your reply, you play some file for someone that make call. but I want to freeswitch be a-leg of call and start outgoing call (example for ads). I answered my question before. – Ahmad Dehnavi May 18 '17 at 18:00
  • You mean something like [this](https://pastebin.com/LQRCS6g9)? By the way that goes into dialplan.xml – ArthurG May 19 '17 at 18:06
1

you can achieve By using a socket[ESL] application.

https://wiki.freeswitch.org/wiki/Event_Socket_Outbound