Running a script/agi when a phone is picked up

anyone knows if it can be done?
if yes how?
freepbx 12.0.65
Asterisk 11.17.1


Yes, it’s well documented try to start with

of course i google it before i ask the question here… :smiling_imp:

i only found this one
but is from 2012…

I got many more than one. Choose your language of choice, use one the many examples for that language as a tenplate, you will soon get it.

Before you ask, nobody will write it for you or read you the FM you will need some basic programming skill in the choice you make.

And you know this how, exactly, Dicko? Stop being a jerk; if you don’t want to help someone then just don’t reply at all. Telling someone to Google for something is condescending (you assume they haven’t done that already) and insulting. Saying that no one will be any more (un)helpful than you are is projecting your bad attitude toward all other forum participants. If I knew the answer, I certainly wouldn’t mind taking five or ten minutes to write a code snippet that would work; I’ve spent more time than that in the past writing a bit of custom dialplan for someone.

In this case I’ve never had the need to trigger an event when a particular phone is picked up, and I’m not sure I understand why the OP would need this. ineagu, if we understood a bit better what exactly you’re trying to accomplish, there may be an easier way than trying to detect when a specific phone is picked up. In fact doing that may be impossible in FreePBX because normally just picking up a VoIP phone doesn’t send any information back to FreePBX. It’s not until the phone number has been dialed that the PBX even knows that the phone wants to make a call.

Look at it this way, let’s say you have an Obihai VoIP adapter with a phone attached. The Obihai device can connect to two different service providers, and maybe one is your FreePBX server and the other is a commercial VoIP provider. If you are going to make a call through the commercial provider there is no reason FreePBX needs to know about that, and conversely if you are making the call through FreePBX then the commercial provider doesn’t need to know about it. Same thing on incoming calls; if you pick up the phone to answer a call from the commercial provider, FreePBX doesn’t need to know about that. And if you pick up the phone, just get dial tone, and hang up, in most cases no provider (including FreePBX) will know about that.

So you probably should think about why you want to detect when a phone is picked up. What is it you are really trying to accomplish? If you can state that, then people may be able to suggest a more simple way to help you achieve your goal. In the meantime, don’t listen to the sourpuss that can only tell you why HE won’t help you.

If you had ever tried to implement AGI then one of the first things you would have googled would have been

that will explain what the various varieties are and how it only works on active “channels” , i.e. you can run an agi script on picking up a ringing phone but not on picking up an on-hook phone unless perhaps setup as a hotline.

Then you run into

at the bottom of that is a list of libraries and languages with examples.

Then you need to work out what you are trying to achieve so you know where to put the AGI call and which variety of AGI to use.

Consuming all that takes more than “five or ten minutes” and will result in way more than a “code snippet”

Those two links I posted are both within the first half dozen google results and is a good place to start.

The OP is trying to solve his problem top-down , I am suggesting he uses the better bottom-up method where he understands what he needs to do and what tools he has available.

i found this module on GIT

it works for ring groups but not for an extention

Add CID Popup
This specialized module allows you to specify a destination IP Address of FQDN to be associated with various AGI Scripts that can be launched as part of a post answer action in a ringgroup. The scripts are specialized to deal with various destination CRM systems such as SugarCRM and other future system to provide push based CID PoPup and other CRM data to the agent who answers the call. Once you make an entry including the relevant information, these instances will be available within ringgroups to optionally associated a ringgroup with one of the configured servers so that such CRM data can be displayed to its agents.

with a tweak i made it work:

For the extention i need to monitor i put a follow me to a ring group and in that RG i activated cidpopup

bye bye

1 Like

Dicko, the OP never said he wanted to use AGI. Maybe you assumed that because he mentioned a link he’d found that uses AGI, but it sounds like he doesn’t want to go that route. I would probably not use AGI to solve this type of problem unless there were simply no other way to do it. I think you got off on the wrong foot here because you jumped to conclusions about how he might want to do this, when we still don’t know exactly what it is he’s trying to do.

You may be suggesting that NOW but that’s not what you suggested in your first two posts in this thread. In the one I replied to, you were just being rude, and projecting you unwillingness to offer any meaningful help onto the other forum participants. Now, suddenly, you’re coming up with more meaningful comments but I suspect that it’s only because you didn’t like being called out on your previous behavior.

In case you missed the point, if you don’t want to help someone, it’s better not to post at all - you are under no obligation to respond to every request for help. And, telling someone to “Google it” is not help, it’s just insulting. Anyone that can get FreePBX running has certainly heard of Google. Sometimes people don’t know what search terms will bring up meaningful results, so if you know of some that will, it’s perhaps helpful to suggest them. But quite often, even with good search terms, Google will bring up thousands of results, but none on the first few pages come remotely close to proving a usable solution. And sometimes people ask questions in a forum like this on the off chance that someone (even if it’s not you) has had a similar problem and has come up with a solution they’d be willing to share. Just because you don’t have an answer doesn’t necessarily mean that no other forum participants do.

Never mind @ineagu fixed it on his own. ( presumably with the help of improved and more directed Google skills :slight_smile: )