Jan 19 2024 07:48 AM - edited Jan 19 2024 07:49 AM
Not sure if this is the right space for this. I have a Teams Bot built with the Bot Framework Composer and recently noticed the following behavior change.
I grab the user's response via = turn.activity.text
I set an array property to user.inputData
[ { "role": "user", "content": "${turn.activity.text}" } ]
Prior to a few days ago, step Send a Response: ${user.inputData} showed:
[ { "role": "user", "content": "test" } ]
now the step Send a Response shows:
{ "lgType": "Activity", "text": [ { "role": "user", "content": "test" } ] }
however if I concatenate a string to it in step Send a Response: input is ${user.inputData} then it displays correctly:
the input is [ { "role": "user", "content": "test" } ]
It seems like the Bot Framework Composer is interpreting ${user.inputData} differently now. The new output format is treating user.inputData as an object with properties lgType and text, where text holds my array. Did the template engine change in processing expressions?
I attempted to display user.inputData in two ways: directly and by concatenating it with a string. When displayed directly, I received an output showing the object with its properties ({ "lgType": "Activity", "text": [array] }). However, when I concatenated user.inputData with a string (e.g., input is ${user.inputData}), it displayed the array as expected, without the object properties. I was expecting consistent behavior in both cases, where user.inputData would simply display the array.
Jan 21 2024 10:08 PM
Solution@aymiee - The behavior change you are experiencing is due to an update in the template engine used by the Bot Framework Composer. The new output format treats user.inputData
as an object with properties lgType
and text
, where text
holds your array.
Jan 22 2024 08:58 AM - edited Jan 22 2024 09:39 AM
Thank you -- I have made the changes on my backend but now the Bot Framework is throwing errors. My web app use to return the response in a 'message' field and I retrieve it in the Bot Framework as so: ${turn.results.content.data.message}
Recently, I started getting "Operation returned an invalid status code 'BadRequest'". The structure of ${turn.results} has changed to:
{ "lgType": "Activity", "text": { "statusCode": 200, "reasonPhrase": "OK", "headers": { "Date": "Mon, 22 Jan 2024 04:58:15 GMT", "Server": "gunicorn" }, "content": { "data": "How can I assist you today? If you have any IT-related queries, need information from the company data, or have compliance-related questions, feel free to ask!" } } }
Attempts to access the data with ${getProperty(turn.results.text.content, 'data')} have been unsuccessful resulting in Operation returned an invalid status code 'BadRequest'
Additionally, ${turn.results.text}, ${turn.results.text.content}, ${turn.results.text.content.data} and are returning empty. How should I obtain 'data' value from the JSON structure in Bot Framework Composer? The standard methods for access the data are not working. Please advise.
EDIT --FIXED -- I modified my Flask app to not encapsulate the response in a JSON object with 'data' as the key since the Bot Framework Composer already uses 'content' and 'data' keys in its JSON structure. I can now access value via ${turn.results.content}
Jan 21 2024 10:08 PM
Solution@aymiee - The behavior change you are experiencing is due to an update in the template engine used by the Bot Framework Composer. The new output format treats user.inputData
as an object with properties lgType
and text
, where text
holds your array.