evolution-api icon indicating copy to clipboard operation
evolution-api copied to clipboard

Improvements to integrate it over a custom internal Chat service

Open jesus-chacon opened this issue 5 months ago • 0 comments

Welcome!

  • [X] Yes, I have searched for similar requests on GitHub and found none.

What type of feature?

Endpoint

What is the motivation for the request?

I would like to propose some changes to the /chat/findChats/:instanceName and /chat/findMessages/:instanceName endpoints to improve their functionality.

  1. Unread Messages Count in /chat/findChats/:instanceName:
    It would be extremely useful to include a count of unread messages for each chat. This would allow us to easily identify which chats have pending messages.

  2. Last Message Preview in /chat/findChats/:instanceName:
    Adding a "lastMessage" field to display a preview of the most recent message would provide a more user-friendly experience and help to quickly identify the context of the conversation.

  3. Read Status in /chat/findMessages/:instanceName:
    In the /chat/findMessages/:instanceName endpoint, it would be beneficial to include a boolean flag for each message indicating whether it has been read. This would allow us to visually differentiate between read and unread portions of the conversation.

These enhancements would improve the usability of both endpoints and enhance the overall functionality for users handling multiple chats or messages.

Usage Examples

No response

How should the feature be developed?

How Should the Feature Be Developed?

  1. Unread Messages Count in /chat/findChats/:instanceName:

    • Introduce a new field in the response object that contains the number of unread messages per chat.
    • The backend can query the message table (or the relevant data source) to count messages with a read: false status associated with each chat.
    • This field can then be returned alongside other chat data in the /findChats endpoint.
  2. Last Message Preview in /chat/findChats/:instanceName:

    • Add a lastMessage field in the response, which retrieves the most recent message from each chat.
    • The backend should fetch the most recent message based on the timestamp and include a preview (e.g., first 100 characters) in the response.
  3. Read Status in /chat/findMessages/:instanceName:

    • Add a boolean field isRead to each message in the response of /findMessages.
    • The backend should check the read status of each message (e.g., a field like read: true/false) and return the appropriate value in the response.
    • This flag will help to distinguish between read and unread messages in the conversation history.

These changes should be backward-compatible to avoid breaking existing clients using the API.

Additional Notes

The proposed changes are relatively small in scope, and it would be ideal to have them included in version 2 (v2) of the API. By implementing these updates, it will significantly enhance support for building a custom message management app, providing better control over chat interactions and improving overall user experience.

jesus-chacon avatar Sep 27 '24 10:09 jesus-chacon