Inbound route to voice mail

What I would like to do is this:
My inbound route has one DID. Now depending on the number that called, I want the route destination to match the voicemail of the calling party.

E.g. 2517 calls my inbound route DID 5299, then I want the call to go to voice mail 2517 in Asterisk, which I have set up.
This is to use my Asterisk as a voice mail server for my extensions on the legacy PBX.

Is that possible without having to create a unique inbound route for every voice mail account that I have set up?

You could do this with custom dial plan otherwise you will have to make a route for each. How many routes do you have?

I have 300 numbers I would like to do this with. So too many to have a route for each of them.

So I will go with a custom dialplan that would look like this:
When call comes in on extension 5299, look at the calling party ID, and route call to * + calling party ID.
E.g. 2517 calls 5299, then call must route to *2517.

Where do I configure such a custom dialplan to accomplish this?

You could try using the context “from-did-direct” for the trunk from your legacy PBX, turning the MWI lights on/off on the legacy Phones is another matter, you will need to write

externnotify = yourscript

in /etc/asterisk/voicemail.conf

Thanks dicko for your help on this.
Where would I change the context for “from-did-direct” and what would the change look like exactly with what I want to do?

FreePBX 12, Asterisk 11.

either in the trunk if you are using one . or make a custom extention to suit. but one extension to handle 300 users voicemail will cause a problem sooner or later.

I can use several extensions eventually.
Now when creating a custom extension I don’t know where to configure the context to adjust my routes to specific extensions. Where do I go from below.

Or do I add a custom extension like this and alter one these fields?

Ok, got it.
I have to edit extensions_custom.conf.
What is the right dial plan config to achieve what I want.

exten => 5230,1,Answer
exten => 5230,n,Goto…

Something like that?

Sorry for all these beginner questions.
I know you guys prefered us looking at documentation first, but things are not always easy to find.