Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set a message history? #56

Open
ClemB-Dev opened this issue Oct 14, 2024 · 2 comments
Open

How to set a message history? #56

ClemB-Dev opened this issue Oct 14, 2024 · 2 comments

Comments

@ClemB-Dev
Copy link

I was wondering how I could populate the RealTime Client with a conversation history.

The idea is that users can continue a conversation from where it left off after being disconnected. I am already able to retrieve the history, as I have saved it in a database. Now, I would like to configure the client with the updated history.

Is this possible? If so, how does it work?

@josancamon19
Copy link

In theory you should be able to call response.create.item with each one of the previous messages, but I couldn't make it work, I'm creating an issue about it in a sec.

So what I did was:

let instructionsCopy = instructions;
    if (messageList.length > 0) {
      instructionsCopy = instructionsCopy + `\n\nThe following is a history of our previous conversation:\n${messageList.map(message => `${message.sender}: ${message.message}`).join('\n')}`;
    }

@ClemB-Dev
Copy link
Author

Thank you for answering.
That's also what I did on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants