Dialplan for two sip trunks

Is there an easy way or dialplan to have certain extensions on the same context dial out via different SIP trunks? Like say extension 301 dial out using sip-trunk1 and extensions 302 and 303 dial out using sip-trunk2? The easiest way I can determine so far is to say dial 9 first for sip-trunk1 and 8 first for sip-trunk2, but it would be nice to just pre-configure the extensions to go out the different trunks by default.

There are multiples ways to achieve this task

  • Put the extensions on differents context.

  • Choose the trunk based on the value ${CALLERID(num)} variable.

  • and many other ways …