From 851b53d3480ab38fac3744363d9386b11af4827b Mon Sep 17 00:00:00 2001 From: Kostas Chatzikokolakis Date: Fri, 20 Oct 2023 17:23:18 +0300 Subject: [PATCH] Use action response in intent_script speech template (#28156) --- source/_integrations/intent_script.markdown | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/source/_integrations/intent_script.markdown b/source/_integrations/intent_script.markdown index 157cb28bbe5..2fd41fed9fe 100644 --- a/source/_integrations/intent_script.markdown +++ b/source/_integrations/intent_script.markdown @@ -77,3 +77,33 @@ intent: required: true type: template {% endconfiguration %} + +## Using the action response + +When using a `speech` template, data returned from the executed action are +available in the `action_response` variable. + +{% raw %} + +```yaml +conversation: + EventCountToday: + - "How many meetings do I have today?" + +intent_script: + EventCountToday: + action: + - service: calendar.list_events + target: + entity_id: calendar.my_calendar + data_template: + start_date_time: "{{ today_at('00:00') }}" + duration: { "hours": 24 } + response_variable: result # get service response + - stop: "" + response_variable: result # and return it + speech: + text: "{{ action_response.events | length }}" # use the action's response +``` + +{% endraw %}