OpenAI beta assistants

Hi, How would I connect the responses from my own api, back into the chatbot list items or table, so it will show on the chatbot screen as a response from the AI api.?

I can get the entered in the chat/text box text to send to the API. Meaning the text I enter into textbox.

I am now using the chat1.data.pop().value to get the last entered value in that array? is this the preferred way ??

Note: I am using a js script that i call after entering the search text. the script calls the assistant api, adds a threadid, adds the messages to the thread, and then calls the run.

I have tried
chat1.table.addNotification({message: messageList});
chat1.sendMessage(messageList);
chat1.data.push(messageList)
chat1.data.values.push(messageList)

My jsfunction returns the correct response from my assistant, but i cannot get the response connected to the chat messages to show ?

Hello @Marius_Visser ,

Thank you for your question.

I have some ideas that might be useful for you:

There are various possible solutions for the issue of messages not showing up on your chat interface.

First, ensure that the responses from your API match the format expected by the chat interface. Then, update the state of your app after receiving the response from your API. Some applications use 'setState' or 'updateState' functions for this. Lastly, re-render the interface to display the new messages.

In your script, add a response from your API to the chat data array like this:

let responseFromAssistant = // your API response...
let newMessage = { role: 'bot', value: responseFromAssistant } //replace 'bot' with the relevant role (if any)
chat1.data = chat1.data.concat([newMessage])

Replace 'chat1' with the name of your chat component and make sure it follows the structure {role: '...', value: '...'}.

You can also try debugging your JavaScript by checking the console for any error messages or enabling detailed loggings. Use the console.log() function or "temporary state" in Retool to inspect the processed response data and ascertain that your script is executing correctly and receiving the response from your assistant.

In the Retool environment, consider using the setOnRowSelect() or setValue() methods. For instance, you populate your chat interface with the API response data like this:

chat1.setValue(response.data);

Avoid manipulating Retool component data directly, like using push directly on the chat1.data array, as it's not recommended and can lead to issues.

Hopefully something here helps you make progress with your project.

  • Brett