Access slots in the prompt even if no active flow

I have a prefilled slot that I want to access its value from the prompt.

I tried to access it using {{slots.slot_name.value}} but with no luck.

I saw that I can access slots from an active flow only, but in my case this slot doesn’t belong to any flow!

The complication here is that slots in the prompt template is a list of dicts, not a dict itself. To unpack it you need to loop over all the slots and pull out what you need.

Here’s some sample jinja code that looks for a slot named language and uses its value to change the output language of the LLM:

{% set language = 'English' %}
{% for slot in slots %}
  {% if == "language" %}
    {% set language = slot.value %}
    {% break %}
  {% endif %}
{% endfor %}

Your responses should be in {{ language }}