Architect Flow - Auto-Answer Suggestion Failure

Hey all,

We’ve got a weird one cropping up in production - auto-answer suggestions are failing to surface in a handful of our DX flows, and it’s intermittent. It’s impacting a fairly large queue so it’s getting attention. The error’s a 400 Bad Request when the flow tries to hit the /api/v2/knowledge/knowledgebases/{knowledgeBaseId}/documents/search/suggestions endpoint.

It’s happening specifically after a chatbot handoff. The flow looks like this - customer starts in the bot, then we route to a live agent via a transfer action, then we’re trying to surface relevant KB articles after the agent accepts the chat. We’re using the “Suggest Knowledge Articles” node, configured to pull from a specific knowledge base - ID is 7a3b2c9d-e1f2-3456-7890-abcdef012345.

I’ve dug into the flow history and the logs and it appears the request being sent to the API is pretty standard. The query parameter is being populated with the chat transcript, and the maxResults is set to 5. I saw a similar issue mentioned a month or so back in a community thread about article relevance, but that one seemed to be related to the relevance tuning settings in the knowledge base. We checked those and they look correct.

Here’s a snippet of the error message from the flow execution details:

{
 "message": "Bad Request",
 "code": 400,
 "details": [
 {
 "field": "query",
 "message": "Query cannot be empty"
 }
 ]
}

The thing that’s throwing me is the transcript isn’t empty. I’ve validated that the transfer action is capturing the full transcript, and the query parameter is getting populated. It’s like the API is temporarily rejecting it even though it shouldn’t be. I also checked the KB indexing status - it completed successfully a couple of hours ago. The SDK version the flow is running on is 2.1.1. I’ve tried bumping the query length limit to 2000 to see if that helps, no luck.

Anyone else seen this? It’s a head-scratcher.

i think is problem with request body format for /api/v2/knowledge/knowledgebases/{knowledgeBaseId}/documents/search/suggestions. if text is empty or null in data action, it return 400 error. sometimes flow pass empty variable when customer not speak or input is missing.

check if body is like this:

{
 "query": "search term here",
 "pageSize": 10
}

if query is missing or empty string, it fail. one edge case is when special characters in search term not encoded, then api return bad request. try add a decision block in architect to check if variable is not empty before call data action.

1 Like

That’s right. The suggestions endpoint hates nulls. If the input variable is empty, the data action sends a malformed body and the API just throws a 400.

Add a decision block before the call to check if the string is empty. We’ve got 1200 agents and skipping these empty hits saved us a ton of noise in the logs.

3 Likes

that worked! added a decision block to catch the empty strings before the call and the 400s stopped. :slight_smile:

The fact that the API just chokes on a null instead of returning an empty list is… a choice. At my last shop, we had to deal with similar “creative” error handling where the backend just gave up if a string wasn’t exactly what it wanted. Adding a decision block is the standard band-aid, but if you’re doing this across dozens of flows, it’s a nightmare to maintain.

A slightly cleaner way is to use a default value in the Data Action configuration so the request body never actually hits the API as null. Just set the input variable to a blank space or a dummy string in the JSON template.

{
 "text": "${input.searchQuery:- }"
}

edit: actually, if you’re using the /api/v2/knowledge/knowledgebases/{knowledgeBaseId}/documents/search/suggestions endpoint, just make sure that default doesn’t trigger a bunch of irrelevant results.