How to select questions using a criteria using API

  • 16 March 2021
  • 7 replies

Userlevel 3
Badge +1
  • inSpires others
  • 51 replies posted

We are trying to develop a workflow that will notifiy a specific group when topics have no replies after a certain time. In the community startup, it is important that we get to these questions fast to ensure customers keep coming back.

However, the API does not seem to allow us to selectively return questions based on a criteria - or at least, its not documented. Is there a generic syntax to the API that will allow us to select questions based on criteria input?

Here is the comment from our developer - it seems like there is no choice but to get ALL questions in the community to evaluate which ones to take action on. 

It seems like I have to always loop through all the questions in the given category – the result of questions is listed in last activity time descending. If new question is created or old question gets replied, the sequence will be changed, so it would be hard to get the pattern. This means the more questions get created, the longer this workflow may have to run.

7 replies

Userlevel 3
Badge +1

@tom.shaddock - any thoughts on this?

Userlevel 7
Badge +1

Hi @dandre, sorry to see that your question has remained unanswered for so long. Unfortunately me and Tom had quite a busy week, so we are trying to catch up with this as soon as possible. I’m not able to answer this, but I assure you I will check with Tom and other colleagues to help you further with this. Quite ironically, I could have used such a notification in this case as well. :(

Userlevel 3
Badge +1

I’m trying to code a very similar thing, so I’m interested in the answer! In my case, I’m trying to code a script which does the following:

  1. Query questions
  2. Narrow down to questions that have remained unanswered for over 24 hours
  3. Identify the author/user role of the OP
  4. Notify our team externally if the criteria is met

Would love to be able to narrow down by time frame if possible. 

Userlevel 2

@dandre  & @alexandra.culler - 

A couple years later and I’m working on the same problem. My company’s employees would like a link to all the unanswered questions in the community so they know where to focus their attention. I understand that many communities may not want to make this list visible for all end-users, but I should be able to grant that permission to a role associated with those that answer a majority of the questions: power users and employees. There are 90+ of these users so making them all CMs isn’t a realistic option. They wouldn't want to mess around in the community admin interface anyway. So I find myself calling the API daily so I can send a Slack message containing links to the unanswered questions. As @dandre noted - without filtering on the API calls we’re boiling a bigger and bigger ocean everyday. 

Do you have any advice to share on how you’ve solved this problem? Have you found a more efficient route? 


Userlevel 3
Badge +1

Hi @davetee - if it’s a question of finding all of the unanswered questions, could your team simply use the Unanswered question public filter? This filter is applied by adding the following after your community’s home URL: /search/activity/unanswered

If you need a bit more fidelity than that, the API could help you. I did end up making some code that searches the first page or two of recently-posted questions, then filters those questions based on the author. The role of the author determines if we will review them as a team. This script is set to run every morning via a batch process in Windows. The script outputs to a Team on Microsoft Teams via one of the URL endpoints.

If you need it, I could probably share the majority of the code with you. Feel free to PM me in that case :).

Userlevel 2

Hi  @alexandra.culler! I appreciate your ideas. 

The challenge with the unanswered questions filter is that almost all of our questions have replies - but are considered unanswered since they don’t yet have a “Best Answer.”  That may be because they’re still under discussion or there just isn’t yet a satisfactory answer. Your daily batch process sounds interesting - I’ll DM you for the details. Thanks! 

Userlevel 6
Badge +1

Hi @davetee 👋,

You’re right, sometimes questions don’t have a definitive best answer. In these situations the best practice is to convert these questions into the Conversation topic type. This will also give you a more accurate representation of how many (and how quickly) questions that do have a best answer are resolved when looking at the Q&A dashboard.