"##" detection while in Call

I am developing an asterisk application and using dial to transfer the call. However, I want the control of the call back when the calling part presses “##”.
Can anybody please tell me how to accomplish that.
Thanks.