Get Extension by called number

Smueller1337

Customer
Joined
Jul 31, 2023
Messages
2
Reaction score
0
Hi everyone. I'm having a (for me tricky) question for the extension properties.
I Have a callflow where the external caller gets transfered to if the extension is busy. In the CFD I only get the called number, the caller number but not the called extension. I need this because I want to transfer the caller to a queue where the extension is registered to. There are multiple queues for each branch office. I already have the script to get all queues of an extension but I struggle to get the extension number by the called number.
I thought iterating through all available extensions and check if the called number is the one of the extension but I can't figure out how to get this property.
If there is any different approach to that I'm happy to hear it.
 
Wouldn't it be easier just to use the forwarding rules of an extension to do this?

Each user would have their forwarding rules for external callers going to the relevant queue. Internal callers would go to a different destination, like voicemail for example.
 
Theoratically yes but within another callflow the acutal queue gets observed for free agents, playing moh and after some specific time the caller can choose between staying in line or to record a message and send it as an email.

I've just came across this thread https://www.3cx.com/community/threa...-20-0-update-0-build-1494.124792/#post-587928 and this seems to fit just perfectly. I just couldn't get the transfering extension number but now it does
 
the caller can choose between staying in line or to record a message and send it as an email
That can be done with the destination if no answer. The caller can press the * button on their phone to trigger this. You would need to record this into your intro prompt to let them know they can do this at any time. This could also be inserted into your music on hold file if needed as well.
 
CFD C# snippet, returns the extension which is first called from external or internal caller

returns 0 if all fails

C#:
string retval="0";
if(myCall.Caller.DN is ExternalLine externalLine && myCall.IsInbound)
{
    string[] range;
    foreach (var a in externalLine.RoutingRules)
    {
        bool match = (a.Conditions.Condition.Type == RuleConditionType.BasedOnDID &&
        (
            a.Data == myCall.Caller.CalledNumber
            || (a.Data.StartsWith('*') && myCall.Caller.CalledNumber.EndsWith(a.Data[1..]))
        ))
        ||
        (
            a.Conditions.Condition.Type == RuleConditionType.BasedOnCallerID &&
            a.Data.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
            .Any
            (x =>
                x == "*"
                || x == myCall.Caller.CallerID
                || x.StartsWith('*') && myCall.Caller.CallerID.EndsWith(x[1..])
                || x.EndsWith('*') && myCall.Caller.CallerID.StartsWith(x[..^1])
                || x.StartsWith('*') && x.EndsWith('*') && myCall.Caller.CallerID.Contains(x[1..^1])
                || ((range = x.Split("-", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)).Length == 2 ?
                (range[0].Length == myCall.Caller.CallerID.Length && range[1].Length == myCall.Caller.CallerID.Length) && (range[0].CompareTo(myCall.Caller.CallerID) <= 0 && range[1].CompareTo(myCall.Caller.CallerID) >= 0) : false)
            )
        )
        ||
        (a.Conditions.Condition.Type == RuleConditionType.ForwardAll);
   
        if (match)
        {
            retval=(a.ForwardDestinations.OfficeHoursDestination).Internal?.Number?? "0";
            break;
        }
    }
}
else
{
    retval=myCall.Caller.AttachedData["extnumber"]?? "0";
}
return retval;
 

Latest Posts

Forum statistics

Threads
111,964
Messages
590,001
Members
164,869
Latest member
hpgitsupport