Using call file to connect an extension to an IVR

I have set up some Home Assistant automations, and in some cases I make FreePBX call a ring group and play a recording by creating a call file.This is working correctly.
Whoever picks up gets a phonecall that plays a warning message.
I want to extend this functionality so the one receiving the message actually has to acknowledge it and confirm he/she will take action, for instance by pressing 1. If this doesn’t happen, the process should start over and hopefully someone else will pick up the call and take action. I think the easiest way to do this is an IVR. I have created an IVR and a misc application so I can reach the IVR by a number (704* in this case).

I am using this call file.
channel: PJSIP/1021
callerid: “Alarm notification”
application: originate
data: Local/704*@from-internal,exten,from-internal
(and some wait/retry stuff that isn’t relevant)

When I trigger the automation the extension gets dialled. However, when I pick up the PBX hangs up.

I do see the IVR being called though:
pbx_spool.c: Unable to set utime on /var/spool/asterisk/outgoing/ Operation not permitted
pbx_spool.c: Attempting call on PJSIP/1021 for application originate(Local/704*@from-internal,exten,from-internal) (Retry 1) —> not sure why it is retrying as I don’t see a first attempt

dial.c: PJSIP/1021-0000008f is ringing
dial.c: PJSIP/1021-0000008f answered
dial.c: Called 704*@from-internal
pbx.c: Executing [704*@from-internal:1] NoOp(“Local/704*@from-internal-00000016;2”, “Running miscapp 1: redirect-to-IVR1 app”) in new stack
pbx.c: Executing [704*@from-internal:2] Macro(“Local/704*@from-internal-00000016;2”, “user-callerid,”) in new stack

pbx_spool.c: Attempting call on PJSIP/1021 for application originate(Local/704*@from-internal,exten,from-internal) (Retry 1)

pbx_spool.c: Call completed to PJSIP/1021 → why?

pbx.c: Executing [[email protected]:8] Set(“Local/704*@from-internal-00000016;2”, “IVR_MSG=custom/message1&custom/message1”) in new stack
pbx.c: Executing [[email protected]:9] Set(“Local/704*@from-internal-00000016;2”, “TIMEOUT(digit)=3”) in new stack
func_timeout.c: Digit timeout set to 3.000
pbx.c: Executing [[email protected]:10] ExecIf(“Local/704*@from-internal-00000016;2”, “1?Background(custom/message1&custom/message1)”) in new stack
[C-00000031] file.c: <Local/704*@from-internal-00000016;2> Playing ‘custom/message1.slin48’ (language ‘en’)

So it looks like the IVR is actually called and activated, it’s just not linked to the other call anymore.

Any idea what I’m doing wrong here?

What exactly is the process followed to get the call file into /var/spool/asterisk/outgoing ?

I am using this on my FreePBX machine:

It’s a python script that connects to the MQTT broker on Home Assistant and listens for specific topics. When a relevant message is received it will launch a bash script ( in the same post) that will create the file.

This part is working fine; if you were asking this to get it working yourself I can share the actual config files from Home Assistant but it’s not really related to this topic.

No, I am asking you because you would appear to have a problem with ownership/permission/completeness of the call-file being processes.

Potentially, but would that explain why playback works fine?

When I put this in the same file, the call works correctly:
channel: PJSIP/1021
callerid: “Alarm notification” <2008>
application: playback
data: /var/lib/asterisk/sounds/nl/custom/message1

The given call file will call PJSIP/1021. Once answered it will execute the “Originate” application with the given data. The call to PJSIP/1021 will then be hung up, because Originate just originates and does nothing else. Doesn’t connect them, nada. The call file is doing what you’ve told it to do.

If you wanted to send the call to PJSIP/1021 into the dialplan, then the Context/Extension/Priority fields would be used instead.

Thanks. How would that work in practice (as in: which command would I have to enter in the call file)? I don’t see any of these three options under the “applications”.

You wouldn’t enter a command. The context/extension/priority fields are alternatives to an application.

The options are clearly present in the documentation:

Thanks, that worked!
Now comes the next challenge. If the receiver DOESN’T press 1, I should call the same number (in reality it is a ring group rather than an extension) again and route it to the same IVR again. Essentially the timeout action should be “process the same callfile again”, and that until someone presses 1 and breaks the chain.
What would be the most efficient way to do that?

I partially solved the problem with the “callback” function. However, if someone answers, and doesn’t wait for the IVR to timeout but hangs up instead, the chain will stop. Is there a workaround for this?

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