Retrieving OpenAI assistant messages with latest Assistant updates?

Hi there,
I’m building an Ai assistant with OpenAI’s API. I want to be able to retrieve the messages when they finish running. I’m using Bubble’s API connector. Right now these are the calls I have set up. The messages are not being retrieved. What am I doing wrong?

The messages are retrieved using the list messages call, but this call should be made only after the “Run” status is “completed”, and the call that retrieves the "run: is missed in this image, so you need to add this call, then you need to put it in a loop to check the “run” status periodically (every 3 seconds maybe), and when it gets “completed” you make the “list messages” call, then extract only the last messages generated by the assistant.

This is very helpful. Any chance you can provide more detail on how to do those steps?
Specifically:

  1. set run to a loop every 3 seconds;
  2. make a list messages call when the run is complete;
  3. extract last message only

Is this the right order then?

you need to add “retrieve run” call before the “list messages”.

I used a backend workflow to retrieve the run and check its status, if it is not “completed” then schedule this backend workflow again after 2 or 3 seconds, if it is completed then proceed to “list message”,

When I make the “List messages” call I send the run ID as a parameter, so the retrieved messages are only the messages related to this run and added by the assistant, so there is no need for additional extraction.

This assumes that there is no “function calling”, if there is, then when “retrieve run” you need to check if the status is “requires_action” and then take another path.

I made this using the API connector so I don’t know if the plugin you use helps with this.

1 Like