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?