From 37e33dfc0f0f79f67aa600c13e2e134037005f45 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 17 Feb 2023 09:26:35 +0700 Subject: add message sent in wati leads --- indoteknik_custom/models/wati.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index fbe350a5..170b4245 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -18,17 +18,23 @@ class WatiNotification(models.Model): watis = self.env['wati.notification'].search(query, order='id') for wati in watis: - _logger.info('Convert Lead ID %s' % wati.id) + _logger.info('Convert to Lead WATI Notification ID %s' % wati.id) ticket_id = json.loads(wati.json_raw)['ticketId'] text = json.loads(wati.json_raw)['text'] current_lead = self.env['crm.lead'].search([('ticket_id', '=', ticket_id)], limit=1) operator_email = json.loads(wati.json_raw)['operatorEmail'] operator_name = json.loads(wati.json_raw)['operatorName'] + event_type = json.loads(wati.json_raw)['eventType'] - if current_lead: + if event_type == 'sessionMessageSent': + current_lead.description = str(current_lead.description)+ "| i:" + str(text) + current_lead.operator_email = operator_email + current_lead.operator_name = operator_name + wati.is_lead = True + elif current_lead: # must append internal notes as a reply here - current_lead.description = str(current_lead.description) + "|" +str(text) + current_lead.description = str(current_lead.description) + " | c:" +str(text) current_lead.operator_email = operator_email current_lead.operator_name = operator_name wati.is_lead = True -- cgit v1.2.3