Automation Integration Guide¶
๐ฏ Overview¶
Have you ever wished your Odoo system could automatically analyze data, generate reports, or perform intelligent actions whenever something happens or on a schedule? That's exactly what AI Automation does - it connects your AI assistants with Odoo's Automation Rules and Scheduled Actions, so AI can work for you automatically in the background.
Think of it like having a smart assistant that watches your system and takes action whenever you need it, without you having to ask. When a new lead comes in, AI can automatically analyze it. When an order is confirmed, AI can generate a summary. When data is updated, AI can validate it. Or, on a schedule, AI can generate daily reports, perform periodic data analysis, or run maintenance tasks. All automatically, all the time.
๐ก What Can AI Automation Do?¶
AI Automation opens up powerful possibilities for automating intelligent tasks:
Data Analysis & Enrichment
- Automatically analyze new records and add insights
- Enrich leads with additional information from your database
- Calculate scores and ratings based on multiple factors
- Identify patterns and trends in your data
Report Generation
- Generate daily, weekly, or monthly reports automatically
- Create summaries of important events
- Compile data from multiple sources into readable formats
- Send intelligent notifications with context
Data Quality & Validation
- Validate new records before they're saved
- Check for compliance issues automatically
- Clean and standardize data
- Flag potential problems for review
Smart Categorization
- Automatically categorize records based on content
- Tag records with relevant keywords
- Route items to appropriate teams or departments
- Prioritize tasks based on intelligent analysis
Workflow Automation
- Trigger complex workflows based on AI analysis
- Make decisions automatically when criteria are met
- Update related records based on intelligent insights
- Coordinate actions across multiple systems
๐ Prerequisites¶
Before you can use AI Automation, make sure you have:
- โ AI Complete Suite installed and configured
- โ base_automation module enabled (usually comes with Odoo)
- โ At least one AI Assistant created and configured
- โ AI Configuration set up with valid API key
- โ Understanding of how Odoo Automation Rules and Scheduled Actions work
๐ Step 1: Understanding the Basics¶
What is an AI Action?¶
An AI Action is a special type of action you can use in Odoo Automation Rules and Scheduled Actions. Instead of just updating a field or sending an email, an AI Action lets you ask an AI assistant to do something intelligent with your data.
Key Differences from Regular Actions:
- Regular Action: "Set field X to value Y" - simple, predefined
- AI Action: "Analyze this record and suggest improvements" - intelligent, flexible
How It Works¶
When an automation rule or scheduled action with an AI Action triggers:
- System creates a new AI thread - Each automation execution gets its own conversation thread
-
Records are tagged - Records can be included in the AI's context in two ways:
- Manual tagging: Both Automation Rules and Scheduled Actions support manual record tagging using
$model/idsyntax in your prompt (e.g.,$crm.lead/123) - Automatic tagging (Automation Rules only): All records that triggered the rule are automatically included in the AI's context, in addition to any manual tags you specify
- Manual tagging: Both Automation Rules and Scheduled Actions support manual record tagging using
-
Your prompt is sent to AI - The AI receives your instructions along with the record data (if any)
- AI executes autonomously - The AI works in non-interactive mode, making decisions and taking actions without asking questions
- Results are applied - The AI can create records, update data, send messages, or perform any other actions using its tools
Key Difference:
- Automation Rules are triggered by events (record creation, update, etc.) and automatically include the triggered records in the AI context (in addition to any manual tags)
- Scheduled Actions run on a fixed schedule (daily, weekly, monthly) and don't have triggered records - you must manually tag records using
$model/idsyntax or instruct AI to search for records in your prompt
Non-Interactive Mode¶
When AI runs through automation, it works in non-interactive mode. This means:
- โ AI makes decisions automatically based on available information
- โ AI uses tools to gather data if needed, but doesn't ask you
- โ AI completes tasks without waiting for confirmation
- โ AI won't ask questions or request clarification
- โ AI won't wait for your input
This is perfect for automation because the AI needs to work independently, just like any other automated action.
๐ ๏ธ Step 2: Creating Your First AI Automation¶
Let's create a simple automation that automatically analyzes new sales leads. This will give you a hands-on understanding of how everything works.
Setting Up the Automation Rule¶
-
Navigate to Automation Rules
- Go to Settings โ Technical โ Automation โ Automation Rules
- Click Create
-
Configure the Trigger
- Name: "Auto-Analyze New Leads"
- Model:
crm.lead(or your lead model) - Trigger: "On Creation" (or "On Update" if you prefer)
- Domain: Leave empty to trigger on all leads, or add conditions like
[('type', '=', 'lead')]
-
Add the AI Action
- Scroll to the Actions section
- Click Add a line
- Action Type: Select "AI Action"
- You'll now see new fields appear for AI configuration
-
Configure the AI Action
Now you need to tell the system which AI assistant to use and what you want it to do:
-
Select AI Assistant
- AI Assistant: Choose the assistant you want to use (e.g., "Sales Analysis Assistant")
- Make sure this assistant has access to the data sources it needs
-
Write Your Prompt
- AI Prompt: This is where you describe what you want the AI to do
- Be specific and clear about your expectations
- Manual tagging: You can reference additional records using
$model/idsyntax in your prompt (e.g.,$crm.lead/123) - Automatic tagging: The system automatically tags all triggered records in addition to any manual tags you specify
Example Prompt:
-
Configure Security (Optional)
- Run as Superuser: Check this if the AI needs to access data beyond normal user permissions
- Use this carefully - it bypasses security restrictions
- Only enable if your AI needs to access restricted data
-
-
Save the Rule
- Click Save
- Make sure the rule is Active
Note: When your automation triggers, the system automatically includes all triggered records in the AI's context. You can also manually tag additional records using $model/id syntax if needed.
Setting Up a Scheduled Action¶
For tasks that need to run on a schedule (daily reports, periodic analysis, etc.), you can use Scheduled Actions instead:
-
Navigate to Scheduled Actions
- Go to Settings โ Technical โ Automation โ Scheduled Actions
- Click Create
-
Configure the Schedule
- Name: "Daily Sales Report"
- Model:
sale.order(or the model you want to analyze) - Interval Number: 1
- Interval Type: Days (or Weeks, Months, etc.)
- Next Execution Date: Set when you want it to start
-
Set Action Type to AI Action
- Action Type: Select "AI Action" (instead of "Code")
- You'll now see the same AI configuration fields as Automation Rules
-
Configure the AI Action
Now you need to tell the system which AI assistant to use and what you want it to do:
-
Select AI Assistant
- AI Assistant: Choose the assistant you want to use (e.g., "Sales Reporting Assistant")
- Make sure this assistant has access to the data sources it needs
-
Write Your Prompt
- AI Prompt: This is where you describe what you want the AI to do
- Be specific and clear about your expectations
- Manual tagging required: Since there are no triggered records, you must manually tag records using
$model/idsyntax in your prompt (e.g.,$sale.order/123) or instruct the AI to search for records using its tools
Example Prompt:
-
Configure Security (Optional)
- Run as Superuser: Check this if the AI needs to access data beyond normal user permissions
- Use this carefully - it bypasses security restrictions
- Only enable if your AI needs to access restricted data
-
-
Save the Action
- Click Save
- Make sure the action is Active
Note: Since Scheduled Actions don't have triggered records, you must manually tag records using $model/id syntax in your prompt (e.g., $sale.order/123) or instruct the AI to search for records using its tools.
When to Use Each:
- Automation Rules: Use when you want AI to act on specific events (new record created, record updated, etc.)
- Scheduled Actions: Use when you want AI to run on a fixed schedule (daily reports, weekly analysis, monthly summaries, etc.)
๐ Step 3: Writing Effective Prompts¶
The quality of your automation depends heavily on how well you write your prompts. Here are some best practices:
Be Specific and Clear¶
โ Bad Prompt:
โ Good Prompt:
Analyze this lead and:
1. Calculate a lead score from 0-100 based on:
- Company size (larger = higher score)
- Industry match with our target markets (+20 points)
- Budget information availability (+10 points)
2. Add tags: "high-priority" if score > 70, "needs-followup" if score > 50
3. Update the lead description with: "Lead Score: [score]. Key factors: [list factors]"
Break Down Complex Tasks¶
If you want the AI to do multiple things, break it down into clear steps:
For this order:
1. Check if all line items are in stock
2. If any items are out of stock, create a purchase order for those items
3. Calculate the estimated delivery date based on stock availability
4. Update the order notes with delivery information
5. Send a message to the customer thread with the delivery estimate
Provide Context and Examples¶
Help the AI understand what you want by providing context:
This is a customer support ticket. Analyze the issue and:
1. Categorize it (Technical, Billing, Feature Request, Bug Report)
2. Assign a priority (High if contains words like "urgent" or "critical", Medium otherwise)
3. Suggest a response template based on the category
4. If it's a bug, create a linked bug report record
Use Conditional Logic¶
You can ask the AI to make decisions:
Analyze this invoice:
- If the amount is over $10,000, add tag "high-value" and notify the finance manager
- If payment is overdue by more than 30 days, mark as "urgent" and create a follow-up task
- If the customer has a good payment history, apply a 2% discount
๐ Step 4: Security and Permissions¶
Understanding AI Permissions¶
By default, AI assistants respect the same permissions as the user who created the automation rule or scheduled action. This means:
- AI can only access data the user has permission to view
- AI can only modify records the user has permission to edit
- AI respects all Odoo security rules and domain restrictions
When to Use Superuser Mode¶
The Run as Superuser option allows the AI to bypass security restrictions. Use this when:
- โ The AI needs to access data from multiple companies
- โ The AI needs to modify records the user normally can't edit
- โ The automation should work regardless of who created the rule
- โ Don't use it if you want to maintain strict security controls
- โ Don't use it if the AI should respect user-level data access
Example Use Case: You want an automation that analyzes all leads across all companies and generates a company-wide report. The user who created the rule or scheduled action might only have access to their own company's leads, so you'd enable superuser mode to let the AI access all leads.
Best Practices for Security¶
- Start without superuser mode - Only enable it if you really need it
- Test thoroughly - Make sure the AI only does what you expect
- Monitor AI actions - Review what the AI does, especially in the beginning
- Use specific prompts - Clear prompts reduce the chance of unexpected actions
- Limit data sources - Only give the AI access to data sources it actually needs
๐งช Step 5: Testing Your Automation¶
Before relying on automation in production, test it thoroughly:
Testing Steps¶
-
Create Test Records
- Create a test record that matches your trigger conditions
- Use data that's easy to identify (e.g., "TEST LEAD - DELETE ME")
-
Trigger the Automation
- Let the automation run (or manually trigger it if possible)
- Wait a few moments for the AI to process
-
Check the Results
- Verify the AI thread was created: Settings โ Technical โ AI โ Threads
- Look for a thread with the same name as your automation rule or scheduled action
- Check the thread messages to see what the AI did
- Verify the actual changes to your records
-
Review AI Actions
- Check if records were created, updated, or modified as expected
- Verify any messages were sent correctly
- Ensure data quality is maintained
-
Refine and Iterate
- If results aren't perfect, adjust your prompt
- Test again with different scenarios
- Keep refining until you're satisfied
Common Testing Scenarios¶
Test with Different Data Types:
- Test with complete data (all fields filled)
- Test with minimal data (only required fields)
- Test with edge cases (unusual values, special characters)
Test with Multiple Records:
- Create multiple records that trigger simultaneously
- Verify the AI handles all of them correctly
- Check that each record gets appropriate treatment
Test Error Handling:
- What happens if the AI can't complete the task?
- What if required data is missing?
- What if the AI encounters an error?
๐ Step 6: Monitoring and Maintenance¶
Monitoring AI Automation¶
Keep an eye on your automations to ensure they're working correctly:
-
Check AI Threads
- Regularly review threads created by automation
- Look for error messages or unexpected behavior
- Verify AI responses match your expectations
-
Review Record Changes
- Spot-check records that were processed by automation
- Ensure data quality is maintained
- Look for patterns or issues
-
Monitor Performance
- Check how long automations take to complete
- Watch for any slowdowns in your system
- Ensure API usage stays within limits
Maintaining Your Automations¶
Regular Reviews:
- Periodically review automation results
- Update prompts based on changing business needs
- Remove or update automations that are no longer relevant
Optimization:
- Refine prompts to improve accuracy
- Adjust triggers to reduce unnecessary executions
- Optimize AI assistant configurations for better performance
Documentation:
- Keep notes on what each automation does
- Document any special considerations or edge cases
- Update documentation when automations change
๐ก Real-World Examples¶
Example 1: Lead Enrichment¶
Goal: Automatically enrich new leads with additional information and scoring
Automation Setup:
- Trigger: On Creation of
crm.lead - AI Assistant: "Sales Analysis Assistant"
- Prompt:
Analyze this new lead and: 1. Search our customer database for similar companies 2. Calculate a lead score (0-100) based on: - Company size and industry - Budget information - Similarity to existing customers 3. Add tags: "high-value" if score > 70, "qualified" if score > 50 4. Update the lead description with key insights and the calculated score 5. If score > 80, create a follow-up task for the sales team
Result: Every new lead automatically gets analyzed, scored, and tagged, saving the sales team hours of manual work.
Example 2: Daily Sales Report¶
Goal: Generate a daily summary of sales activities
Scheduled Action Setup:
- Type: Scheduled Action
- Schedule: Daily at 9:00 AM
- Model:
sale.order - AI Assistant: "Sales Reporting Assistant"
- Prompt:
Setup Instructions:
- Go to Settings โ Technical โ Automation โ Scheduled Actions
- Create a new scheduled action
- Set Action Type to "AI Action"
- Configure the schedule (daily at 9 AM)
- Enter the prompt above
- Save and activate
Result: Sales team gets an intelligent daily summary automatically, highlighting important information and trends.
Example 3: Data Quality Check¶
Goal: Validate and clean customer data when records are updated
Automation Setup:
- Trigger: On Update of
res.partner - AI Assistant: "Data Quality Assistant"
- Prompt:
Review this customer record for data quality issues: 1. Check if email format is valid 2. Verify phone number format 3. Check for duplicate records with similar names or emails 4. Validate address completeness 5. If issues found, add tag "needs-review" and create a task for data cleanup team 6. If all checks pass, remove "needs-review" tag if present
Result: Customer data stays clean and validated automatically, reducing errors and improving data quality.
๐ฏ Best Practices¶
Prompt Design¶
- Be specific: Clearly state what you want the AI to do
- Provide context: Help the AI understand the business context
- Break down tasks: Complex tasks should be broken into steps
- Include examples: Show the AI what good output looks like
- Test and refine: Iterate on your prompts based on results
Automation Design¶
- Start simple: Begin with straightforward automations
- Test thoroughly: Always test before relying on automation
- Monitor closely: Watch automations closely at first
- Document clearly: Keep notes on what each automation does
- Review regularly: Periodically review and update automations
Security Considerations¶
- Minimize superuser usage: Only use when absolutely necessary
- Limit data access: Give AI only the data sources it needs
- Test permissions: Verify AI respects security rules
- Monitor actions: Review what AI does, especially initially
- Keep prompts safe: Don't ask AI to do things that could cause problems
๐จ Troubleshooting¶
AI Not Responding¶
- Check if the AI assistant is active and properly configured
- Verify the AI configuration has a valid API key
- Check system logs for error messages
- Ensure the automation rule or scheduled action is active
- For Scheduled Actions, verify the next execution date is set correctly
Unexpected Results¶
- Review the AI thread to see what the AI actually did
- Check if your prompt was clear enough
- Verify the AI has access to necessary data sources
- Consider adding more context to your prompt
Performance Issues¶
- Check if automations are running too frequently
- Review API usage and rate limits
- Consider optimizing prompts to be more efficient
- Check system resources and database performance
Permission Errors¶
- Verify the AI assistant has access to required data sources
- Check if superuser mode is needed
- Review user permissions for the automation creator
- Ensure domain restrictions aren't blocking access
โ What's Next?¶
Now that you understand AI Automation, you can:
- Explore Use Cases: See real-world examples in Workflow Automation Use Cases
- Learn About AI Assistants: AI Assistants Guide
- Understand Data Sources: Data Sources Guide
- Configure Contexts: Contexts Guide
AI Automation transforms your Odoo system into an intelligent, self-managing platform. With careful planning and testing, you can automate complex tasks that would be impossible with traditional automation rules or scheduled actions.