Outgoing routing based on number match

Good morning,

I am looking for a possibility to use asterisk based on number match to a specific channel. I myself have little experience with asterisk programming and wonder if and how to realize this. Hopefully there is someone who could help me with this.

The wish is as follows.

It concerns one PBX with two channels (A and B). By default, all calls are routed to channel A. Only outgoing calls that are matched - these numbers are in a file or database - should be routed to channel B.

Hopefully this is a possibility and someone can tell me how to implement this.

Thank you in advance

Sincerely,
Patrick

What changes this from normal use of Asterisk to not entirely trivial is not the routing on numbers, but that you have to check the existence in a database. You should look at:

http://asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/asterisk-ICR-SECT-1.html#InternetCallRouting_id288593

Whilst this is a bit dated and some of the backends are deprecated, the general principles apply. (Later versions of the book are available but not as free downloads.)