1
votes

I'm trying to create a Dialplan in freeswitch that hits an external API and waits for an "OK" HTTP response before initiating the outgoing call or stops the call if the response is anything but OK.

The reason I want to do this is to ensure that the calling user A) has a sufficient balance and B) is allowed to call the number they've requested to call in a pragmatic and dynamic way.

I cannot find any documentation that outlines this use case. Do I need to create my own extension (perhaps using ESL?) or is there a way I can do this with existing mods?

Thanks for any help.

1

1 Answers

3
votes

You can use https://freeswitch.org/confluence/display/FREESWITCH/mod_curl.

Just an example:

  <action application="curl" data="http://your_api_url/?from=${sip_from_user}" inline="true"/>
  <condition field="${curl_response_code}" expression="200">
    <action application="set" data="channel_var=${curl_response_data}"/>
    <anti-action application="respond" data="500"/>
  </condition>