I really appreciate your help Ben . To give some background of current behaviour , 1stly we are not doing parallel forking , we are doing serial forking . We have adjusted opensips code somehow and sorted the list of contacts according to their registration time (*creation time column is added in the location table for this* ). In a branch if there are 5 contacts then we give a call to the longest ideal contact first if that fails then opensips again try the next longest ideal contact and so on . If All fails it gives back 500 Error .
My requirements have changed at this point . *Agent1 call-info : sales=1,apple=20,en=5* *Agent2 call-info : sales=15,apple=7* *Agent3 call-info : sales=4,apple=4* *Agent4 Call-info : hr=3,gallileo=5 * *Invite $hdr(Call-Info) : sales,en * *For this INVITE , Agent1 , Agent2 and Agent3 are matched candidates ** and the elements are present in their attribute . Now the question is who should I give the call first . * *Here I have to calculate the average level of both the agent and which one will be the greatest 1st call sent out to that agent . * *When I am saying theoretically it seems achievable through config adjustment . But the question is now how ? * *Agent1 average skill level : (1+20)/2 =10.5* *Agent2 average skill level : (15+7)/2=11 (Now Agent2 is in higher skill . )* *Agent3 average skill level : (4+4)/2=4 * *Now the highest average skill level is Agent2 , Call will be sent out to Agent2 if fails then will go to Agent1 if fails then will go to Agent3 . * *Again this is a challenge for me . Is there any other module or table on which I can save the branch with its skill level and then while sending out call I will check the skill level and then send out . How will I achieve this ?* *Thanks & Regards* *Sasmita Panda* *Senior Network Testing and Software Engineer* *3CLogic , ph:07827611765* On Fri, Nov 3, 2023 at 2:28 AM Ben Newlin <ben.new...@genesys.com> wrote: > Sasmita, > > > > I can’t provide a working example as I don’t have a use case like this. > However, this piece of script you’ve provided does not represent a correct > flow. I think you may need to review how the different types of routes, and > particularly branch routes, work. [1] > > > > I don’t have any experience with Registrar module, so take all of the > following with a grain of salt. Someone with more experience with registrar > can maybe keep me honest here. > > > > You should only need to call next_branches() one time, as it already loads > all contacts returned by lookup() into parallel branches (assuming you are > using the “b” flag for lookup()). This means they are all sent out at once, > not serially. So you don’t need to send the next branch in failure_route > because they’ve all already been sent. > > > > The branch route is executed as the last route before the message is being > sent out. You certainly do not need to call next_branches() there either, > in fact its behavior in a branch route is not defined in the docs. Also, I > don’t know what your route “1” does, but you likely don’t need it from > branch route either. As long as you don’t drop the branch, it will > automatically be sent out. Lastly, you have the actual drop() command > commented out, so this code won’t work as I described. > > > > Lastly, failure_route is armed for the whole request. In the case of > parallel branching, it will only be called once for the request, not once > for each branch, and only if all branches receive negative replies. > > > > One thing I’m not clear about is what happens if you end up dropping all > the branches. I don’t know if failure_route would be called then, but it > would be pretty easy to verify that. I think it would. > > > > Again, I can’t speak to your specific use case, but a representative > version of the solution I recommended is below. **I have not tested or > verified this code.** > > > > route { > > # all of your normal routing logic > > > > if (lookup(“<domain>”, “b”)) { > > if (next_branches()) { > > t_on_branch(“check_attrs”); > > t_on_failure(“no_branches”); > > } > > else { > > # handle case of no contacts > > t_reply(404, “Not Found”); > > } > > } > > else { > > # handle case of failed lookup > > t_reply(404, “Not Found”); > > } > > } > > > branch_route[check_attrs] { > $var(count) = $(hdr(Call-Info){csv.count}); > > while($(var(count) >= 0)) { > if ($(avp(attr){s.index, $(hdr(Call-Info){csv.value,$var(i)})}) == > NULL) { > > # as soon as one requirement doesn’t match, you know you don’t want > to route > > drop(); > > } > > > > xlog("count: $var(count)\n"); > $var(count) = $var(count) - 1; > } > > } > > > > failure_route[no_branches] { > # handle case where all branches failed > > t_reply(404, “Not Found”); > } > > > > [1] https://www.opensips.org/Documentation/Script-Routes-3-2 > > > > Ben Newlin > > > > *From: *Users <users-boun...@lists.opensips.org> on behalf of Sasmita > Panda <spa...@3clogic.com> > *Date: *Thursday, November 2, 2023 at 9:36 AM > *To: *OpenSIPS users mailling list <users@lists.opensips.org> > *Subject: *Re: [OpenSIPS-Users] I need some help in attr matching while > forming the Branch . > ------------------------------ > > Hi Ben , > > > > > > failure_route[1] { > if ( t_check_status("404|477|480|481|408|486|50[234]")){ > if (next_branches()) > { > t_on_branch("attr"); > } > > } > } > > > branch_route[attr] > { > $var(count) = $(hdr(Call-Info){csv.count}); > > $var(i) = 0; > $var(match-count) = 0; > > while($var(i) < $(var(count))){ > > if ($(avp(attr){s.index, $(hdr(Call-Info){csv.value,$var(i)})}) > != NULL){ > xlog("counter: $var(i)th index matched in attribute \n"); > $var(match-count)= $var(match-count) + 1; > } > xlog("counter: $var(i)\n"); > $var(i) = $var(i) + 1; > } > > if ($var(i) == $var(match-count)){ > ## Here I want to give call to that contact .. if that fails then again it > should come to next branch and again compare > t_on_failure("1"); > route(1); > } > else{ > # Here if the condition does not match . then i want to do the comparison > again > if (next_branches()){ > t_on_branch("attr"); > } > # drop(); > } > } > > > > As for my expectation, it's not working . How does it work ? Where should > I use T_branch_Idx ? Can I get some examples of this ? > > > > > *Thanks & Regards* > > *Sasmita Panda* > > *Senior Network Testing and Software Engineer* > > *3CLogic , ph:07827611765* > > > > _______________________________________________ > Users mailing list > Users@lists.opensips.org > http://lists.opensips.org/cgi-bin/mailman/listinfo/users >
_______________________________________________ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users