Use the following built-in functions to get information on the results of an integration.

New to scripting functions? Please review the Introduction.

Get API integration results count

Most commonly used to check whether an API integration returned any results at all, and how many. If no results are returned, you should display an error message or redirect to a failover message.

For example, imagine you are using the KnowledgeBase feature to create an FAQ bot. If the user’s query doesn’t return any results, you may want to respond with another message that provides some guidance.

Example

In the below example, faqIntegration is the name of the API integration, title is the custom data field mapping name, and count is the parameter that gives you the actual count.

var results = botContext.getBotVariable(faqIntegration.title.count);
if (results < 1) {
      botContext.sendMessage('Sorry, I was not able to find any notes for this contact.');
}