Using logic/test with custom intents/sentences

I’ve read the docs and did a quick search here, but don’t see an answer.

I have a bunch of custom intents and sentences set up, but can’t figure out how to do this:

Our phones have geocoded locations and zones for frequent locations defined. We also have Bluetooth proxies in every room.
What I’m trying to accomplish is simple, If I ask:

  SonLocation:
    data:
      - sentences:
        - "Where is Son"


SonLocation:
    Speech:
<If zone('device_tracker.sons_phone') != "Home" say >
      text: "Son is at {{ states('device_tracker.sons_phone') }}."
<if zone('device_tracker.sons_phone') == "Home">
      text: "Son is at home, in the {{ states('sensor.sons_phone_area') }}. "

Example outputs would be:
“Son is at School.”
“Son is at Home, in the Garage.”

Is there a way to do this? If so, please provide an example.

Thanks in advance!

I did something like this a while ago to test room presence. I would ask “Where am I?” and the intent would reply with the name of the room. In this case I didn’t try to include any logic in the intent - that was handled by a template sensor:

language: "en"
intents:
  CustomRoom:
    data:
      - sentences:
          - "Where am I"
          - "(What | Which) room am I in"

CustomRoom:
  action:
    - service: script.willow_tts_response
      data:
        tts_sentence: >-
          Well, I may be wrong, but I think, you're in the {{ states('sensor.most_likely_room') }}.

That way you can test the logic of the template in Developer Tools and the intent itself remains quite simple.

Yes, you can use logic in your response. One if-then-else condition is enough. See what the correct syntax looks like for jinja2.
Go to github, there are tons of examples.