No able to capture call reject event

i was building a predective dialer where i am first trying to connect the customer and once customer answer then i connect him to the available agent.

Here i only get the answer event in my context . How can i get the call cancel event with out answering the call.

What is the complete chain of signalling protocols between the callee and Asterisk.

Analogue lines cannot signal cancel.

ISDN to VoIP gateways may well lose information because of the mismatch between ISDN an SIP.

If the information is available, it should be presented as ${HANGUPCAUSE}=21.

Thanks David below i my complete code snippet.
I am calling the asterisk dial method from php script that is calling the customer no and once customer answered then it captured in the [phones-pd] context. my problem is that context [phones-pd] is getting called only when the customer answered.How can i captured if the customer is busy or rejected the call without answering.

php script

$oSocket = fsockopen ("$server_ip", 5038, &$errno, &$errstr, 20);
if (!$oSocket) {
echo “$errstr ($errno)
} else {
fputs($oSocket, “Action: login\r\n”);
fputs($oSocket, “Events: off\r\n”);
fputs($oSocket, “Username: $strUser\r\n”);
fputs($oSocket, “Secret: $strSecret\r\n\r\n”);
fputs($oSocket, “Action: originate\r\n”);
fputs($oSocket, “Channel: DAHDI/g0/0’.Phoneno\r\n”);
fputs($oSocket, “WaitTime: 30\r\n”);
fputs($oSocket, “CallerId: $strCallerId\r\n”);
fputs($oSocket, “Exten: s\r\n”);
fputs($oSocket, “Context: phones-pd\r\n”);
fputs($oSocket, “Account: 123456\r\n”);
fputs($oSocket, “Priority: 1\r\n\r\n”);
fputs($oSocket, “Action: Logoff\r\n\r\n”);

asterisk code


exten => s,1,Answer()
exten => s,n,Set(starttime=${STRFTIME(${EPOCH},%Y-%m-%dT%H:%M:%S)})
exten => s,n,Queue(retainerspd,60)
exten => s,n,Hangup()

exten => h,1,Set(currenttime=${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)})
exten => h,n,Hungup()

The Answer() in your dialplan does nothing. The answer for outgoing calls is performed by the remote side, and the channel is already up before the dialplan starts. (Hangup also does nothing, as simply falling off the end will do the same. Also it will only be reached if the queue is not answered, so you probably want to do more than hangup, e.g. apologise for the speechless call.)

Can you confirm this is ISDN, as there is no way of signalling reject over an analogue line, other than inband, and Asterisk doesn’t try and decode call progress tones and announcements.

If it is ISDN, you need to use a local channel, so that you can explicitly call the Dial application on the A side.

Thanks David for quick reply. Yes this is ISDN, can you please suggest how can i do it with local channel

Dial and look at ${HANGUPCAUSE} if the Dial fails, and drops through.

DO NOT call Answer() in your A side dialplan as that will cause problems.

I have already removed answer() but then even event is going through in the context only after call answer.can you please share some script how to handle this.

Adapt (there is a syntax error on the Hangup line).

However, if the callee is analogue, the network won’t know they rejected the call, and if mobile, it is normal for the call to be accepted by the voicemail service and appear successful to the caller. I don’t know if mobile networks generate cause 21 when there is no voicemail, and, in any case, it is probably network dependent. Some networks might just do a voice announcement, either as early media, or after an apparently successful answer.

1 Like

thanks, david I will try this. as of now I can see the rejected or not answered event on CLI but I am not able to get the same inside the context.

thanks a lot, David I am able to do it now getting the all kind of information I required.