Skip to content

Save chat by ID

The save function allows you to save messages to a chat. You can optionally provide metadata for the chat.

ts
const messages = [
    {
      role: 'user',
      content: 'Hello!'
    }, {
        role: 'assistant',
        content: 'Hello, welcome to Invsy!'
    }
];
// Update meta title, use the first message as the chat title
const title = chat.messages[0].content.substring(0, 100);

const updatedChat = await invsy.save({
    meta: {
        title
    },
    messages
});