FreeSwitch 请求 DTFM 并执行 CURL 请求。然后连接到会议

FreeSwitch ask for DTFM and do a CURL request. Then connect to conference

我有以下拨号方案:

       <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>

这里的问题是 curl 在用户通过 DTFM 输入其凭据之前执行。正确的做法是什么?在此解决方案中,重要的是在加入之前执行 cURL 请求。

我通过 LUA 完成了它。这是我的 XML 配置:

<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>

并在 /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);

适合我。重要的是设置 dtmf_type 以便来自 SIP 中继的来电也能得到应答!