This is what tool calling is for. It's just the model being trained to produce a specific type of JSON when it needs an external call
After that it's plain code.
if phone_number == "911" return false