dolibarr icon indicating copy to clipboard operation
dolibarr copied to clipboard

Ticket Responder Reply

Open VaderD opened this issue 4 years ago • 10 comments

Bug

When a ticket responder replies and his reply is inserted by the email collector then in the ticket general there is no info to know that there is reply for this ticket... Instead you have to go to the the ticket to read the message but if you do not know that there is new message you will never go ...

Environment

  • Version: [14.0.4]
  • OS: [CentOS 7]
  • Web server: [Apache 2.4.6]
  • PHP: [7.4.26]
  • Database: [MySQL 5.5.68]

Expected and actual behavior

VaderD avatar Nov 26 '21 15:11 VaderD

I feel the same feature missing but not sure how to do it Maybe change de status to "not read" like of the ticket was just created ?

freechelmi avatar Jan 06 '22 16:01 freechelmi

I do not know how do it ....Can you explain it to me ?

VaderD avatar Jan 06 '22 17:01 VaderD

Any news regarding this issue ..?

VaderD avatar Jan 12 '22 14:01 VaderD

Hi , please don't comment every few days , you can either :

  • Propose a PR to help this issue
  • sort your ticket list by modification date to show the last answers
  • monitor your email to see that there was an answer

I would classified this as low priority

freechelmi avatar Jan 12 '22 15:01 freechelmi

Bug still exists !

VaderD avatar Jan 12 '23 21:01 VaderD

Hello,

Is it still the case on V18 ?

ksar-ksar avatar Oct 18 '23 18:10 ksar-ksar

Yes it is ...Nothing is improved or chnage to v 18 ...about this issue

VaderD avatar Oct 19 '23 11:10 VaderD

  • sort your ticket list by modification date to show the last answers

Unfortunately, it is not usable because this date is not modified when the ticket is answered (maybe a bug ?)

nicolasVr avatar Jun 09 '24 20:06 nicolasVr

I created a simple python script handling "Collect_Responses_In" messages: If such a new message is detected it sets the ticket status to "unread" again. (Only works if status is set to "waiting for feedback" before). Make sure to have API Module enabled and you configured your API-Key and dolibarr correctly in this script. Great to be ran as cronjob every five minutes:

import json
import os

FULLURL = ('https://dolibarr.example.com/api/index.php/').replace('//api', '/api')
HEADERS = {'DOLAPIKEY': "myapikey"}

import requests
import time

def get_request(url, json=None):
    print(f"(GET request to {url})")
    retrycounter = 0
    while retrycounter < 3:
        try:
            response = requests.get(url, headers=HEADERS, json=json)
            return response
        except requests.exceptions.RequestException as e:
            retrycounter += 1
            print(f"Request failed, retrying {retrycounter} time(s)")
            time.sleep(1)

def put_request(url, json=None):
    print(f"(PUT request to {url})")
    retrycounter = 0
    while retrycounter < 3:
        try:
            response = requests.put(url, headers=HEADERS, json=json, timeout=15)
            return response
        except requests.exceptions.RequestException as e:
            retrycounter += 1
            print(f"Request failed, retrying {retrycounter} time(s)")
            time.sleep(1)

# Load json file
all_read_message_ids = []
if os.path.exists('all_message_ids.json'):
    with open('all_message_ids.json') as f:
        all_read_message_ids = json.load(f)

# Get all latest 500 tickets
response = get_request(FULLURL + 'tickets?limit=500&sortfield=t.rowid&sortorder=DESC')
tickets = response.json()

# Only get all the tickets with status 5 (waiting for feedback)
tickets = [ticket for ticket in tickets if ticket['status'] == "5"]

for ticket in tickets:
    # Get all messages for this ticket
    response = get_request(FULLURL + 'tickets/' + str(ticket['id']))
    ticket_with_messages = response.json()
    messages = ticket_with_messages['messages']
    for message in messages:
        # Check if message is a response from the user (from Collect_Responses_In Email Collector procedure)
        if "Collect_Responses_In" in message["message"] and message["id"] not in all_read_message_ids:
            # Update ticket status to 0 (unread)
            response = put_request(FULLURL + 'tickets/' + str(ticket['id']), json={"fk_statut": "0"})
            all_read_message_ids.append(message["id"])
            # Save all read message ids to json file (in case of script failure in the future)
            with open('all_message_ids.json', 'w') as f:
                json.dump(all_read_message_ids, f)

Jean28518 avatar Mar 14 '25 00:03 Jean28518

Thanks for sharing. Could be done also with a n8n or zapier workflow.

nicolasVr avatar Mar 14 '25 05:03 nicolasVr