What channel to be set for AMI to dial plan?

I’m using AMI for sending request to Asterisk for call processing and after Asterisk received the request and data from client it passes to an AGI for further processing. The problem I’m facing what channel shall I defined in Asterisk so it can receive request from its client.

The dial plan I’m listing below;

;exten => TAP,1,Dial(Local/pager@Pager)
exten => pager,1,Dial(Local/pager@Pager)

exten => pager,2,Verbose(1,Sending Alphanumeric Pages)
same => n,Set(device=ttydl1)
same => n,Set(baudrate=9600)
same => n,Set(parity=none)
same => n,Set(maxtries=3)
same => n,Set(maxmsgsize=255)
same => n,Set(maxpages=9)
same => n,Set(allowpid=true)
same => n,NoOp(Service : ${service})
same => n,NoOp(Device : ${device})
same => n,NoOp(Baud Rate : ${baudrate})
same => n,NoOp(Parity : ${parity})
same => n,NoOp(Maxtries : ${maxtries})
same => n,NoOp(Max Msg Size : ${maxmsgsize})
same => n,NoOp(Max Pages : ${maxpages}
same => n,NoOp(Allow Pid : ${allowpid})
same => n,NoOp(Password : ${password})
same => n,NoOp(Phone : ${phone})
same => n,NoOp(Pager : ${pager})
same => n,NoOp(PagerId : ${pagerid})
same => n,NoOp(Service : ${service})
same => n,NoOp(Message : ${msg})
same => n,NoOp(Channel Name: ${CHANNEL})
same => n,AGI(/home/ac958b/proc.pl)
same => n,HangUp()

When I use “Local/pager@Pager” channel in exten => TAP,1,Dial(Local/pager@Pager) [setting exten => pager,2,Verbose(1,Sending Alphanumeric Pages) to exten => pager,1,Verbose(1,Sending Alphanumeric Pages)], it executes correctly but the problem I’m facing as soon as AGI transmits the message it hang ups, so it is not performing any post procedure actions. On other hand when I call the channel as I mentioned above, uses dial plan i.e. exten => pager,1,Dial(Local/pager@Pager) [using exten => pager,2,Verbose(1,Sending Alphanumeric Pages)], it iterates few loops and later execute AGI completely(NOte: The iterating loops bothers me so I’m not recommending to use it).

Please advise which channel shall I use into my dial plan that can execute my AGI completely.

Note: Logs can be provided on request.

I was missing few lines and library, now its working fine

Please mark your post resolved as mentioned in this forum rule and put the details what you did the changes so other user can know about it.