crisp-im / node-crisp-api

:zap: Crisp API Node Wrapper
https://docs.crisp.chat/guides/rest-api/
MIT License
99 stars 38 forks source link

Add a function in order to get all messages since a timestamp #1

Closed pilerou closed 6 years ago

pilerou commented 7 years ago

Hi,

It could be great to have a function in order to get all messages since a date (or in a range) It could be a parameter in getList function.

My use case would be to have a scheduled program which gets all messages since the last launch. I would get a response containing an array of messages such as

[
{"website_id":"...c3","type":"text","from":"operator","origin":"chat","content":"The message","fingerprint":-333,"user":{"nickname":"My nickename","user_id":"....C4"},"timestamp":1487956507997,"stamped":true,"session_id":"session_e690....a0"}
]
baptistejamin commented 7 years ago

Hello Pierre!

Following your request, I updated the node lib to support this usecase:

Update to v1.2.2

And use:

CrispClient.websiteConversations.getMessages(WEBSITE_ID, SESSION_ID, {
    timestamp_before : 1488187641699
  })
  .then((messages) => {
    console.log("messages", messages);
  })
pilerou commented 7 years ago

Hi Baptiste,

And thanks for your reactivity ! Actually, my need would be timestamp_after in order to retrieve new messages. It seems it's not yet implemented.

Moreover, I would like to retrieve messages for all SESSION_ID of my website. Is it possible to make the session_id optional ?