https://discord.gg/botpress logo
#🤝help
Chat History In Array
# 🤝help
a

adorable-belgium-29368

07/23/2023, 10:06 PM
I'm trying to export the chat history into an array variable that saves both the bot's and the users' messages. However, I'm only able to store the last 6 interactions. Any hints? I need to export the entire chat.
c

curved-traffic-50479

07/23/2023, 10:18 PM
how could you find the last 6 interactions?
i have similer problem, need to export the history chat
a

adorable-belgium-29368

07/23/2023, 10:26 PM
tried these (like it says in the chat support (didnt work): workflow.userHistoryArr.push({user_said:event.preview}) workflow.userHistoryArr.push({bot_replied:workflow.answer}) so i tried these: workflow.chatHistory = [] event.state.session.history.map((message) => { { workflow.chatHistory.push(${message.sender}:${message.preview}) } }) but im just getting 6 elements Any clue?
c

curved-traffic-50479

07/23/2023, 10:27 PM
did u run the code i excude code ?
a

adorable-belgium-29368

07/23/2023, 10:27 PM
no, how is it?
c

curved-traffic-50479

07/23/2023, 10:28 PM
where did u run the cod to get the 6 elements ?
a

adorable-belgium-29368

07/23/2023, 10:28 PM
In an execute code card
c

curved-traffic-50479

07/23/2023, 10:28 PM
aha okej
what are you trying to archive ?
with chat history
a

adorable-belgium-29368

07/23/2023, 10:29 PM
I want the whole chat history, export it as an array (bot an user) so i can uset in a database (firestore)
the only way that i have found its export the {{conversation.SummaryAgent.transcript}}
but it export it as a single string (not as an array)
@early-train-33247 any suggestions? I just read a post from you, but i dont know how to implement a before incoming hook and a before outgoing hook. Can you helpme please? 🙏
l

limited-forest-26830

08/03/2023, 10:20 AM
hi were you able to do so
e

early-train-33247

08/18/2023, 1:46 AM
Hey folks, we now have the history available in the
event.state.session.fullHistory
variable
check out the hooks tab to see how this custom variable is populated

https://cdn.discordapp.com/attachments/1132795803166064640/1141911176394051735/image.png