Need help with Custom Dynamic Feature <Activated By>

Hi Guys,

Starting a new post as the old one (Adding caller ID to blacklist during call), in which I asked this question as a response, seems to have died :/.

What I’m trying to do:
When someone calls me, I’d like to press *9 (say) to blacklist the caller. I’d like a message played to me saying that the blacklist has been successful and maybe a message played to the caller saying that he/she has been blacklisted.

What I did:
As per david551’s and satish4asterisk’s valuable suggestions, I have managed to implement most of it as follows:

**features.conf**
[applicationmap]

apps => *9,peer,Macro,appblock

**extensions.conf**

......
......

;this part is a continuation of the rest of the dial plan. skipped the above part (of dial plan) as it isn't related to the question and may be confusing.

[macro-dial-extension]
exten => s,1,Set(_DYNAMICFEATURES=apps) ;if I don't put double underscore, then when B calls A (i.e. me), only B is able to press *9 and use the feature
same => n,Dial(${ARG1},u)
same => n,Return()

[macro-appblock]
exten => s,1,Set(DB(blacklist/${CALLERID(num)})=1)
same => n,Set(Value=${DB(test/${CALLERID(num)})})
same => n,SayDigits(1234) ;I'd like to put a message like "block successful"
same => n, MacroExit ; not sure what this is for

Ok, now the issue I have is:

Both the caller and the called party can press *9 to initiate the custom feature. From what I read, the “Activated By” field is no longer honoured so I have left it out. Ideally, I’d just want my side to be able to blacklist (it doesn’t make sense for the caller to blacklist my number on my own PBX!).

Also, currently the SayDigits(1234) is heard by the opposite channel (eg. if I press *9 then the caller hears it). But, I want to be able to hear “block successful”.

Any help would be appreciated.

Thanks,
Clive

Deprecated doesn’t mean ignored. It means that there is a better way of doing the same thing, and the current way may be withdrawn in the future. The documentation that says it is deprecated should say what replaces it. I suspect it might be whether or not you enable it in the channel variable before calling Dial.

You need to use a Predial Handler and add your feature there.

https://wiki.asterisk.org/wiki/display/AST/Pre-Dial+Handlers

https://wiki.asterisk.org/wiki/display/AST/Custom+Dynamic+Features

I did try it (specifying the Activated By field as callee) but I don’t think it worked. I can’t recall my result so I shall try it again and post a response.

Thanks @johnkiniston, I’ll look into Predial Handler and post a response.

First, apologies for the long delay in my response. Second, I should have used a different word rather than “deprecated”. The documentation says “ActivatedBy is no longer honored”. I tried apps => *9, peer/callee, Macro, appblock and it made no difference. Both caller and callee were able to use the feature.

Does predial handler allow me to activate a customer feature while on a call? I don’t quite get what I must do with the predial handler.

predial handlers let you run any dialplan of your choice before the call is dialed, You should be able to set your DYNAMICFEATURES variable in the predial handler you create and then it would apply on the calls that apply to your dial command.

1 Like

Thanks for your response. What I’m trying to do is to activate the dynamic features on the outbound channel only - so that if a telemarketer calls me, only I can activate the feature and block him.

Thanks @johnkiniston. It seemed to have worked. I’m now able to activate the customer features only on the callee’s channel.

Here’s the relevant part of the code:

[macro-dial-extension]
exten => s,1,NoOp()
same => n,Dial(${ARG1},5,b(test^callee_handler^1)) ; goes to [test] context to execute the lines under [test] on callee's channel
same => n,Return()

[test]
exten => callee_handler,1,NoOp()
same => n,Set(__DYNAMIC_FEATURES=apps) ;now dynamic features can be activated by the callee's channel only. The documentation says "The feature is activated by which channel DYNAMIC_FEATURES includes the feature is on". 
same => n,Return()

[macro-appblock]
exten => s,1,Set(DB(blacklist/${CALLERID(num)})=1)
same => n,Set(Value=${DB(test/${CALLERID(num)})})
same => n,SayDigits(1234) ;I'd like to put a message like "block successful"
same => n, MacroExit ; not sure what this is for

However, note that there is a double underscore before DYNAMIC_FEATURES, I’m not sure why that didn’t make the feature active on both channels. But, I’ve got what I wanted. Even without the leading double underscore, the features were activated only on the callee’s channel. Perhaps, the predial handler overrides the double underscore setting.

Thanks a lot guys.

1 Like

To add on to my post, I’d also like to play a message to myself to say something like “Block successful”. However, when I test with SayDigits(123), the message is heard by the caller and not by callee (me). How can I fix this? @johnkiniston @david551

@clivesam have you resolved this issue…? I am also getting the same issue although I am using Asterisk 16 and I know I am missing something, may be I have to playback on the callee explicitly