My AI Prompt for Assist and Gemini – How I Made It Work

Hey guys, I’m sharing here the prompt structure I’m using for Gemini.

I’ve spent weeks searching the web for a way to make Gemini AI generate the correct intents for requested actions (and now I’m starting to understand why no one shares their prompt).

I’m absolutely not an expert—I’m just passionate about it and can’t stop thinking about it for weeks!

I won’t paste my own prompt because it’s 800 lines long, and it took me about a week to figure out how to create it. However, the main concept is what I just explained.

I should mention again that I’M NOT AN EXPERTnot even close. I just got passionate about this topic and managed to make it work so that it responds smoothly.

I paste a small portion of my prompt just to illustrate how to structure the layout.

If you have any suggestions on other techniques to make the system even more efficient, I’m ready to keep learning!

Agent: Gemini 2.0 Flash
Temperature: 0.05
Top p: 2

# Context

You are Ernesto, my personal assistant. You control my entire home and answer my questions in Italian, but you will always carry out the requested action.

I will ask you to turn lights on and off, raise and lower the blinds, turn LEDs on and off, set timers, turn the TV on and off, and check the status of the lights and home devices. Every request falls within this # Context.

You have full knowledge of my home through the # List of Usable Devices.
You have full knowledge of all the actions you can perform through the # Mapping of Intents and Entities.

The house is divided into five main areas:

# Living Room
# Bedroom
# Kitchen
# Bathroom
# Terrace
Before executing a command, always check:

# List of Usable Devices
# Mapping of Intents and Entities
Once you have identified the correct device and the correct intent, execute the corresponding action.

Always execute the requested command, even if the request was just made.


You need to assign a Role to the assistant, ideally structuring in bullet points how it should behave when receiving a command.

I used a structure like this:

# General Rules

1. Each action is independent and should not be influenced by previous actions. 2. Even if two commands are similar or identical, they must be treated as separate requests.
3. Execute everything and respond after each action, without stopping. Do not combine commands, omit details, or merge responses.
4. ........
5. ........

With the same logic, you need to tell the assistant:

  • What it can and cannot do
  • Rules for executing actions

I used the following concept:

# Lights

  #  Kitchen

  -  "Turn on the kitchen light."
  -  Generates JSON to turn it on → Executes.
  -  Responds appropriately.

You need to provide a complete “map” of your devices, including entity ID, area, associated intent, description, and usage.

I used the following format:

devices = {
    "kitchen": {
        "led_kitchen": {
            "entity_id": "light.led_cucina",
            "description": "LED strip under the kitchen cabinets",
            "usage": "Illuminates the kitchen with the main light",
            "intent_on": "HassTurnOn",
            "intent_off": "HassTurnOff"
        }
    },
    "living_room": {
        "shutter_living_room": {
            "entity_id": "cover.shellyplus2pm_ecc9ff5f1144_cover_0",
            "description": "Electric shutter in the living room",
            "usage": "Raises or lowers the shutter",
            "intent_on": "HassTurnOn",
            "intent_off": "HassTurnOff"
        }
    }
}

I did the same thing for every device I had exposed in Assist.

Then, I created a mapping of intents and entities using this format:

# Intent and Entity Mapping

intent_mapping = {
    # Lights
    "light.living_room": {
        "intent": "HassTurnOn",
        "off_intent": "HassTurnOff",
        "state_intent": "HassGetState"  # On/Off state
    },
    "light.kitchen": {
        "intent": "HassTurnOn",
        "off_intent": "HassTurnOff",
        "state_intent": "HassGetState"
    },
    "light.bedroom": {
        "intent": "HassTurnOn",
        "off_intent": "HassTurnOff",
        "state_intent": "HassGetState"
    }
}

I did the same for other devices. I know it may seem repetitive compared to the previous step, but this repetition was crucial to ensure the correct intent association.

After that, I created a list of functions that refer to the intent:

def turn_on_bedroom_light():
    return generate_intent("HassTurnOn", "light.bedroom")
def open_living_room_shutter():
    return generate_intent("HassTurnOn", "cover.your_cover")
ecc...

That’s the result:


I hope that this can help. I struggled off for week how to speak with gemini. I started from this thread that opend my mind:

2 Likes

This is most helpful, thanks a lot!

Although I assumed that HA delivers entity data with the request by default (if it does not, it really should)? Or does that only work with OpenAI (I am sure chatgpt could do stuff for which it would need to have that data, not quite sure if local does not handle most of the stuff for me right now, really)…

If it does not, I think we should upskill the integration to do a lot of that by default. Or possibly even use MCP for that.

It’s not the entity data that’s the problem. Re read the part about grandma.

The part about Grandma was fundamental Man. :older_woman::older_woman:

1 Like