Testing for active conversations

#1

Hi,

I’m working on a module in our association management software that needs to determine whether a user is engaged in an active conversation. It uses the endpoint: https://api.intercom.io/conversations/?type=user&intercom_user_id=[intercom_user_id], then parses the result to see if the following are true:

  • The value of ‘delivered_as’ in a message is either ‘customer_initiated’ or ‘admin_initiated’.

  • If the above is true, the value of ‘customer_first_reply’ in the conversation is not null.

First—are these valid criteria for seeing if the conversation is active?
Second—In my conversation on our sandbox app, only the first message of the conversation shows up in the API call, and it can take up to 10 minutes for the value of ‘customer_first_reply’ to change from null to a sub-array. Is this expected behavior?

Regards,

Mark Pemburn
Blue Ocean Ideas

0 Likes

#2

Hi Mark, welcome to the forum! :tada:

Happy to address these questions:

First—are these valid criteria for seeing if the conversation is active?
I’m not seeing where “delivered_as” is returned when pulling a user’s conversations. We return:

"open": true,
"state": "open",
"read": true

which could be useful for this use case. Having more information on where you are seeing “delivered_as” would be helpful in determining this, however.

Second—In my conversation on our sandbox app, only the first message of the conversation shows up in the API call, and it can take up to 10 minutes for the value of ‘customer_first_reply’ to change from null to a sub-array. Is this expected behavior?

It is expected that only the first message within a conversation is returned when calling all conversations for a single user. To get an entire conversation (with all the messages) each single conversation would need to be called through the API.

I would expect updates to the conversation parts to occur a bit quicker than 10 min, but more details would be needed on your use case to get a better gauge on that number.

Feel free to reach back out with more details on your use case here, we can definitely guide you in the right direction with a little more information!

0 Likes

#3

Hi Andrew,

Thanks for your speedy reply! I think that checking the state of the conversation is a good indicator, except that in some cases, they don’t get closed so we have to check a few other things.

The ‘delivered_as’ key is part of the response, and we need to make sure that the conversation is actually one that was initiated by either the user or an admin. The other values (from the API docs) are ‘automate’, ‘campaigns_initiated’, and ‘operator_initiated’. I think the best method to be sure we have it right is to check that field, the state fields, and the ‘updated_at’ timestamp.

For reference, I’ve included a sample response below.

Regards,

Mark

{
    "type": "conversation.list",
    "pages": {
        "type": "pages",
        "next": null,
        "page": 1,
        "per_page": 20,
        "total_pages": 1
    },
    "conversations": [
        {
            "type": "conversation",
            "id": "21381018109",
            "created_at": 1553716724,
            "updated_at": 1553783435,
            "waiting_since": 64667687435,
            "snoozed_until": null,
            "conversation_message": {
                "type": "conversation",
                "delivered_as": "admin_initiated",
                "id": "333580028",
                "subject": "",
                "body": "<p>Hi Mark,<br>test conversation initiated by Harry on 2019-03-27</p>",
                "author": {
                    "type": "admin",
                    "id": "1974814"
                },
                "attachments": [],
                "url": null
            },
            "user": {
                "type": "user",
                "id": "5c9bd51d4fb5ec5af8e67af7"
            },
            "customers": [
                {
                    "type": "user",
                    "id": "5c9bd51d4fb5ec5af8e67af7"
                }
            ],
            "customer_first_reply": {
                "created_at": 1553718393,
                "type": "conversation",
                "url": null
            },
            "assignee": {
                "type": "admin",
                "id": "1974814"
            },
            "open": false,
            "state": "closed",
            "read": true,
            "tags": {
                "type": "tag.list",
                "tags": []
            }
        }
    ]
}
0 Likes

#4

Hi Mark! :wave:

I think you are on the right track here! If you:

  • check customer_initiated or admin_initiated are true

  • Check State is open

  • Check updated_at for recent update

This would be a good way to see if the user is engaged. It is odd that customer_first_reply is taking 10 minutes to update that value. We would be happy to take a closer look if you wish to write in to us through the Intercom.io or email team@intercom.com. We can ask one of our Support Engineers to dig into that. :mag:

0 Likes

#5

Hi Kayvan,

Thanks for the offer. I only witnessed this on one try, so it may have been a fluke. We have what we need for our purposes with the above, so no need to pursue the issue from my perspective.

Regards,

Mark

0 Likes