Skip to content

[16.0][ADD] helpdesk_mgmt_livechat: add new module - #884

Open
marcelsavegnago wants to merge 1 commit into
OCA:16.0from
Escodoo:16.0-add-helpdesk_mgmt_livechat
Open

[16.0][ADD] helpdesk_mgmt_livechat: add new module#884
marcelsavegnago wants to merge 1 commit into
OCA:16.0from
Escodoo:16.0-add-helpdesk_mgmt_livechat

Conversation

@marcelsavegnago

Copy link
Copy Markdown
Member

This module extends the helpdesk management functionality by allowing you to create tickets directly from livechat conversations.

Main Features

  • Create Tickets from Livechat: Allows creating helpdesk tickets directly from livechat conversations using the /ticket command
  • Chatbot Integration: Automatically creates tickets when chatbot reaches a "create_ticket" step
  • Automatic Team Assignment: Configure chatbot steps to automatically assign tickets to specific helpdesk teams
  • Conversation History: Automatically includes the full conversation history in the ticket description
  • Ticket Counter: Displays the number of tickets generated by each chatbot directly in the chatbot view
  • Channel Tracking: Automatically marks tickets created from livechat with the "Livechat" channel

Benefits

  • Streamline customer support by creating tickets directly from chat conversations
  • Automate ticket creation through chatbot workflows
  • Keep complete conversation context in ticket descriptions
  • Track tickets originated from livechat interactions
  • Improve response time by converting chats to actionable tickets

Dependencies

This module requires:

  • helpdesk_mgmt: Base helpdesk management module
  • im_livechat: Odoo's livechat module

@marcelsavegnago

Copy link
Copy Markdown
Member Author

cc @parzewski @douglascstd

@kaynnan kaynnan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread helpdesk_mgmt_livechat/__manifest__.py Outdated
@marcelsavegnago
marcelsavegnago force-pushed the 16.0-add-helpdesk_mgmt_livechat branch from 4379492 to 0b1fa91 Compare November 26, 2025 22:30

@WesleyOliveira98 WesleyOliveira98 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marcos-mendez marcos-mendez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Review -- Tests Failed

1. Root Cause of the Test Failure

The test failure occurs because the database connection fails during the Odoo server startup, likely due to misconfiguration or an issue with the test environment setup (e.g., missing PostgreSQL service or invalid connection parameters). This is not directly caused by the module code but indicates a failure in the CI/CD pipeline or test runner environment.


2. Suggested Fix

There is no code-level fix needed for this failure since it's an infrastructure or environment issue. However, to prevent such failures in the future:

  • Ensure that the runboat environment is properly configured with access to a valid PostgreSQL instance.
  • Verify that the database connection string in the test config is correct.
  • Confirm that the test database is created and accessible before running tests.

⚠️ This error is unrelated to the module code changes and should be resolved at the CI level.


3. Additional Code Issues

🔴 Potential Bug in chatbot_script_step.py line ~77

create_values.update(
    self._chatbot_helpdesk_prepare_ticket_values(
        mail_channel, customer_values["description"]
    )
)
  • The method _chatbot_helpdesk_prepare_ticket_values is not defined in the base class chatbot.script.step, and it's expected to be overridden or defined in this module.
  • It should be a protected method (e.g., _prepare_ticket_values) or at least documented as an extension point.

Suggested Fix:
Rename _chatbot_helpdesk_prepare_ticket_values to _prepare_ticket_values and ensure it's a documented hook, e.g.,:

def _prepare_ticket_values(self, mail_channel, description):
    return {
        "description": description + mail_channel._get_channel_history(),
        "name": _("%s's New Ticket", self.chatbot_script_id.title),
        "team_id": self.helpdesk_team_id.id,
        "user_id": False,
    }

Then update the call to:

create_values.update(self._prepare_ticket_values(mail_channel, customer_values["description"]))

🔴 Inefficient Domain Search in chatbot_script.py line ~25

.search_count(
    [
        ("description", "ilike", script.title),
        ("channel_id.name", "=", "Livechat"),
    ]
)
  • The search_count uses ilike on description which is inefficient and may cause performance issues if there are many tickets.
  • It's also fragile since ticket descriptions may not always contain the chatbot title.

Suggested Fix:
Use a more robust way to track tickets created from chatbots, such as adding a related field or using a computed field with a proper link to the chatbot script.


4. Test Improvements

Add Tests for the Following Scenarios (using SavepointCase or TransactionCase)

  1. Test /ticket command execution:

    • Simulate a livechat conversation.
    • Execute /ticket Some issue.
    • Assert that a ticket is created with correct title, description, and channel.
  2. Test chatbot create_ticket step:

    • Create a chatbot script with a create_ticket step.
    • Configure a helpdesk team.
    • Simulate a visitor reaching that step.
    • Assert that a ticket is created with correct team, description, and channel.
  3. Test channel creation fallback logic:

    • Delete the helpdesk.ticket.channel record.
    • Trigger ticket creation via chatbot or /ticket.
    • Assert that the channel is recreated automatically.
  4. Test ticket_count computation:

    • Create multiple tickets with matching descriptions.
    • Run _compute_ticket_count on a chatbot script.
    • Assert that the ticket_count is correctly updated.

Use OCA Testing Patterns

  • Use SavepointCase for tests involving data isolation and performance.
  • Use TransactionCase for tests requiring transactional behavior.
  • Tag tests with @tagged('post_install') if they rely on data loaded from XML files.

Example Test Snippet

def test_ticket_creation_from_chatbot_step(self):
    script = self.env.ref("helpdesk_mgmt_livechat.chatbot_script_ticket_generation_bot")
    step = self.env["chatbot.script.step"].create({
        "step_type": "create_ticket",
        "chatbot_script_id": script.id,
        "helpdesk_team_id": self.env.ref("helpdesk_mgmt.helpdesk_team_1").id,
    })
    # Simulate channel and run step
    channel = self.env["mail.channel"].create({"name": "Test"})
    # Assert ticket is created

Summary

Area Issue
Root Cause Test environment/database connection issue, not code
Code Bug Inefficient domain search and fragile description matching
Extension Hook _chatbot_helpdesk_prepare_ticket_values should be renamed and documented
Testing Add tests for /ticket command, chatbot steps, and fallback channel logic

Let me know if you'd like a patch file or test code examples.


⏰ PR Aging Alert

This PR by @marcelsavegnago has been open for 121 days (4 months).

Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)


Reciprocal Review Request

Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):

My open PRs across OCA:

Reviewing each other's work helps the whole community move forward. Thank you!


Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b

@github-actions

Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants