Title: Odoo 18 - Send WhatsApp template via automated action after customer replies in discuss.channel
Description:
I'm trying to build a WhatsApp flow in Odoo 18:
- Customer receives WhatsApp template with buttons ("Goed bevallen" / "Niet goed bevallen")
- Customer clicks "Goed bevallen" → reply comes in as a discuss.channel message
- Odoo should automatically send a second WhatsApp template as response
What works:
- Automated action triggers correctly on model "mail.message"
- Trigger: On save, filter: body contains "Goed bevallen"
- We can find the sale.order via the channel name
- We have the partner phone number
What doesn't work:
- Sending the WhatsApp template via code
Code tried so far:
python
# Attempt 1 - gives AttributeError
env["whatsapp.message"].create({...}).send()
# Attempt 2 - gives AttributeError
env["whatsapp.message"].create({...}).button_send_whatsapp_template()
# Attempt 3 - no error but nothing sent
env["whatsapp.composer"].create({...}).action_send_whatsapp_template()Question: What is the correct method in Odoo 18 to send an approved WhatsApp template via server action code?
Hello,
You're very welcome, I'm glad it worked out.
Hope it helps
Thanks