ai*
This commit is contained in:
40
ai_crm/data/ai_skill.xml
Normal file
40
ai_crm/data/ai_skill.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="ai_crm.ai_skill_create_lead" model="ai.skill">
|
||||
<field name="name">Create Lead (Livechat)</field>
|
||||
<field name="description">Lets the Livechat agent register a lead from a website visitor conversation. Reserved for the Livechat flow: do not equip this skill on other agents — its lead creation runs without a confirmation card, which only makes sense in front of an anonymous visitor.</field>
|
||||
<field name="instructions"># Skill: Lead creation
|
||||
|
||||
##Purpose
|
||||
Create a lead when the assistant cannot confidently resolve a request or the user explicitly asks for a human follow-up.
|
||||
|
||||
## When to activate
|
||||
- Insufficient or conflicting info in the provided resources.
|
||||
- The request requires custom quotes, contractual details, implementation work, account access changes, or hands-on troubleshooting.
|
||||
- The user says things like "contact me", "schedule a demo", "I want pricing for my case", or provides contact information proactively and wants follow-up.
|
||||
|
||||
## Flow (step-by-step)
|
||||
1) If not asked explicitly, suggest to the customer to have someone from our team to recontact them.
|
||||
2) If you know the customer's name, email, and phone number (they can be in the instructions in the "User Info" section), explicitly ask confirmation for these details with the customer before proceeding, rather than assuming they are correct. Otherwise you should collect them one-by-one:
|
||||
2.1) If you don't know the customer's name, ask for their name. You can then use it naturally in the conversation.
|
||||
2.2) If you don't know the customer's email, ask for their email. Validate that it looks like an email; if not, ask for a corrected address.
|
||||
2.3) If you don't know the customer's phone number, ask for their phone number.
|
||||
3) Call the lead creation tool exactly once. The job position and address are optional.
|
||||
4) If the lead creation was successful, reply with "Thanks. Our team will recontact you soon." (Mirror the customer's language; keep it friendly and minimal). Otherwise reply with "An error occurred", and do **not** say that out team will recontact the user.
|
||||
5) Do not disclose internal tool names, payloads, or statuses.
|
||||
|
||||
## Strict Constraints
|
||||
- Never say "Lead created", "I will create a lead", "Ticket opened", or any system-centric phrasing.
|
||||
- Call the lead creation tool at most once per conversation. If the user later asks to change details, apologize and say a teammate will update them on follow-up. If the user requests more, politely decline.
|
||||
- Never promise recontact or imply action until after a lead has been successfully created. Instead, make recontact conditional: "To allow us to recontact you, please provide your email.")
|
||||
- Don't ask for the customer's name, email and phone number in the same message. Collect them one by one.
|
||||
- The lead description must:
|
||||
- Be valid HTML (wrapped in p tags).
|
||||
- Contain both the customer’s description and a clear explanation of why the selected tag_ids were chosen.
|
||||
- Not contain technical names (such as "tag_ids")</field>
|
||||
<field name="tool_ids" eval="[(6, 0, [
|
||||
ref('ir_actions_server_ai_create_lead'),
|
||||
ref('ir_actions_server_ai_get_lead_create_available_params')
|
||||
])]"/>
|
||||
</record>
|
||||
</odoo>
|
||||
106
ai_crm/data/ir_actions_server_tools.xml
Normal file
106
ai_crm/data/ir_actions_server_tools.xml
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="ir_actions_server_ai_create_lead" model="ir.actions.server">
|
||||
<field name="name">AI Tool: Create Livechat Lead</field>
|
||||
<field name="ai_tool_name">ai_tool_create_livechat_lead</field>
|
||||
<field name="state">code</field>
|
||||
<field name="use_in_ai" eval="True"/>
|
||||
<field name="code">ai['result'] = record.sudo()._ai_create_lead(name, contact_name, description, email, phone, team_id, tag_ids, priority, country_id, state_id, city, zip_code, street, job_position)</field>
|
||||
<field name="model_id" ref="crm.model_crm_lead"/>
|
||||
<field name="ai_tool_description">## Tool: Create a Lead from the Livechat conversation
|
||||
Use when the customer has provided the required information and you are ready to register the lead.</field>
|
||||
<field name="ai_tool_schema">
|
||||
{
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Name of the lead record"
|
||||
},
|
||||
"contact_name": {
|
||||
"type": "string",
|
||||
"description": "Name of the contact for which the lead record is created"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "Lead record description"
|
||||
},
|
||||
"email": {
|
||||
"type": "string",
|
||||
"description": "Email of the contact"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string",
|
||||
"description": "Phone number of the contact"
|
||||
},
|
||||
"team_id": {
|
||||
"type": "number",
|
||||
"description": "The id of the team to assign the lead to"
|
||||
},
|
||||
"tag_ids": {
|
||||
"type": "array",
|
||||
"description": "Array of ids of the tags to assign to the lead",
|
||||
"items": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"priority": {
|
||||
"type": "string",
|
||||
"description": "The key of the priority (choose between the ones provided by the 'get lead creation parameters' tool"
|
||||
},
|
||||
"country_id": {
|
||||
"type": "number",
|
||||
"description": "The id of the contact's country"
|
||||
},
|
||||
"state_id": {
|
||||
"type": "number",
|
||||
"description": "The id of the contact's state"
|
||||
},
|
||||
"city": {
|
||||
"type": "string",
|
||||
"description": "The contact's city"
|
||||
},
|
||||
"zip_code": {
|
||||
"type": "string",
|
||||
"description": "The contact's zip code"
|
||||
},
|
||||
"street": {
|
||||
"type": "string",
|
||||
"description": "The contact's street name and number"
|
||||
},
|
||||
"job_position": {
|
||||
"type": "string",
|
||||
"description": "The contact's job title"
|
||||
}
|
||||
},
|
||||
"required": ["name", "contact_name", "description", "email", "phone", "team_id", "tag_ids", "priority"],
|
||||
"type": "object"
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_actions_server_ai_get_lead_create_available_params" model="ir.actions.server">
|
||||
<field name="name">AI Tool: Get Livechat Lead creation parameters</field>
|
||||
<field name="ai_tool_name">ai_tool_get_livechat_lead_creation_parameters</field>
|
||||
<field name="state">code</field>
|
||||
<field name="use_in_ai" eval="True"/>
|
||||
<field name="code">ai['result'] = record.sudo()._ai_get_lead_create_available_params(country_code)</field>
|
||||
<field name="model_id" ref="crm.model_crm_lead"/>
|
||||
<field name="ai_tool_description">## Tool: Get Lead Creation Parameters
|
||||
Retrieves available teams and tags for lead creation.
|
||||
Use this tool only immediately before calling the lead creation tool (never at other times).
|
||||
When the customer provides their country (or if it can be clearly inferred from the conversation),
|
||||
use the country’s code as parameter to retrieve the country and its states IDs.</field>
|
||||
<field name="ai_tool_schema">
|
||||
{
|
||||
"properties": {
|
||||
"country_code": {
|
||||
"type": "string",
|
||||
"description": "ISO 3166-1 alpha-2 code of the customer's country"
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"type": "object"
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user