diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-02-17 09:26:35 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-02-17 09:26:35 +0700 |
| commit | 37e33dfc0f0f79f67aa600c13e2e134037005f45 (patch) | |
| tree | e387e2b7e06fff04247d83d334418ebb090b186f | |
| parent | a400a6b71bdd0ec77c9a053088c0024a2aadfaff (diff) | |
add message sent in wati leads
| -rw-r--r-- | indoteknik_custom/models/wati.py | 12 |
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 |
