Change call flow based on results of a custom destination

I use spam filtering that is similar. Callers in the phonebook ring through, others are sent to an IVR (leading to voicemail if they fail to press the correct key). See [SOLVED]Inbound routing for code sample.