Hello everyone
I’m having difficulty using the OpenAI Assistants API in my ManyChat setup for handling multi-turn conversations. The chatbot responds correctly to the first question but fails when trying to process the second and subsequent questions.
Here’s a summary of the current flow:
- First Webhook: A POST request to
https://api.openai.com/v1/threads/runs
- Headers:
OpenAI-Beta
: assistants=v2Content-Type
: application/jsonAuthorization
: Bearer {{Bot Field OpenAI API}}
- Request Body:
{
"assistant_id": "{{Bot Field Asistente}}",
"thread": {
"messages": [
{"role": "user", "content": "Pregunta ChatGPT"}
]
}
}
- Response Mapping: Maps the
thread_id
to the user fieldGPT thread
to save the thread ID.
- Second Webhook: A GET request to
https://api.openai.com/v1/threads/'GPT thread'/messages
- Headers:
OpenAI-Beta
: assistants=v2Content-Type
: application/jsonAuthorization
: Bearer {{Bot Field OpenAI API}}
- Response Mapping: Maps the returned message content to the user field
Respuesta ChatGPT
.
- Third Webhook: A POST request to
https://api.openai.com/v1/threads/'GPT thread'/messages
- Headers:
OpenAI-Beta
: assistants=v2Content-Type
: application/jsonAuthorization
: Bearer {{Bot Field OpenAI API}}
- Request Body:
{
"role": "user",
"content": "{{Pregunta ChatGPT}}"
}
- Fourth Webhook: A POST request to
https://api.openai.com/v1/threads/'GPT thread'/runs
- Headers:
OpenAI-Beta
: assistants=v2Content-Type
: application/jsonAuthorization
: Bearer {{Bot Field OpenAI API}}
The flow works well for the first message, but as soon as the second question is asked, the bot fails to return a response. The error logs show issues such as “Unauthorized” or “Invalid Request,” especially when the second POST request to the threads/runs
endpoint is made.
This chatbot is crucial for me, and I’m struggling to make it work. I’m not a programmer or developer. I’m 46 years old, and I was let go from my job, where I worked for 20 years, a year and a half ago. I found “help” in ManyChat forums offering to sell me a solution for USD 350, but I can’t afford that. I really need to make this chatbot work and would deeply appreciate any guidance to resolve this issue.