Skip to main content
Solved

Probable bug in the Manychat with API GPT Assistant from external request

  • 27 February 2024
  • 5 replies
  • 408 views

Filipe

I'm sending a request to OpenAi in the Assistants API. And it returns the list of messages correctly.

{
  "object": "list",
  "data": [
    {
      "id": "msg_iKGCwdwjUO5bb8c1SMpnIk33",
      "object": "thread.message",
      "created_at": 1709048220,
      "assistant_id": "asst_4O3IU4O3IUweCWH1fE2aX",
      "thread_id": "thread_d8xFPr33232hNovmHTI9hyno",
      "run_id": "run_l42qcQLk3h2k3jhmvIyX7cEOY",
      "role": "assistant",
      "content": [
        {
          "type": "text",
          "text": {
            "value": "Hello! I can help you? 😊",
            "annotations": []
          }
        }
      ],
      "file_ids": [],
      "metadata": {}
    },
    {
      "id": "msg_0VVvobTk4hj32jk4h23iFbm6Vnk",
      "object": "thread.message",
      "created_at": 170432432228,
      "assistant_id": null,
      "thread_id": "thread_d8xFPrFi4kjh324kj3h2TI9hyno",
      "run_id": null,
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": {
            "value": "Hi",
            "annotations": []
          }
        }
      ],
      "file_ids": [],
      "metadata": {}
    }
  ],
  "first_id": "msg_iKGCwkj3h4kj3hc1SMpnIk3n",
  "last_id": "msg_0VVvobTgEk4j3h4jk3hFbm6Vnk",
  "has_more": false
}

 

So the correct way to capture the last message, which is the one at the top, would be number 0 in the array (json)

So I try to save like this:

 

However, when you save the message, it saves the message from array 1, that is, the "Hi"

 

 

chatgpt_entrada is the contact's message, which I save at the beginning when sending the first message in the thread.

 

and the chatgpt_response field I only change when I receive a response from the assistant's message list

I've done several tests, and it really doesn't work.

I wanted to know if this really is a Manychat bug or if I'm missing something... Can anyone help me?

Best answer by Gustavo Boregio

Your mapping is correct, and it should work.

 

You have some other error in your setup.

Check Settings > Logs in Manychat, and see if you have any other errors that may give you a clue as to what is wrong.

Also, are you waiting until the status of the run is ‘complete’ before asking for the message? If you do it before it’s complete it’ll give you only the first message (which is the user message that you’re getting). If this is the case, then the mapping is correct because the 2nd message (the response) does not exist yet.

I have Assistants API working with Manychat, and a working template to do the integration, so happy to help if you need assistance.

PS: Também falo português ;)

View original
Did you find this topic helpful?

Gustavo Boregio
Forum|alt.badge.img+6
  • Manychat Community Moderator
  • February 27, 2024

Your mapping is correct, and it should work.

 

You have some other error in your setup.

Check Settings > Logs in Manychat, and see if you have any other errors that may give you a clue as to what is wrong.

Also, are you waiting until the status of the run is ‘complete’ before asking for the message? If you do it before it’s complete it’ll give you only the first message (which is the user message that you’re getting). If this is the case, then the mapping is correct because the 2nd message (the response) does not exist yet.

I have Assistants API working with Manychat, and a working template to do the integration, so happy to help if you need assistance.

PS: Também falo português ;)


Filipe
  • Up-and-Comer
  • February 27, 2024

Obrigado! Era isso, eu fiz a requisição para criar a thread e depois aguardei 10 segundos antes de solicitar a lista de mensagens.

Thanks! That was it, I made the request to create the thread and then waited 10 seconds before requesting the list of messages.

 

Que legal ! Bom saber que não estou sozinho!

Abraço!


gicsaud
  • Up-and-Comer
  • March 18, 2024

Boa tarde @Filipe, desculpe o incômodo em sua postagem, poderia me informar se, quando o usuário envia duas mensagens seguidas, seu bot também faz duas requisições à OpenAI? O meu responde sempre 2x e na maioria dos casos a resposta é a mesma, ele não altera o contexto nem nada… Você já conseguiu tratar isso? Poderia me ajudar de alguma forma?


Filipe
  • Up-and-Comer
  • March 20, 2024

 

gicsaud wrote:

Boa tarde @Filipe, desculpe o incômodo em sua postagem, poderia me informar se, quando o usuário envia duas mensagens seguidas, seu bot também faz duas requisições à OpenAI? O meu responde sempre 2x e na maioria dos casos a resposta é a mesma, ele não altera o contexto nem nada… Você já conseguiu tratar isso? Poderia me ajudar de alguma forma?

 

Você deve colocar uma condição antes, dizendo se a mensagem for igual a ultima, ele não faz nada.


daniel alisov

$.data[?(@.role=='assistant')].content[0].text.value

some filters in the mapping 

 


enjoy~!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings