summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_custom/models/wati.py12
1 files 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