Asterisk Group Count via AGI

Can we execute the group_count or any other similar function in an AGI like we do in dialplan?

Thanks

Why execute the function on the AGI side instead of do it on the dial plan and pass the value to the AGI ?

Thanks for your reply.

Yes, we always do it from dialplan but is there any direct or indirect way to do this on the AGI because of our current need.