My goal is that I could direct a call through the trunk through ARI, if I specify it strictly in routing and without specifying the trunk it works correctly, I need to understand the syntax of how to tell me that he would call the internal number first, then to the external one through a certain trunk
Is this a school exercise? This goals seems an artificial goal to exercise ARI, rather than a useful business goal.
Asterisk is a toolkit. It doesn’t have standard patterns for high level operations. The pattern you are using creates a channel to an end point, then runs a section of dialplan on that channel. You have to supply it with dialplan that does what is necessary to complete the operation. In this case, the dialplan should closely match the typical beginners; examples for making outgoing calls, but it still has to exist.
There are three types of number in your examples. In the first example external number represent digits to dial, and internal number represents the name of an extension in the dialplan. In the second, internal number represents the name of a peer definition, in sip.conf, and external number is the name of an extension in the dialplan.
Before you start using new features, like ARI, you really need to be comfortable that you understand how to configure a simple PABX, using just dialplan, and that you understand what the configuration means.
Also note that chan_sip is scheduled for removal from Asterisk in the near future. You should use chan_pjsip for new SIP based systems.
If your real gaol is click to call, there are many examples around, although most, or all, pre-date ARI.
no, this is not a school exercise) As a result, in one of the programs there will be 2 buttons where these commands will be, where numbers will be substituted instead of XXX, integration if you want, this already works in the example that i gave but not quite the way I want it as I need it so that the call would first go to the internal number and then to the external one, I was able to implement the opposite and a simple rearrangement does not work here.
Simple rearrangement depends on what you have in your dialplan (and also what you have in sip.conf, although that is less likely to be the problem here).