Missed Call Notification: When Follow me is "Enabled" - emails about missed calls are not received

I think, that this code may function correctly:
[from-internal-custom]
exten => 107,1,NoOp(Starting call handling for extension 107)
same => n,Dial(PJSIP/107)
same => n,Hangup()

exten => h,1,GotoIf($[“${DIALSTATUS}”=“NOANSWER”]?missedcall,s,1)

[missedcall]
exten => s,1,NoOp(Sending missed call notification)
same => n,System(echo “Content-Type: text/html\nSubject: Missed Call\nFrom: [email protected]\nTo: [email protected]\n\nYou have a missed call from phone number: ${CALLERID(num)}” | sendmail -t)
same => n,Return()

Yes, also my code can be wrong. :laughing:

1 Like

I´m testing your code in my pbx, right now.

1 Like

Its at this point i realize you’re trolling us. This second block of dialplan is orders (plural!) of magnatude worse than your first attempt.

I’m giving up. I will close by repeating for everyone that you CANNOT add an existing extension number to the from-internal or from-internal-custom context like this.

I just tested all this and I found the issue. At every point of the follow-me call that ends as a missed call the missed call notify is fired off.

Here’s one leg of the Local channel having it fired off on:

    -- Executing [FMPR@app-missedcall-hangup:1] NoOp("Local/FMPR-101@from-internal-00000006;1", "Dialed: FMPR") in new stack
    -- Executing [FMPR@app-missedcall-hangup:2] NoOp("Local/FMPR-101@from-internal-00000006;1", "Caller: 100") in new stack
    -- Executing [FMPR@app-missedcall-hangup:3] GotoIf("Local/FMPR-101@from-internal-00000006;1", "0?exit") in new stack
    -- Executing [FMPR@app-missedcall-hangup:4] Set("Local/FMPR-101@from-internal-00000006;1", "EXTENNUM=FMPR") in new stack
    -- Executing [FMPR@app-missedcall-hangup:5] Set("Local/FMPR-101@from-internal-00000006;1", "FEXTENNUM=FMPR") in new stack
    -- Executing [FMPR@app-missedcall-hangup:6] GotoIf("Local/FMPR-101@from-internal-00000006;1", "0?exit") in new stack
    -- Executing [FMPR@app-missedcall-hangup:7] AGI("Local/FMPR-101@from-internal-00000006;1", "agi://127.0.0.1/missedcallnotify.php,FMPR,,FMPR,0,,Local/FMPR-101@from-internal-00000006;1,,,,TRUE") in new stack

Problem here is the extension is set to FMPR so that’s not going to match an extension.

Here’s the second leg of the local channel having it fired off on:

-- Executing [Flowroute@app-missedcall-hangup:1] NoOp("PJSIP/Flowroute-00000022", "Dialed: Flowroute") in new stack
-- Executing [Flowroute@app-missedcall-hangup:2] NoOp("PJSIP/Flowroute-00000022", "Caller: 100") in new stack
-- Executing [Flowroute@app-missedcall-hangup:3] GotoIf("PJSIP/Flowroute-00000022", "0?exit") in new stack
-- Executing [Flowroute@app-missedcall-hangup:4] Set("PJSIP/Flowroute-00000022", "EXTENNUM=Flowroute") in new stack
-- Executing [Flowroute@app-missedcall-hangup:5] Set("PJSIP/Flowroute-00000022", "FEXTENNUM=Flowroute") in new stack
-- Executing [Flowroute@app-missedcall-hangup:6] GotoIf("PJSIP/Flowroute-00000022", "0?exit") in new stack
-- Executing [Flowroute@app-missedcall-hangup:7] AGI("PJSIP/Flowroute-00000022", "agi://127.0.0.1/missedcallnotify.php,Flowroute,,Flowroute,0,,PJSIP/Flowroute-00000022,,,,TRUE") in new stack
-- <PJSIP/Flowroute-00000022>AGI Script agi://127.0.0.1/missedcallnotify.php completed, returning 0

Again not going to match against the trunk name of Flowroute.

Executing [1313NXXXXXX@from@app-missedcall-hangup:1] NoOp("Local/1313NXXXXXX@from-internal-00000008;1", "Dialed: 1313NXXXXXX@from") in new stack
    -- Executing [1313NXXXXXX@from@app-missedcall-hangup:2] NoOp("Local/1313NXXXXXX@from-internal-00000008;1", "Caller: 100") in new stack
    -- Executing [1313NXXXXXX@from@app-missedcall-hangup:3] GotoIf("Local/1313NXXXXXX@from-internal-00000008;1", "0?exit") in new stack
    -- Executing [1313NXXXXXX@from@app-missedcall-hangup:4] Set("Local/1313NXXXXXX@from-internal-00000008;1", "EXTENNUM=1313NXXXXXX") in new stack
    -- Executing [1313NXXXXXX@from@app-missedcall-hangup:5] Set("Local/1313NXXXXXX@from-internal-00000008;1", "FEXTENNUM=13136NXXXXXX@from") in new stack
    -- Executing [1313NXXXXXX@from@app-missedcall-hangup:6] GotoIf("Local/1313NXXXXXX@from-internal-00000008;1", "0?exit") in new stack
    -- Executing [13136517001@from@app-missedcall-hangup:7] AGI("Local/1313NXXXXXX@from-internal-00000008;1", "agi://127.0.0.1/missedcallnotify.php,1313NXXXXXX@from,,1313NXXXXXX@from,0,,Local/1313NXXXXXX@from-internal-00000008;1,,,,TRUE") in new stack
    -- <Local/1313NXXXXXX@from-internal-00000008;1>AGI Script agi://127.0.0.1/missedcallnotify.php completed, returning 0

Again not going to match on 1313NXXXXXX

Also firing here:

Executing [FMGL@app-missedcall-hangup:1] NoOp("Local/FMGL-1313NXXXXXX#@from-internal-00000007;1", "Dialed: FMGL") in new stack
    -- Executing [FMGL@app-missedcall-hangup:2] NoOp("Local/FMGL-1313NXXXXXX#@from-internal-00000007;1", "Caller: 100") in new stack
    -- Executing [FMGL@app-missedcall-hangup:3] GotoIf("Local/FMGL-1313NXXXXXX#@from-internal-00000007;1", "0?exit") in new stack
    -- Executing [FMGL@app-missedcall-hangup:4] Set("Local/FMGL-1313NXXXXXX#@from-internal-00000007;1", "EXTENNUM=FMGL") in new stack
    -- Executing [FMGL@app-missedcall-hangup:5] Set("Local/FMGL-1313NXXXXXX#@from-internal-00000007;1", "FEXTENNUM=FMGL") in new stack
    -- Executing [FMGL@app-missedcall-hangup:6] GotoIf("Local/FMGL-1313NXXXXXX#@from-internal-00000007;1", "0?exit") in new stack
    -- Executing [FMGL@app-missedcall-hangup:7] AGI("Local/FMGL-1313NXXXXXX#@from-internal-00000007;1", "agi://127.0.0.1/missedcallnotify.php,FMGL,,FMGL,0,,Local/FMGL-1313NXXXXXX#@from-internal-00000007;1,,,,TRUE") in new stack
    -- <Local/FMGL-1313NXXXXXX#@from-internal-00000007;1>AGI Script agi://127.0.0.1/missedcallnotify.php completed, returning 0

Not going to match FMGL

And now it is routing back to the extension after follow-me has completed:

Executing [s@macro-hangupcall:1] Set("PJSIP/100-00000021", "__MCVMSTATUS=") in new stack
    -- Executing [s@macro-hangupcall:2] Gosub("PJSIP/100-00000021", "app-missedcall-hangup,s,1()") in new stack
    -- Executing [s@app-missedcall-hangup:1] NoOp("PJSIP/100-00000021", "Dialed: s") in new stack
    -- Executing [s@app-missedcall-hangup:2] NoOp("PJSIP/100-00000021", "Caller: 100") in new stack
    -- Executing [s@app-missedcall-hangup:3] GotoIf("PJSIP/100-00000021", "0?exit") in new stack
    -- Executing [s@app-missedcall-hangup:4] Set("PJSIP/100-00000021", "EXTENNUM=s") in new stack
    -- Executing [s@app-missedcall-hangup:5] Set("PJSIP/100-00000021", "FEXTENNUM=s") in new stack
    -- Executing [s@app-missedcall-hangup:6] GotoIf("PJSIP/100-00000021", "0?exit") in new stack
    -- Executing [s@app-missedcall-hangup:7] AGI("PJSIP/100-00000021", "agi://127.0.0.1/missedcallnotify.php,s,,s,0,,PJSIP/100-00000021,CHANUNAVAIL,,,TRUE") in new stack
    -- <PJSIP/100-00000021>AGI Script agi://127.0.0.1/missedcallnotify.php completed, returning 0

However, even here it is being sent to the s extension which isn’t going to match.

So basically the app-missedcall-hangup is being called 5 times and not once in the follow me flow or after is there a correct extension being tracked and sent to the module. So it never matches and thus never sends a notice.

This is a bug.

2 Likes

For example, I use in my pbx this code:
[from-internal-custom]
exten => 558,1,Progress
same => n,Dial(PJSIP/558,40,m(Music-On-Ringing))
same => n,ExecIf($[“${DIALSTATUS}” = “BUSY”]?Playback(custom/busy,noanswer))
same => n,ExecIf($[“${DIALSTATUS}” = “NOANSWER”]?Playback(custom/noanswer,noanswer))
same => n,Hangup()

Only you replace the playing prompt about no answer by the System command for email sending. This code can be easily, I think :grinning:

@mikeserg
Hi, I have an update for you. The code you sent is correct and works. My code too. It only depends on you, which one is more suitable for you. It works nicely. Listen, I also want to ask you that if you used “exten => h” in that code, it means that when the subscriber calls you, even if the phone does not ring and the calling party ends the call earlier, you will still receive an email about the missed call or no?

[from-internal-custom]
exten => 107,1,Gosub(missedcall,s,1(${CALLERID(num)}))
same => n,Dial(PJSIP/107)

[missedcall]
exten => s,1,NoOp(Sending missed call notification)
same => n,System(echo “Content-Type: text/html\nSubject: Missed Call\nFrom: [email protected]\nTo: [email protected]\n\nYou have a missed call from phone number: ${ARG1}” | sendmail -t)
same => n,Return()

in this case, yes, the email comes in any case, just after the call, whether the call was received or not

[from-internal-custom]
exten => 107,1,NoOp(Starting call handling for extension 107)
same => n,Dial(PJSIP/107&Local/89999999999@from-internal,20)
same => n,Hangup()

exten => h,1,GosubIf($[“${DIALSTATUS}”=“NOANSWER”]?missedcall,s,1(${CALLERID(num)}))

[missedcall]
exten => s,1,NoOp(Sending missed call notification)
same => n,System(echo “Content-Type: text/html\nSubject: Missed Call\nFrom: [email protected]\nTo: [email protected]\n\nYou have a missed call from phone number: ${ARG1}” | sendmail -t)
same => n,Return()

but in this case, yes, the email simply does not arrive at all. under no circumstances(

can you share your version of the config that works?

can I send your logs to the bug tracker?

this all looks, of course, like a feature of the implementation of calls in astersik or freepbx

Of course,
exten => XXX,1,Progress
same => n,Dial(Replace by your extension)
same => n,GotoIf($[“${DIALSTATUS}”=“NOANSWER”]?noanswer:hangup)
same => n(noanswer),System(echo “Content-Type: text/html\nSubject: Missed call\nFrom: Replace by your pbx email address\nTo: Recipient email address\n\nYou have a missed call from phone number ${CALLERID(num)}” | sendmail -t)
same => n(hangup),Hangup()

exten => XXX,1,Progress
same => n,Dial(Replace by your extension)
same => n,GotoIf($[“${DIALSTATUS}”=“NOANSWER”]?noanswer:hangup)
same => n(noanswer),System(echo "Content-Type: text/html\nSubject: Missed call\nFrom: Replace by your pbx email address\nTo: Recipient email address\n\n<html><body>You have a missed call from phone number ${CALLERID(num)}</body></html>" | sendmail -t)
same => n(hangup),Hangup()

I know I said yesterday I would hold my tongue, but it’s clear that UNK40 is not experienced with FreePBX dialplan nor are they testing what they share here in the forum. The dialplan above this post is the first thing they’ve shared that would be safe to use on an fpbx system, as it currently looks like this:

and that is only because it won’t do anything. (Unless you have a X key on your phone)

Value “XXX” will be replace by his extension. I don´t know, what number of extension do he have. I sent him an example of commands and variable values he have to replace by his values. I don´t know his sender email, that I can input it to code.

Your example lack any real explanation on how to use them. Such as replace XXX with your extension. It can be confusing because X is a pattern match variable that matches against 0-9 digits. So XXX could be 100, 453, 856, etc. and it just looks like you didn’t use the _ (_XXX) which would trigger pattern matching.

Also, why does this solution completely bypass the missed call module? This module relates the extension to a user and uses the email in the user profile. Your solution requires every single extension and email to be hard coded.

Finally, time and time again it has been advised to not use [from-internal-custom]. I’m not even sure why it still exists. It is known to case issues with how the system handles calls.

If you use the “from-internal-custom” context, everything is fine. That’s what the context is for, that when you need to program something, I mean something special, you can use this context. You should not edit the configuration files of Asterisk, because then there is a risk that it will not work according to your requirements. At worst, your entire Asterisk system will fail. As long as the context is programmed correctly, there is no need to worry. When something doesn’t work as it should or I want to program something myself, I use this context. It’s just about how one can win with it. If you have better code or know how to do it better, feel free to write it here. Of course, I don’t know everything either, but I’m trying to do it as best as I can. The code is complete, he just needs to edit it, which means that instead of “XXX” he puts his extension. And he adjusts other variable items, as long as he does everything right, the code will work for him. And to the rest of you too.

No, it is not. Your suggested dialplan would match first and thus it would not execute a bunch of dialplan that exists when a call is normally routed to XXX (being the extension in question).

Your solution doesn’t check for Call Waiting, DND, Call Forwarding or any other extension level feature that the can be used to handle the call (auto answer is another).

Your solution wouldn’t allow Follow Me, which is where the bug is for this flow.

Your solution doesn’t account for having multiple contacts, something that happens with chan_pjsip. So instead of dialling all the contacts, it dials only one.

Your solution doesn’t account for handling of any of the Alternative Destinations when a call isn’t answered. Nor does it account for CFU or CFB that might be set on the extension.

Your solution doesn’t account for handling of voicemail for any of the missed calls.

Your solution doesn’t account for missing a call because the extension was BUSY or UNAVAILABLE (offline). These are missed calls.

Your solution breaks any internal dialling from Queues or other features that would send the call into from-internal,XXX,1

Your solution basically dials a single contact and only on NO ANSWER sends an email. It beaks all the other functionally that would be used on the extension for FreePBX.

1 Like

In that case, the “custom destinations” module is available. You program the context that you insert into “config edit”. Then you create a “custom destination” and then set on the extension that if the extension does not answer, the call will go to this destination.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.