Q1: How do I show only the last object of a list of objects? In this case, that would be object #21.
Right now it shows every single thing, i only want it to show the last thing…
Q2: Also, within each object there is a “role” item inside. What if I only want it to show the last “user” object, not “assistant”. How do I show that? In this case, that would be #20, not #21. How do i do that?
q1 using weweb’s formulas:

q2 you can do it in many ways.
one example with weweb’s formulas:

one example with javascript:
const messages = variables[/* messages */'b5533a69-83b9-4c64-bd24-589a99060e1d'] // your array here
const key = 'role' // the key to look for in the object
const value = 'user' // the value to look for
let data
for(let i=messages.length-1; i>=0; i--){
if(messages[i][key]===value){
data=messages[i]
break
}
}
return data
1 Like