vishva
vishva2mo ago

chat bot with nextjs

i have created workflow chat wi supabse and in text mode working fine but if I implement this in nextjs app and start chat that show error I was attaching image here. this is error wile chat with bot
{ "error": { "status": 400, "headers": { "alt-svc": "h3=\":443\"; ma=86400", "cf-cache-status": "DYNAMIC", "cf-ray": "8ac736299cfb6326-ORD", "connection": "keep-alive", "content-length": "203", "content-type": "application/json", "date": "Thu, 01 Aug 2024 16:30:14 GMT", "openai-organization": "user-tecqq7ghzy7wyosafoigsw2v", "openai-processing-ms": "23", "openai-version": "2020-10-01", "server": "cloudflare", "set-cookie": "__cf_bm=TjvnW71eNe7KTRlK8dIfFTtW7nj3Y1jD2tRgO9e.dEY-1722529814-1.0.1.1-TyrZHDcuBxeZjUfOIt01wIlczQ2nY8WgYwRJIRja8rAz5sWsagqiG8KLx_9C3rBWvvy4Gi1NdZyFjOcPCc9IUQ; path=/; expires=Thu, 01-Aug-24 17:00:14 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=7Ip47q2TY8pp2awgE99XA8qmHKTUi_n2ogEKbdpfnr8-1722529814098-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None", "strict-transport-security": "max-age=15552000; includeSubDomains; preload", "x-content-type-options": "nosniff", "x-request-id": "req_d07b3718076ef9cdcf4466aceca53162" }, "error": { "message": "Missing required parameter: 'messages[0].content'.", "type": "invalid_request_error", "param": "messages[0].content", "code": "missing_required_parameter" }, "code": "missing_required_parameter", "param": "messages[0].content", "type": "invalid_request_error" }, "label": "OpenAI Assistant", "message": "400 Missing required parameter: 'messages[0].content'."
{ "error": { "status": 400, "headers": { "alt-svc": "h3=\":443\"; ma=86400", "cf-cache-status": "DYNAMIC", "cf-ray": "8ac736299cfb6326-ORD", "connection": "keep-alive", "content-length": "203", "content-type": "application/json", "date": "Thu, 01 Aug 2024 16:30:14 GMT", "openai-organization": "user-tecqq7ghzy7wyosafoigsw2v", "openai-processing-ms": "23", "openai-version": "2020-10-01", "server": "cloudflare", "set-cookie": "__cf_bm=TjvnW71eNe7KTRlK8dIfFTtW7nj3Y1jD2tRgO9e.dEY-1722529814-1.0.1.1-TyrZHDcuBxeZjUfOIt01wIlczQ2nY8WgYwRJIRja8rAz5sWsagqiG8KLx_9C3rBWvvy4Gi1NdZyFjOcPCc9IUQ; path=/; expires=Thu, 01-Aug-24 17:00:14 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=7Ip47q2TY8pp2awgE99XA8qmHKTUi_n2ogEKbdpfnr8-1722529814098-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None", "strict-transport-security": "max-age=15552000; includeSubDomains; preload", "x-content-type-options": "nosniff", "x-request-id": "req_d07b3718076ef9cdcf4466aceca53162" }, "error": { "message": "Missing required parameter: 'messages[0].content'.", "type": "invalid_request_error", "param": "messages[0].content", "code": "missing_required_parameter" }, "code": "missing_required_parameter", "param": "messages[0].content", "type": "invalid_request_error" }, "label": "OpenAI Assistant", "message": "400 Missing required parameter: 'messages[0].content'."
No description
Solution:
In your workflow you are taking the prompt form the query not from the body. change the prompt to (x)Body.message, it should work then, note here that the body is the variable from the Rest API Request.
Jump to solution
3 Replies
AI Support
AI Support2mo ago
It looks like you're encountering an error related to missing required parameters in your API's POST request body. Based on the error message, it seems that the messages[0].content parameter is not being passed correctly from your client side on the chat widget. To resolve this issue, ensure that your API's POST request body contains all the necessary parameters, including prompt and threadId. You can refer to the relevant section of the documentation for more details: BuildShip Chat Widget - Requirements for Your BuildShip Workflow If you need further assistance, you can submit your query via the in-app support button.
GitHub
GitHub - rowyio/buildship-chat-widget: AI Chat Widget - flexible an...
AI Chat Widget - flexible and lite chat widget that can connect to OpenAI Assistant, any database, tools - rowyio/buildship-chat-widget
vishva
vishva2mo ago
{
"message": "comapny that hashtag is new",
"threadId": null,
"timestamp": 1722611423272
}
{
"message": "comapny that hashtag is new",
"threadId": null,
"timestamp": 1722611423272
}
i was passing this as payload but still same error @Gaurav Chadha
Solution
Gaurav Chadha
Gaurav Chadha2mo ago
In your workflow you are taking the prompt form the query not from the body. change the prompt to (x)Body.message, it should work then, note here that the body is the variable from the Rest API Request.