FreePBX | Register | Issues | Wiki | Portal | Support

Modifying existing Macro with module

(Brandon Brown) #1

Is there a way to modify the “macro-hangupcall” with a module? I can’t seem to find documentation on this. Basically what I am looking to do is to hook into this and send an email after a call is hung up. I have found the dial plan code that is supposed to send the email after a hangup a forum post but I can’t post the link because I am a new user so below is the snippet. I basically just want to modularize this instead of creating adding the code below inside of the extensions_custom.conf file

exten => s,1,DumpChan()
exten => s,n,System(echo ‘Call from ${CALLERID(name)} at ${CALLERID(number)}’ | mail -s ‘SUBJECT’ ‘’)
exten => s,n,MacroExit()

Thanks in advance

(Lorne Gaetz) #2

You can rewrite the macro, but far better to do a hook as explained at the bottom of this post:

(Brandon Brown) #3

Would you be able to provide a snippet of the FreePBX module PHP code required to start off with something like this? The post you linked describes how to manually add it to a file but I am looking to do this with a module so no files have to be manually edited. I am not finding any documentation on how to create these contexts using the provided FreePBX PHP API. I have the module skeleton started already, I assume I would add the code inside of the “doDialPlanHook” method of my module class?

(Brandon Brown) #4

I have figured how how to add these to the dialplan using a php module. However the hook only seems to get called after calling an extension. I can confirm this by looking at the description inside of extensions.conf. Is there a hook I can use that will execute after any agent hangs up, regardless if they received a call from a queue, direct extension dial or outbound call?


Somewhat off topic, but most IP phones can be configured to access a URL on various events, including when a call is ended. Variables can be used to transmit the calling and called numbers, call duration, etc. for example, see