Skip to main content

Forward CRM lead and ticket data to external CRM platforms via outbound webhooks when converting a helpdesk ticket.

Project description

License: AGPL-3

Extends the Helpdesk Ticket to Lead conversion workflow with an optional outbound webhook step. When an agent converts a helpdesk ticket into a CRM lead they can select an external destination so that the lead data and the full ticket conversation history are also forwarded to an external CRM platform (e.g. Zoho CRM) through an intermediate automation layer such as n8n.

No external API client code lives inside this module. All HTTP dispatching, logging and error handling are handled by the Webhook Hub module.

Features

  • crm.lead.destination — lightweight configuration model that pairs a friendly name with an outbound webhook.webhook record. Managed under CRM → Configuration → CRM Lead Destinations.

  • destination_id field on crm.lead — selectable in the conversion wizard so the agent picks the target at conversion time (one lead at a time). Leaving it empty keeps the lead in Odoo CRM only.

  • sent_to_destination status flag on crm.lead marks whether outbound synchronization has succeeded. Leads with destination and pending status are retried by a scheduled job every 2 hours.

  • Payload sent to the intermediate layer includes:

    • Lead fields: name, email, partner name, mobile, phone.

    • Ticket fields: id, reference number, origin email of the customer, and the full conversation history as an HTML string.

      • Origin email resolution order: ticket partner email → first received inbound email (message_type_mail = email_received). Left empty if no customer email is found (never falls back to a support agent’s address).

      • Conversation history is built by get_message_body_with_history() when helpdesk_ticket_mail_message is installed; raw ticket description is the fallback.

    • Attachment metadata (id, name, MIME type, download URL) for every attachment across all ticket messages.

  • Webhook failures never abort the lead creation; errors are logged at WARNING / ERROR level and the webhook log in Webhook Hub records the full request and response.

  • CRM form warning banner: if a lead has destination configured but is still pending synchronization, a warning is displayed to inform users that automatic retry runs every 2 hours.

Configuration

The setup requires three manual steps. Repeat for every external CRM target.

Step 1 — Payload Template

Webhook Hub → Payloads → New

Field

Value

Name

CRM Lead — Ticket to Lead Outbound

Model

CRM Lead (crm.lead)

Content

(see template below)

Template content (copy-paste and adjust as needed):

{
    "lead": {
        "name": {{ record.name | safe_tojson("") }},
        "email_from": {{ record.email_from | safe_tojson("") }},
        "partner_name": {{ record.partner_name | safe_tojson("") }},
        "mobile": {{ record.mobile | safe_tojson("") }},
        "phone": {{ record.phone | safe_tojson("") }}
    },
    "ticket": {
        "id": {{ record.helpdesk_original_ticket_id.id | safe_tojson("") }},
        "name": {{ record.helpdesk_original_ticket_id.name | safe_tojson("") }},
        "number": {{ record.helpdesk_original_ticket_id.number | safe_tojson("") }},
        "origin_email": {{ context.get('ticket_origin_email', '') | safe_tojson("") }},
        "body_with_history": {{ context.get('ticket_body', '') | safe_tojson("") }}
    },
    "attachments": {{ context.get('ticket_attachments', []) | tojson }}
}

The Jinja2 template context exposes:

  • record — the crm.lead record just created.

  • context.get('ticket_body', '') — HTML string with the full conversation history.

  • context.get('ticket_attachments', []) — list of dicts {id, name, mimetype, url} for every ticket attachment.

  • context.get('ticket_origin_email', '') — origin email of the customer who opened the ticket (empty string if not determinable).

  • context.event_type — always "create" for this flow.

Filters: use safe_tojson("") for scalar fields (handles False/None gracefully) and tojson for lists/dicts.

Save.

Step 2 — Webhook

Webhook Hub → Webhooks → New

Field

Example value

Name

n8n — CRM Lead (Zoho)

Direction

Outbound

URL

http://host.docker.internal:5678/webhook/crm

Allowed Methods

POST

Payload

CRM Lead — Ticket to Lead Outbound

Custom Headers

{“X-Odoo-Event”: “create”,

“X-Odoo-Model”: “crm.lead”}

Log Retention Days

30 (0 = keep forever)

Save, then activate the webhook.

Step 3 — CRM Lead Destination

CRM → Configuration → CRM Lead Destinations → New

Field

Value

Name

Zoho CRM via n8n

Outbound Webhook

n8n — CRM Lead (Zoho) (from Step 2)

Notes

Contact: ops team / n8n workflow ID: …

Save, then activate the destination (toggle the Active switch).

Converting a Ticket

  1. Open a helpdesk ticket and click Convert into CRM Lead.

  2. In the conversion wizard, set External Destination to the destination created in Step 3 (leave it empty to create the lead in Odoo CRM only).

  3. Fill in the remaining lead fields and click Save.

The lead is created in Odoo and, if a destination was selected, the webhook fires immediately. Check Webhook Hub → Webhooks → <webhook> → Logs to inspect the request and response.

Credits

Authors

  • Som IT Cooperatiu SCCL

Contributors

Maintainers

  • Som IT Cooperatiu SCCL

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

File details

Details for the file odoo_addon_helpdesk_ticket_to_lead_outbound-16.0.1.0.1.tar.gz.

File metadata

File hashes

Hashes for odoo_addon_helpdesk_ticket_to_lead_outbound-16.0.1.0.1.tar.gz
Algorithm Hash digest
SHA256 a6f8dcdd7d15e5c496381810c8a84b744ec85e42a8ab0996901469b2a53f8488
MD5 520cfccc86ced58e3c3de400eb1cae31
BLAKE2b-256 2eb947bbf57f7aef513e124fda28737fa8b2ccd652277f9934681b3ab93046ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page