AI agents - how to save messages in UI
Hello,
I have started to use AI Agents with convex, and I can get it to work nicely, but when I refresh the pages in my Next.js project, it does not save the messages.
Any good best practices?
3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
I think there are two ways for you to do so, one is by updating it in the
Agent
object, or when you want to save the thread/messages you pass it in the mutation itself, see:
https://github.com/get-convex/agent/tree/main?tab=readme-ov-file#configuring-the-storage-of-messagesGitHub
GitHub - get-convex/agent: Build AI agents on Convex with persisten...
Build AI agents on Convex with persistent chat history - get-convex/agent
and to retreive messages in thread:
https://github.com/get-convex/agent/tree/main?tab=readme-ov-file#fetching-thread-history
GitHub
GitHub - get-convex/agent: Build AI agents on Convex with persisten...
Build AI agents on Convex with persistent chat history - get-convex/agent