I have following dialplan:
<extension name="public_did">
<condition field="destination_number" expression="^({{ $externalNumber }})$">
<action application="sleep" data="1000"/>
<action application="play_and_get_digits" data="9 9 3 5000 # welcome.wav error.wav ${confid}" />
<action application="event" data="Event-App-Type=READ-EXECUTED,Read-Result=${read_result}"/>
<action application="log" data="Read-Result=${read_result}"/>
<action application="play_and_get_digits" data="5 5 3 5000 # pin.wav pin-error.wav ${pin}" />
<action application="curl" data="https://example.com/do-freeswitch-dialin?id=${confid}&pin=${pin}" inline="true"/>
<condition field="${curl_response_code}" expression="500">
<anti-action application="set" data="conf=${curl_response_data}"/>
<action application="speak" data="There was an error! Please try again later!" />
<action application="hangup" data="500"/>
</condition>
<action application="conference" data="${conf}{{ '@' }}default"/>
</condition>
</extension>
The problem here is that the curl gets executed before the user enters his credentials via DTFM. What is the correct way to do it? IN this solution it is important to do the cURL request before joining.
I managed it doing by LUA. Here my XML config:
<extension name="public_did">
<condition field="destination_number" expression="^(12345)$">
<action application="answer" />
<action application="set" data="dtmf_type=rfc2833"/>
<action application="start_dtmf" />
<action application="lua" data="basic.lua"/>
</condition>
</extension>
And in /usr/share/freeswitch/scripts/basic.lua
session:sleep(500)
session:execute("playback", "ivr/ivr-douche_telecom.wav");
digits = session:playAndGetDigits(4, 10, 3, 3000, "#", "ivr/ivr-please_enter_the_number_where_we_can_reach_you.wav", "ivr/ivr-invalid_extension_try_again.wav", "\\d+", "digits_received", 1000,
"5000 XML default");
session:execute("playback", "ivr/ivr-thank_you.wav");
api = freeswitch.API();
get_response = api:execute("curl", "https://example/freeswitch-dialin?id=" .. digits);
api:execute("log", get_response);
api:execute("log", digits);
Works for me. Important was to set the dtmf_type so that incomming calls from a SIP trunk get answered as well!