Fallback for Empty Results

When leveraging an API with Dev Platform, it may return an empty set of results. While this will not cause Dev Platform to throw an error, it's ideal to design an alternative path for the chat user instead of showing them an empty result. 

Below is an example of an App Action – "SEARCH Driveitems in sharepoint site". It takes in a query and a site name as inputs and outputs a list of results in the variable "hits".

Following that App Action card that searches Sharepoint, we've added another App Action card to "Count items in a list". It takes in a list as in input and outputs a count of the number of items in that list.

Adding the action that counts the list items allows us to incorporate simple logic via a logic node. Using the "count" variable, which counted how many items were in the "hits" list, we can quickly assess whether the list was empty or not. Here is a useful expression for that check: {{count}} > 0. In the logic card shown above, if the expression is true, then the Guided Conversation will follow path 1. So, if "count" is greater than 0, path 1 is taken. If not, that is the list is empty, then the conversation will follow the fallback path.

In the fallback path, you can add an informative error message to help the user understand what happened.

Was this article helpful?