Ringing to SIP account after hangup

Hi, is possible set up dialplan as follow? I have Asterisk and I need hangup call from mobile phone, and Dial or ringing to another SIP number, which mobile call was hangup?

I need some as:

exten => _X.,1,Hangup()
exten => _X.,2,Dial(SIP/J&SIP/D,120,g)

Its possible some as this?

You would need to use the Originate[1] dialplan application in an β€˜h’ extension or hangup handler[2]. Once you do Hangup() in normal execution the subsequent steps are not executed, same if they hang up.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Application_Originate
[2] https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers

Im tried

exten => _X.,1,Hangup()
same => n,Originate(SIP/J,exten,default,originated,1)


exten => _X.,1,Hangup()
exten => _X.,2,Originate(SIP/J,exten,default,originated,1)

for now, but not one does not work. What is right or what is the right form?

Neither are right. As I mentioned, once Hangup() is executed dialplan execution stops except for the β€˜h’ extension or hangup handlers. You can’t proceed in the dialplan normally with a channel that no longer has anyone connected to it. The wiki page I posted has a few examples of using hangup handlers. If you want to use the β€˜h’ extension you could do something like:

exten => h,1,Originate(SIP/j,exten,default,originated,1)
1 Like

Its not good, because when running Originate, its quiet, I need same beep tone as Hangup().

It is not entirely clear what you are trying to do, but the answers so far assume that when a call between A and B, or A and internal services, ends, , you want to start a call between C and D.

If you want to do that and play a tone to A, after A has been answered, you will have to explicitly play a tone, as Hangup cannot initiate tones on a channel that has already been answered.

I think, though, that you need to provide a detailed specification of how you want the system to behave, and also the higher level requirement that results in your wanting that behaviour.

For example, if want to a sequence in which A calls to B, and when B hangups, A is connected to C, that is completely different from the above.