Skip to main content
Answered

API operator logic is flawed/broken


I am tying to query conversations (via python) and my payload is as follows

 

payload = {
  "query": {
    "operator": "AND",
    "value": [
        {
          "field": "state",
          "operator": "=",
          "value": "open"
        },
        {
          "field": "admin_assignee_id",
          "operator": "=",
          "value": "123456"
        },
        {
          "field": "waiting_since",
          "operator": "<",
          "value": 1693564392
        }
      ]
  }
}

 

The above logic should be, show me conversations where state = open AND admin_assignee_id = 123456 AND waiting since is less than 1693564392. 

The response however includes conversations that have a “state” = “closed”

 

What am I doing wrong ? Your docs state AND operators can have upto 15 filters.  

Best answer by Gary Cahill

Hi @Jacob Cox 

I figured it out, it was actually the “waiting_since” field that was breaking my logic. I didnt share my full query as I was trying to simplify it for the question. 

When “waiting_since” was null, it was breaking. The reason being I had “” to check for null but I actually needed to use a null object. Where as checking string variables for nulls uses empty quotes and not a null object. I think this should be made more clear in the docs. 


Valid: 

{
          "field": "admin_assignee_id",
          "operator": "=",
          "value": ""
},

{
         "field": "waiting_since",
         "operator": "=",
         "value": null
 }

 

Invalid: 

{
          "field": "admin_assignee_id",
          "operator": "=",
          "value": ""
},

{
         "field": "waiting_since",
         "operator": "=",
         "value": “”
 }

 

(*I am using Python and declared null = None)

View original
Did this topic help you find an answer to your question?

2 replies

Jacob Cox
Intercom Team
Forum|alt.badge.img+5
  • Sr. Technical Support Engineer
  • 441 replies
  • September 3, 2023

Hey there @Gary Cahill !

 

That call should only be returning open conversations. Are you sure that the conversation was actually open when you made the call and that it didn’t get closed at some point afterward? We do also have a Boolean attribute on that Conversation Object called ‘open’. If you continue to have issues around that ‘state’ attribute you could try the ‘open’ attribute.

 

If you double check that call and are still seeing it return closed conversations, you should write into our Support team in your Intercom Messenger. They can take a closer look at the specific conversations and see if there’s a rhyme or reason to the behavior that you’re seeing!


  • Author
  • New Participant
  • 1 reply
  • Answer
  • September 4, 2023

Hi @Jacob Cox 

I figured it out, it was actually the “waiting_since” field that was breaking my logic. I didnt share my full query as I was trying to simplify it for the question. 

When “waiting_since” was null, it was breaking. The reason being I had “” to check for null but I actually needed to use a null object. Where as checking string variables for nulls uses empty quotes and not a null object. I think this should be made more clear in the docs. 


Valid: 

{
          "field": "admin_assignee_id",
          "operator": "=",
          "value": ""
},

{
         "field": "waiting_since",
         "operator": "=",
         "value": null
 }

 

Invalid: 

{
          "field": "admin_assignee_id",
          "operator": "=",
          "value": ""
},

{
         "field": "waiting_since",
         "operator": "=",
         "value": “”
 }

 

(*I am using Python and declared null = None)


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings