Conversation Process Service

Hi All

I may be doing something wrong here but trying to have a play with the new service responses from the conversation.process.

Apart from simply messing around, my aim is to add some randomness to some of our automated messages.

I find that quite often I get the following response:

Sorry, I had a problem talking to OpenAI: The server is overloaded or not ready yet.

Which is fine but I dont want that randomly read out.

If I use developer tools to run this service I get the following response when it works:

response:
  speech:
    plain:
      speech: >-
        Why don't scientists trust atoms?
        Because they make up everything!
      extra_data: null
  card: {}
  language: en-GB
  response_type: action_done
  data:
    targets: []
    success: []
    failed: []
conversation_id: xxxxxxxxxxxxxxxxx

When it doesn’t work I get the following:

 response:
  speech:
    plain:
      speech: >-
        Sorry, I had a problem talking to OpenAI: The server is overloaded or
        not ready yet.
      extra_data: null
  card: {}
  language: en-GB
  response_type: error
  data:
    code: unknown
conversation_id: xxxxxxxxxxxxxxxxxx

So I thought I could simply template the response by using the ‘response.response_type’.
The idea being that if it is ‘action_done’ then read the speech response and if its ‘error’ read out a static message for example.

Something like: (sudo)

      message: >-
        {% if ('response.response_type' == 'action_done') %} 
        read out the response {% else %} 
        read our original static message {% endif %}

But I cant get it to work and I don’s see the full response data as shown above when using dev tools to call the service in the automation and/or script traces - so is it simply not there OR am I not templating correctly?

Any input appreciated
Thanks

1 Like

OK, it was me being an idiot…might have guessed.

The correct format is:

{% if ('response.response_type == action_done') %}

Can you post the whole response formatting you used? I am using a response variable in my automation and the next step is to send the response in an HA notification. But I get the full response(see image) what do I put to only have it send the “speech:” part of the response?

I tried
’"Assist Reply: {{ response.speech }}"
But it says template error.

{{ response.speech.plain.speech }}
1 Like

Worked perfectly thank you!