Hello again all. Once again I am asking for your help.
I have been building up the following template in the Developer Templates tab using data output from the Calendar:Get Events action.
I am trying to handle the edge of case of when there isn’t a second event in the returned data by only attempting to utilise data from a second event when it is not null. Unfortunately, it is instead returning an error because the value is null!
I’d appreciate any insight you can offer. I believe the problem comes from my lack of experience in error handling in templates.
{% set action_response = {"calendar.david_work":{"events":[{"start":"2026-01-21T16:00:00+00:00","end":"2026-01-21T23:45:00+00:00","summary":"4-Mid"}]}} %}
{% if action_response["calendar.david_work"]["events"][1].start != '' %}
{% set shift_start_date = action_response["calendar.david_work"]["events"][1].start | as_datetime %}
{{shift_start_date}}
{% else %}
Off
{% endif %}
The above template gives this error:
list object has no element 1
Many thanks in advance