You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since it took me ages to figure it out, I thought I would give something back by sharing the code that I used to finally get it to work. I can successfully retrieve the data of 13,000+ users with this:
INTERCOM_API_TOKEN = "XXXXXXXX"
from intercom.client import Client
intercom_session = Client(personal_access_token=INTERCOM_API_TOKEN)
try:
myscroll = intercom_session.users.scroll()
i = 1
for user in myscroll:
print(str(i) + ' ' + user.name + ' ' + user.email)
i += 1
except:
print("An exception occurred, could not get scroll")
(update: the next(myscroll) statement was not needed)
A few things I noted when I converted my users = intercom_session.users.find(order="desc", sort="last_request_at") code to the scroll() code:
before I would do myuser = users.users[i] and then myuser['user_id'] etc. that has changed to myser.user_id format.
myuser['created_at'] would then be returned as an integer, while now myuser.created_at is returned as a datetime object. With myuser.created_at.timestamp() I can get the Unix timestamp again.
if myuser.last_request_at is None then myuser.last_request_at.timestamp() returns an error.
myuser.created_at.strftime('%Y-%m-%d %H:%M:%S') returns nice readable format time.
It seems to be already part of the package, but is missing from the docs.
The text was updated successfully, but these errors were encountered: