Hello, I am trying to save every message (both fro...
# 🌎general
m
Hello, I am trying to save every message (both from bot and user) in a database. I am told that I can find this through the history property in the session. Any clue on how to go about access and viewing this history property?
a
There's two places to get chat history from. 1.
event.state.session.history
will keep the last 6 messages in the conversation (bot user and bot) 2. If the Summary Agent is enabled,
event.state.agentVariables.SummaryAgent.conversation.summary
will contain a short summary of the conversation that updates at every turn. Since you want to save every message, I'd recommend putting your code in an "Before Outgoing Message" hook so that it runs automatically and you don't have to manually run it in your flow.
m
Got it, thanks Gordy. I will give this a shot. Yes agree with using the session history variable that you outlined
I have attempted this and it 'soft of' works. It is hard to account for how many messages were in the session.history variable previously and how many are in the variable now.
So it makes it hard to keep track of what messages you have uploaded already vs. which new messages from session history you need to upload now.
3 Views