Kind "Follow me" for a External Number to SIP Extension?

How can I make a kind “Follow Me” for a external number (trunk), pointing first to SIP Extension and then to a trunk with a kind of firstnotonphone or firstavailable.

Let me explain my scenario:

I have softphones in 5XXX and Nortel PBX Extensions (6XXX), and I need to make transparent to users to call the old way 6XXX and mask it to 5XXX if online, else call the internal Nortel PBX through a Cisco VoIP Gateway.

Thanks for help!