To send a survey invitation email automatically within a Marketing Automation Activity in Odoo, you can use a Server Action to generate and send the survey email. Below is a step-by-step guide on how to achieve this:
1. Prerequisites
- Ensure the Surveys module is installed.
- Create or have an existing survey ready to send.
- Make sure you have a working email setup configured in Settings > Email.
2. Create an Email Template
-
Navigate to Email Templates:
- Go to Settings > Technical > Email > Templates.
- Click Create to design a new email template for your survey.
-
Set the Template Details:
3. Create the Server Action
-
Navigate to Server Actions:
- Go to Settings > Technical > Automation > Server Actions.
- Click Create to define a new server action.
-
Configure the Action:
- Name: Enter a descriptive name (e.g., "Send Survey Invitation").
- Model: Select the model where the server action will run (e.g., "Survey", "Contact", or "Lead").
- Action To Do: Choose Execute Python Code.
-
Add Python Code:
Use the following Python script to send the survey email dynamically:
template_id = env.ref('your_module_name.email_template_survey_invitation')
if template_id:
for record in records:
template_id.send_mail(record.id, force_send=True)
- Replace your_module_name.email_template_survey_invitation with the technical name of the email template created in Step 2.
4. Add the Server Action to Marketing Automation
-
Create or Edit a Campaign:
- Go to Marketing > Automation.
- Create a new campaign or open an existing one.
-
Add an Activity:
- Add an activity that triggers the server action. For example:
- Trigger Type: Email Sent, Record Creation, or Specific Time Delay.
- Action: Select the server action created in Step 3.
5. Test the Setup
- Trigger the marketing campaign or activity.
- Verify that:
- The email is sent to the recipient.
- The survey link is included and functional.
6. Additional Notes
Outcome
When the marketing automation activity triggers the server action, it will dynamically send the email to the recipients with the survey link. This allows you to automate survey invitations seamlessly.
Let me know if you need further assistance!