F
F
Father42021-12-16 20:22:42
Asterisk
Father4, 2021-12-16 20:22:42

Asterisk call result call file?

Hello. There is an asterisk configured to make calls from the call file.
the file itself:

Channel: Local/[email protected]_test
Context: out
Extension: 100
Set: dialout_number=79001234567
Archive: yes


extensions_custom.conf
[outbound_test]
exten => 123,1,System(echo "Dialout number ${dialout_number}" >> /tmp/123)
same => n,Dial(SIP/78633000000/${dialout_number},20)
same => h,n,System(echo "${DIALSTATUS}" >> /tmp/1234)

[out]
exten => 100,1,Noop(Answered)
exten => 100,2,Hangup()
exten => 100,3,Noop(echo "${DIALSTATUS}" >> /tmp/12345)


Everything is fine, the call goes through. Information about the number is added to the /tmp/123 file.
But neither in /tmp/1234 nor in /tmp12345. Even files are not created. The task is to get the value of ${DIALSTATUS}.

log
-- SIP/78633000000-00000009 answered Local/[email protected]_test-00000005;2
    > Channel Local/[email protected]_test-00000005;1 was answered
 -- Executing [[email protected]:1] NoOp("Local/[email protected]_test-00000005;1", "Answered") in new stack
 -- Auto fallthrough, channel 'Local/[email protected]_test-00000005;1' status is 'UNKNOWN'
[Dec 16 21:11:49] NOTICE[27698]: pbx_spool.c:427 attempt_thread: Call completed to Local/[email protected]_test
  == Spawn extension (outbound_test, 123, 2) exited non-zero on 'Local/[email protected]_test-00000005;2'


Tell me in which direction to dig

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
R
Rsa97, 2021-12-16
@Rsa97

We need to add the g option, which allows Asterisk to continue executing the dialplan after the call ends.

same => n,Dial(SIP/78633000000/${dialout_number},20,g)

A
Andrey Barbolin, 2021-12-17
@dronmaxman

For g to work, you need to do this, but it still won't work if the extension hangs up first.

[outbound_test]
exten => 123,1,System(echo "Dialout number ${dialout_number}" >> /tmp/123)
same => n,Dial(SIP/78633000000/${dialout_number},20,g)
same => n,HangUp()

exten => h,1,System(echo "${DIALSTATUS}" >> /tmp/1234)

If it is correct, then I recommend doing it through the handler. And in the system I recommend adding & at the end.
[hdlr-dialstatus]
exten => s,1,Verbose(0, -----Dial Status handler -----)
 same => n,System(echo "${DIALSTATUS}" >> /tmp/1234 &)

 [outbound_test]
exten => 123,1,System(echo "Dialout number ${dialout_number}" >> /tmp/123)
 same => n,Set(CHANNEL(hangup_handler_push)=hdlr-dialstatus,s,1(${EXTEN}))
 same => n,Dial(SIP/78633000000/${dialout_number},20)
 same => n,HangUp

D
Dmitry Shitskov, 2021-12-16
@Zarom

exten=> h,1,System(echo "${DIALSTATUS}" >> /tmp/1234)

In other words:
Explicit Hangup and Implicit Hangup (After Dial) complete the processing of the dialplan - everything after it will not be executed.
Next, what crutches exist to do something with Hangup:
  1. extension h in the current context - as far as I remember, it will be called whenever the call ends
  2. the g option already suggested will allow execution to continue after the Dial is complete, but only if the called party hangs up - not good for you
  3. parameter F([[context^]exten^]priority) - will transfer the called subscriber to the specified context/exten, if the caller hung up - also not your case. For example, transfer it to a machine that will ask you to evaluate the service

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question