Hello everyone, I want to implement a function: A dials B. After B is connected, A dials C to let them talk to 3 people. How do I implement it?

Status
Not open for further replies.

HeisenbergQin

New Member
Jun 30, 2021
19
0
1
29
Hello everyone, I want to implement a function: A dials B. After B is connected, A dials C to let them talk to 3 people. How do I implement it?
 

hfoster

Active Member
Jan 28, 2019
684
81
28
34
If I recall, conferencing calls is a feature of the phones if you are a using ad-hoc conferencing which is why it's usually limited to 3 parties.

Personally, I would just do:

1. Dial B from Handset A
2. Press Conference on Handset A
3. Dial C.

Otherwise, I think you'll have to experiment with the Freeswitch action application="conference" if you needed to do it from the PBX side.
 

HeisenbergQin

New Member
Jun 30, 2021
19
0
1
29
If I recall, conferencing calls is a feature of the phones if you are a using ad-hoc conferencing which is why it's usually limited to 3 parties.

Personally, I would just do:

1. Dial B from Handset A
2. Press Conference on Handset A
3. Dial C.

Otherwise, I think you'll have to experiment with the Freeswitch action application="conference" if you needed to do it from the PBX side.
@hfoster Thank you for your reply. I have tried the conference mode, but C needs to actively enter the conference. I don't know how to use A to invite C to join the call.
 

HeisenbergQin

New Member
Jun 30, 2021
19
0
1
29
Or what do I need to do before I can actively invite a user to listen to the call between A and B?

1628663089479.png
 

HeisenbergQin

New Member
Jun 30, 2021
19
0
1
29
I can now let C participate in the conversation through conference mode or monitoring mode, but the premise requires C to call A or the conference number. Actually, this is not allowed, because we don't know when A and B are talking, so we must You have to invite C to join when A and B are talking.
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
You could certainly do what you require with an .lua script. I'm pretty busy at the moment but if I get time I will dig out some examples for you.
 

hfoster

Active Member
Jan 28, 2019
684
81
28
34
@hfoster Thank you for your reply. I have tried the conference mode, but C needs to actively enter the conference. I don't know how to use A to invite C to join the call.

Nah, I just meant using the functionality of the handset if it has it. On my Yealink, I call one party, tell them I'm conferencing in C and 'Press conference' and call C. Then it just calls to invtie them. The limitation is it's limited to 3 parties.
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Nah, I just meant using the functionality of the handset if it has it. On my Yealink, I call one party, tell them I'm conferencing in C and 'Press conference' and call C. Then it just calls to invtie them. The limitation is it's limited to 3 parties.
My customers use this facility on the Yealinks a lot.
 

HeisenbergQin

New Member
Jun 30, 2021
19
0
1
29
Nah, I just meant using the functionality of the handset if it has it. On my Yealink, I call one party, tell them I'm conferencing in C and 'Press conference' and call C. Then it just calls to invtie them. The limitation is it's limited to 3 parties.
In other words, does this feature need device support?
 

HeisenbergQin

New Member
Jun 30, 2021
19
0
1
29
Nah, I just meant using the functionality of the handset if it has it. On my Yealink, I call one party, tell them I'm conferencing in C and 'Press conference' and call C. Then it just calls to invtie them. The limitation is it's limited to 3 parties.
It may be that I did not express it clearly enough. I do not consider whether C is an external call. In other words, we do not consider the conference mode now, but use eavesdrop as an example: ABC all communicate with SIP extensions, A calls B, and C can pass through Dial *33 to monitor the conversation between A and B or even participate in the conversation, then can I call C from extension A and actively call him to monitor it (I think it must be possible, maybe my technology is not good enough. So I haven't understood their operating mechanism yet)?
 

hfoster

Active Member
Jan 28, 2019
684
81
28
34
Probably not out of the box on FusionPBX. Sounds like it would require a whole new lua script to be able to call an extension, but instead make that user start an eavesdrop of the callers session.
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
@hfoster Good you should mention eavesdrop. The .lua below was written to emulate an old fashioned answering machine using voicemail and a standard extension, where you can listen to the message being left and pick up if you want to. This may serve as an eavesdrop example for HeisenbergQin:

Code:
--    vm_call_screen.lua
--    FusionPBX
--    Version: MPL 1.1
--
--    The contents of this file are subject to the Mozilla Public License Version
--    1.1 (the "License"); you may not use this file except in compliance with
--    the License. You may obtain a copy of the License at
--    http://www.mozilla.org/MPL/
--
--    Software distributed under the License is distributed on an "AS IS" basis,
--    WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
--    for the specific language governing rights and limitations under the
--    License.
--
--    The Original Code is FusionPBX
--
--    Inspired by the Initial Developer of the Original Code
--    Mark J Crane <markjcrane@fusionpbx.com>
--    Copyright (C) 2010-2020
--    the Initial Developer. All Rights Reserved.
--
--    Contributor(s):
--    Adrian Fretwell <adrian.fretwell@topgreen.co.uk>
--
--    call this from the dialplan as a destination with voicemail extension and eavesdrop extension as parameters:
--    <extension name="vm_call_screen" continue="false" uuid="40caf546-e343-404d-9931-0364c7bc7527">
--        <condition field="destination_number" expression="^6201$">
--        <action application="lua" data="vm_call_screen.lua 201 201"/>
--        </condition>
--    </extension>


-- set up API object and get parameters
    api = freeswitch.API();
    vm_destination = argv[1];
    ev_destination = argv[2];


-- make sure the session is ready
    if ( session:ready() ) then
        -- answer the call
            session:answer();
        -- get the dialplan variables and set them as local variables
            destination_number = session:getVariable("destination_number");
            domain_name = session:getVariable("domain_name");
            sounds_dir = session:getVariable("sounds_dir");
            rtp_secure_media = session:getVariable("rtp_secure_media");
            caller_id_name = session:getVariable("caller_id_name");
            caller_id_number = session:getVariable("caller_id_number");
            sip_from_user = session:getVariable("sip_from_user");
            mute = session:getVariable("mute");

            call_uuid = session:get_uuid();

        -- set the sounds path for the language, dialect and voice
            default_language = session:getVariable("default_language");
            default_dialect = session:getVariable("default_dialect");
            default_voice = session:getVariable("default_voice");
            if (not default_language) then default_language = 'en'; end
            if (not default_dialect) then default_dialect = 'gb'; end
            if (not default_voice) then default_voice = 'rachael'; end

        -- set rtp_secure_media to an empty string if not provided.
            if (rtp_secure_media == nil) then
                rtp_secure_media = 'false';
            end


        -- set the caller id
            if (caller_id_name) then
                --caller id name provided do nothing
            else
                effective_caller_id_name = session:getVariable("effective_caller_id_name");
                caller_id_name = effective_caller_id_name;
            end

            if (caller_id_number) then
                --caller id number provided do nothing
            else
                effective_caller_id_number = session:getVariable("effective_caller_id_number");
                caller_id_number = effective_caller_id_number;
            end

            if (not vm_destination or vm_destination == "") then
                freeswitch.consoleLog("NOTICE", "[vm_call_screen] vm_destination (argv[1]) is not valid\n");
                session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-invalid_number_format.wav");
                session:hangup("INVALID_NUMBER_FORMAT");
                return;
            end
            if (not ev_destination or ev_destination == "") then
                freeswitch.consoleLog("NOTICE", "[vm_call_screen] ev_destination (argv[2]) is not valid\n");
                session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-invalid_number_format.wav");
                session:hangup("INVALID_NUMBER_FORMAT");
                return;
            end


        -- transfer the call to voicemail
        -- check to see if the user extension exists
            local cmd = "user_exists id ".. vm_destination .." "..domain_name;
            local result = api:executeString(cmd);
            if result == "true" then
                session:execute("transfer", "*99"..vm_destination.." XML "..domain_name);
            else
                freeswitch.consoleLog("NOTICE", "[vm_call_screen] unallocated number transfer "..vm_destination.." XML "..domain_name);
                session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-unallocated_number.wav");
                session:hangup("UNALLOCATED_NUMBER");
                return;
            end

            session:sleep(1000);

        -- Originate call to bridge eavesdrop extension and eavesdrop application
        -- On answer execute bind_meta_app so it will execute an intercept id *5 is pressed
            local cmd = "user_exists id ".. ev_destination .." "..domain_name;
            local result = api:executeString(cmd);
            if result == "true" then
                cmd_string = "bgapi originate {sip_auto_answer=true,sip_h_Alert-Info='Ring Answer',execute_on_answer='bind_meta_app 5 a i transfer::intercept:"..call_uuid.." inline',hangup_after_bridge=false,rtp_secure_media="..rtp_secure_media..",origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number..",effective_caller_id_number="..caller_id_number..",effective_caller_id_name='"..caller_id_name.."',caller_destination="..ev_destination.."}user/"..ev_destination.."@"..domain_name.." eavesdrop:"..call_uuid.." inline";
                api:executeString(cmd_string);
            else
                freeswitch.consoleLog("NOTICE", "[vm_call_screen] unallocated number eavesdrop "..ev_destination.."@"..domain_name);
            end
            return;
    end
 

HeisenbergQin

New Member
Jun 30, 2021
19
0
1
29
Probably not out of the box on FusionPBX. Sounds like it would require a whole new lua script to be able to call an extension, but instead make that user start an eavesdrop of the callers session.
Thanks, I have a lot of clarity through your explanation~
 

HeisenbergQin

New Member
Jun 30, 2021
19
0
1
29
@hfoster Good you should mention eavesdrop. The .lua below was written to emulate an old fashioned answering machine using voicemail and a standard extension, where you can listen to the message being left and pick up if you want to. This may serve as an eavesdrop example for HeisenbergQin:

Code:
--    vm_call_screen.lua
--    FusionPBX
--    Version: MPL 1.1
--
--    The contents of this file are subject to the Mozilla Public License Version
--    1.1 (the "License"); you may not use this file except in compliance with
--    the License. You may obtain a copy of the License at
--    http://www.mozilla.org/MPL/
--
--    Software distributed under the License is distributed on an "AS IS" basis,
--    WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
--    for the specific language governing rights and limitations under the
--    License.
--
--    The Original Code is FusionPBX
--
--    Inspired by the Initial Developer of the Original Code
--    Mark J Crane <markjcrane@fusionpbx.com>
--    Copyright (C) 2010-2020
--    the Initial Developer. All Rights Reserved.
--
--    Contributor(s):
--    Adrian Fretwell <adrian.fretwell@topgreen.co.uk>
--
--    call this from the dialplan as a destination with voicemail extension and eavesdrop extension as parameters:
--    <extension name="vm_call_screen" continue="false" uuid="40caf546-e343-404d-9931-0364c7bc7527">
--        <condition field="destination_number" expression="^6201$">
--        <action application="lua" data="vm_call_screen.lua 201 201"/>
--        </condition>
--    </extension>


-- set up API object and get parameters
    api = freeswitch.API();
    vm_destination = argv[1];
    ev_destination = argv[2];


-- make sure the session is ready
    if ( session:ready() ) then
        -- answer the call
            session:answer();
        -- get the dialplan variables and set them as local variables
            destination_number = session:getVariable("destination_number");
            domain_name = session:getVariable("domain_name");
            sounds_dir = session:getVariable("sounds_dir");
            rtp_secure_media = session:getVariable("rtp_secure_media");
            caller_id_name = session:getVariable("caller_id_name");
            caller_id_number = session:getVariable("caller_id_number");
            sip_from_user = session:getVariable("sip_from_user");
            mute = session:getVariable("mute");

            call_uuid = session:get_uuid();

        -- set the sounds path for the language, dialect and voice
            default_language = session:getVariable("default_language");
            default_dialect = session:getVariable("default_dialect");
            default_voice = session:getVariable("default_voice");
            if (not default_language) then default_language = 'en'; end
            if (not default_dialect) then default_dialect = 'gb'; end
            if (not default_voice) then default_voice = 'rachael'; end

        -- set rtp_secure_media to an empty string if not provided.
            if (rtp_secure_media == nil) then
                rtp_secure_media = 'false';
            end


        -- set the caller id
            if (caller_id_name) then
                --caller id name provided do nothing
            else
                effective_caller_id_name = session:getVariable("effective_caller_id_name");
                caller_id_name = effective_caller_id_name;
            end

            if (caller_id_number) then
                --caller id number provided do nothing
            else
                effective_caller_id_number = session:getVariable("effective_caller_id_number");
                caller_id_number = effective_caller_id_number;
            end

            if (not vm_destination or vm_destination == "") then
                freeswitch.consoleLog("NOTICE", "[vm_call_screen] vm_destination (argv[1]) is not valid\n");
                session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-invalid_number_format.wav");
                session:hangup("INVALID_NUMBER_FORMAT");
                return;
            end
            if (not ev_destination or ev_destination == "") then
                freeswitch.consoleLog("NOTICE", "[vm_call_screen] ev_destination (argv[2]) is not valid\n");
                session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-invalid_number_format.wav");
                session:hangup("INVALID_NUMBER_FORMAT");
                return;
            end


        -- transfer the call to voicemail
        -- check to see if the user extension exists
            local cmd = "user_exists id ".. vm_destination .." "..domain_name;
            local result = api:executeString(cmd);
            if result == "true" then
                session:execute("transfer", "*99"..vm_destination.." XML "..domain_name);
            else
                freeswitch.consoleLog("NOTICE", "[vm_call_screen] unallocated number transfer "..vm_destination.." XML "..domain_name);
                session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-unallocated_number.wav");
                session:hangup("UNALLOCATED_NUMBER");
                return;
            end

            session:sleep(1000);

        -- Originate call to bridge eavesdrop extension and eavesdrop application
        -- On answer execute bind_meta_app so it will execute an intercept id *5 is pressed
            local cmd = "user_exists id ".. ev_destination .." "..domain_name;
            local result = api:executeString(cmd);
            if result == "true" then
                cmd_string = "bgapi originate {sip_auto_answer=true,sip_h_Alert-Info='Ring Answer',execute_on_answer='bind_meta_app 5 a i transfer::intercept:"..call_uuid.." inline',hangup_after_bridge=false,rtp_secure_media="..rtp_secure_media..",origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number..",effective_caller_id_number="..caller_id_number..",effective_caller_id_name='"..caller_id_name.."',caller_destination="..ev_destination.."}user/"..ev_destination.."@"..domain_name.." eavesdrop:"..call_uuid.." inline";
                api:executeString(cmd_string);
            else
                freeswitch.consoleLog("NOTICE", "[vm_call_screen] unallocated number eavesdrop "..ev_destination.."@"..domain_name);
            end
            return;
    end
@Adrian Fretwell Thank you so much, through your example, I think I already know how to do it.
 
Status
Not open for further replies.