Google Indexing API for Magento 2
€50.00 €50.00
AI Email Theme Generator extends Magento 2 email template management with AI-assisted generation. The module adds a practical workflow for improving native Magento transactional templates directly from the admin panel, without replacing the standard email template system.
Administrators can generate, rebuild, improve, or expand existing Magento email templates using ChatGPT via the OpenAI API. The generated result is returned as structured data and can be saved to native Magento fields:
The process is controlled, auditable, and asynchronous. Each AI request is handled by the Magento queue and tracked as a separate job with information about status, history, errors, request payload, response payload, and the generated result.
Magento transactional emails are an important customer touchpoint, but their default look is usually very generic and requires manual HTML/CSS work to match the brand. AI Email Theme Generator reduces the time needed to prepare better email templates while keeping the result within the native Magento infrastructure.
The module works well for:
The module extends the standard Magento admin interface:
Marketing > Communications > Email TemplatesA saved template receives additional AI fields directly in the standard Magento email template editor. The administrator can enter a prompt, add an optional reference design, prepare image assets, and request generation using ChatGPT.
The AI result is expected as JSON and mapped to native Magento fields:
{ 'template_name': 'New Order Confirmation - Guest', 'template_subject': 'Your order confirmation', 'template_content': '', 'template_styles': '/* CSS */', 'warnings': [], 'change_summary': 'Updated layout and improved copy.', 'variables_used': ['order.increment_id', 'store.frontend_name']}This makes the result predictable and easier to validate before saving.
Generation is not performed while the admin page is loading. The module creates a queue job and processes it in the background using Magento Message Queue.
This prevents long waiting times in the admin panel and gives the team a clear view of each generation request.
Generation jobs are available in:
Marketing > Communications > AI Email Generation JobsEach job shows:
Failed jobs can be retried, pending jobs can be canceled, and completed results can be applied manually if automatic result saving is disabled.
Administrators can add a reference file, such as an image, HTML, or text file. The file is included in the AI context and can be used to generate a template that follows the selected visual concept.
The native email template editor can also store AI assets assigned to a specific template:
Each asset can have a label, alternative text, target URL, and sort order. Banner and icon rows can be added dynamically in the form.
During generation, the module sends an assets section to AI with public frontend URLs grouped by purpose. This lets ChatGPT know which image is the logo, which belongs to the header, which files are banners, and which are icons.
This approach provides a more predictable email layout than sending one generic reference image.
The module includes a global technical prompt used with every generation request. The prompt contains fixed technical rules, such as:
This separates technical instructions from the business prompt written for an individual template.
The module is prepared as a Composer package for Magento:
kowal/module-ai-email-theme-generatorIt is intended to be installed as a vendor package, not manually copied to app/code.
The module is implemented in English, and all visible texts are prepared for the Magento i18n mechanism through translation helpers or translatable labels and XML comments.
AI can be used to modernize default Magento emails, such as:
The administrator can provide a prompt and reference design so the generated template matches the store communication tone, color palette, typography expectations, and layout style.
Developers can use the module to generate the first version of a template, then review the result, validate Magento directives, and refine the final HTML/CSS.
Because each request is saved as a job, the team can compare prompts, models, results, warnings, and errors without losing history.
AI Email Theme Generator is designed to support administrators and developers, not to bypass validation or the Magento template review process.
The module supports:
script tags in generated content,In production environments, it is recommended to disable automatic result application until the team verifies the quality of generated templates for its prompts and use cases.
AI Email Theme Generator brings AI-assisted email template generation to the Magento 2 admin panel while preserving the native Email Templates workflow. The module helps improve transactional emails faster, keeps the process auditable through queue jobs, and gives developers control over prompts, response format, and how the result is applied.
The module is intended for Magento 2 and Composer-managed installations.
Required:
Module package:
kowal/module-ai-email-theme-generatorMagento module name:
Kowal_AiEmailThemeGeneratorAdd the Composer repository:
composer config repositories.ai.email.theme.generator vcs https://github.com/kowalco/ai-email-theme-generatorIf the repository is private, configure GitHub authentication:
composer config --global --auth github-oauth.github.com Install the module:
composer require kowal/module-ai-email-theme-generatorEnable the module:
bin/magento module:enable Kowal_AiEmailThemeGeneratorRun the Magento upgrade:
bin/magento setup:upgradeFlush the cache:
bin/magento cache:flushFor production mode, run the standard deployment commands used in the project, for example:
bin/magento setup:di:compilebin/magento setup:static-content:deploybin/magento cache:flushAI generation is processed asynchronously through Magento Message Queue.
Start the consumer manually:
bin/magento queue:consumers:start kowal.ai_email.generate.consumerIn production environments, configure the consumer under supervisor, systemd, or another process manager used by the hosting environment.
The module creates jobs in the admin panel, but the AI request will not be processed until the consumer is running.
The module adds ACL resources:
Kowal_AiEmailThemeGenerator::rootKowal_AiEmailThemeGenerator::jobsKowal_AiEmailThemeGenerator::generateKowal_AiEmailThemeGenerator::retryKowal_AiEmailThemeGenerator::cancelKowal_AiEmailThemeGenerator::applyKowal_AiEmailThemeGenerator::deleteKowal_AiEmailThemeGenerator::settingsTo allow an administrator to use the module, assign the appropriate resources in:
System > Permissions > User RolesFor full access, allow the main AI Email Generation resource and all child resources.
Go to:
Stores > Configuration > AI Email Generation > AI Email Theme GeneratorThe configuration section contains the group:
General SettingsType: Yes/No
Default: No
Enables or disables the module features.
When set to No:
Set Yes only after preparing the API key and starting the queue consumer.
Type: Select
Default: OpenAI
Defines the AI provider used by the module.
The current implementation supports:
OpenAIThe field exists so that more providers can be added in the future without changing the administrator workflow.
Type: hidden/encrypted field
Stores the OpenAI API key used for generation.
The value is encrypted by Magento using:
MagentoConfigModelConfigBackendEncryptedImportant:
Type: Select
Defines the OpenAI model used for generation.
Example:
gpt-4.1The list is fetched dynamically from the OpenAI Models API using the configured API key. The module filters the response to GPT model identifiers and caches the list for a short time so it does not call the API every time the configuration is opened.
If the API key has not been saved yet, the field will show a fallback option and ask the administrator to save the key.
If the OpenAI API is temporarily unavailable, the field keeps the currently configured model whenever possible.
Use a model that supports the required input type:
The selected model affects result quality, response time, and cost.
Type: Number
Example default value:
120Maximum time in seconds allowed for the request to the OpenAI API.
Recommended values:
60 for short text generation,120 or more for complex HTML/CSS generation,The timeout applies to background processing, not the admin form request.
Type: Number
Example default value:
2Defines how many times the consumer can automatically retry a failed generation job.
Retries are useful for temporary errors, such as:
Permanent errors, such as incorrect configuration or an invalid AI response, should be checked in the job details.
Type: Textarea
This prompt is applied to every generation request. It should contain technical rules that must always be followed.
Example:
You are an assistant generating Magento 2 email templates.Return only JSON that matches the provided schema.Keep Magento directives valid.Do not invent Magento variables.Do not add JavaScript.Put CSS in template_styles unless inline styles are required for email compatibility.Preserve required variables and add warnings when a requested change is risky.When assets are provided, use only the URLs from the assets section, preserve alt text, apply target links to clickable images, use banners and icons according to their sort_order, and do not invent additional image URLs.Use this field for stable instructions, such as:
Do not use this field for one-time creative instructions. Use AI Prompt in the template form for that.
Type: Textarea
This prompt is shown by default in the AI section of the email template editor.
Example:
Improve this Magento email template while keeping all required Magento variables and directives valid.The administrator can change it before creating a generation job.
Use this field to set a practical default instruction for typical generation tasks.
Type: Text
Example default value:
png,jpg,jpeg,webp,html,htm,txtComma-separated list of allowed file extensions for the optional reference design.
Supported examples:
pngjpgjpegwebphtmlhtmtxtIn production, use the most restrictive list possible. Do not allow file types that are not needed in the process.
Type: Number
Example default value:
5242880Maximum reference file size in bytes.
Examples:
1048576 = 1 MB5242880 = 5 MB10485760 = 10 MBLarge files increase the payload size and may slow down generation or exceed provider limits.
Type: Yes/No
Default: No
Defines whether a valid AI result should immediately overwrite the native Magento template fields.
When set to Yes, the consumer saves the generated result to:
When set to No, the result is stored in the job and the administrator can review it before applying it manually.
Recommended production setting:
NoManual approval is safer because the AI result may be technically correct but still require brand, legal, or layout review.
Type: Yes/No
Default: Yes
Defines whether the module saves full request and response payloads in the job record.
When enabled, job details may show:
This is useful for debugging and auditing.
In production environments, review privacy requirements before enabling this option. The module should not send real customer data to AI, but payloads may still contain business-sensitive template content.
Type: Number
Example default value:
30Defines how long old jobs should be stored.
This value documents the target retention policy. The project can use it to implement scheduled cleanup according to operational requirements.
This example describes the full process of generating an improved Magento email template for:
New Order Confirmation for GuestGo to:
Stores > Configuration > AI Email Generation > AI Email Theme GeneratorSet:
Enabled = YesAPI Provider = OpenAIOpenAI API Key = OpenAI Model = gpt-4.1Request Timeout = 120Maximum Retries = 2Automatically Apply Result = NoKeep Request and Response Payloads = Yes Save the configuration and flush the cache if Magento asks you to.
Run:
bin/magento queue:consumers:start kowal.ai_email.generate.consumerDuring testing, the process should run continuously.
Go to:
Marketing > Communications > Email TemplatesClick:
Add New TemplateIn the Template field, select:
New Order Confirmation for GuestClick:
Load TemplateMagento will populate the native fields:
Set the template name, for example:
New Order Confirmation for Guest - AI DraftSave the template.
The AI generation process requires a saved template because the job must have a persistent template_id.
After saving, open the template again if necessary. The standard Magento email template editor includes the AI Email Generation section.
In the AI Prompt field, enter a business instruction, for example:
Create a modern, clean transactional email for a premium fashion store.Keep all Magento order variables and directives valid.Improve the subject line and make the content easier to scan.Add a clear order summary section, shipping information section, and customer support footer.Use neutral colors, simple spacing, and email-client-safe HTML.Purpose of this field:
Use Design Reference if the generated email should follow a specific visual direction.
Example files:
order-email-reference.pngbrand-email-layout.webpemail-layout.htmldesign-notes.txtPurpose of this field:
If no reference design is added, AI will use only the template content, variables, technical prompt, and user prompt.
Use Error Screenshot if you want to show AI the current rendering, layout, or template validation issue.
Examples:
This field is sent to AI as a separate JSON section:
{ 'error_screenshot': { 'type': 'image', 'filename': 'email-rendering-error.png', 'mime_type': 'image/png', 'content_base64': '...', 'purpose': 'current_error_context', 'description': 'Screenshot showing current rendering, layout, visual, or validation errors. Use it to understand what should be fixed. This is not a design reference.' }}Purpose of this field:
AI Prompt.Example prompt:
Use the attached error screenshot only to understand the current rendering issue.Fix the spacing problem visible in the screenshot while preserving Magento variables.Do not treat the screenshot as the target design.The editor includes an AI Assets area. These assets are saved with the Magento template and sent to AI as grouped frontend media URLs.
Available asset groups:
| Field | Meaning |
|---|---|
| Logo | Brand logo used in the email header or footer. |
| Header Image | Main graphic for the top part of the email. |
| Banners | Dynamic list of promotional or informational banners. |
| Icons | Dynamic list of small graphic elements, such as benefits or service icons. |
Each asset can contain:
| Field | Meaning |
|---|---|
| File | Image file uploaded to Magento media storage. |
| Label | Internal name that helps AI understand the purpose of the asset. |
| Alt Text | Text used in the image alt attribute. |
| Target URL | Link used when the image should be clickable. |
| Sort Order | Display priority for banners and icons. |
For banners and icons, click:
Add BannerAdd IconThe module saves uploaded assets in Magento media storage and sends public frontend URLs to AI in the following structure:
{ 'assets': { 'logo': { 'label': 'Brand logo', 'url': 'https://example.com/media/ai_email_theme_generator/template_12/logo/logo.png', 'alt': 'Brand logo', 'link': 'https://example.com/', 'sort_order': 0 }, 'header_image': { 'label': 'Spring campaign header', 'url': 'https://example.com/media/ai_email_theme_generator/template_12/header/header.jpg', 'alt': 'Spring collection', 'link': 'https://example.com/spring', 'sort_order': 0 }, 'banners': [ { 'label': 'Main promotion', 'url': 'https://example.com/media/ai_email_theme_generator/template_12/banner/banner.jpg', 'alt': '20% off new collection', 'link': 'https://example.com/new', 'sort_order': 10 } ], 'icons': [ { 'label': 'Free delivery', 'url': 'https://example.com/media/ai_email_theme_generator/template_12/icon/delivery.png', 'alt': 'Free delivery', 'link': 'https://example.com/delivery', 'sort_order': 10 } ] }}Refer to these groups directly in prompts. Example:
Use the uploaded logo as the main brand mark.Use the header image at the top of the email.Place banners below the order summary using their sort order.Use icons in a benefits row and link each icon to its target URL.Always preserve alt text.Enable:
Generate with AI after savingPurpose of this field:
If the checkbox is not selected, saving the template works exactly like a standard Magento save, and no AI job is created.
Click the standard Magento button:
Save TemplateAfter the template is saved, the module creates a generation job.
At this point:
pending,Go to:
Marketing > Communications > AI Email Generation JobsOpen the created job.
Key fields:
| Field | Meaning |
|---|---|
| Status | Current processing status. |
| Template ID | ID of the native Magento email template. |
| Template Name | Template name saved at the time the job was created. |
| Model | OpenAI model used for generation. |
| Attempts | Number of processing attempts. |
| Prompt | User prompt submitted from the template form. |
| Request Payload | JSON sent to AI if payload storage is enabled. |
| Response Payload | JSON returned by AI if payload storage is enabled. |
| Generated Result | Parsed result ready to apply. |
| Assets | Public frontend URLs and metadata for the logo, header, banners, and icons. |
| Error Screenshot | Screenshot with current errors, sent to AI as repair context. |
| Warnings | AI warnings about risky or incomplete requirements. |
| Error Message | Error cause when generation fails. |
| Status History | History of job status changes. |
Typical statuses:
| Status | Meaning |
|---|---|
pending | The job has been created and is waiting for the consumer. |
processing | The consumer is currently processing the job. |
retry_scheduled | The previous attempt failed and a retry has been scheduled. |
completed | AI returned a valid result. |
failed | The job failed after all attempts or validation failed. |
cancelled | The administrator canceled the job. |
If Automatically Apply Result = No, the result is not automatically saved to the Magento template.
Review:
If the result is correct, click:
Apply ResultThe module will save the generated values to the native Magento template fields.
Return to:
Marketing > Communications > Email TemplatesOpen the template and check that:
Send a test email or run a test order flow according to the project standard QA process.
After applying the result with Apply Result, the current template version is saved in native Magento fields. This means the next AI request will be based on this version, not on the original template.
You can refine the same template multiple times:
Apply Result.Marketing > Communications > Email Templates.Error Screenshot.Generate with AI after saving.For subsequent revisions, treat AI Prompt as a description of the change to the current version. It is best to specify:
Error Screenshot shows a rendering error, visual layout, responsiveness issue, or validation message.Example prompt for another revision:
Use the current saved template as the base.Fix the spacing issue visible in the attached error screenshot.Keep the current header layout, all Magento variables, and the existing Template Styles structure.Do not redesign the whole email.This workflow is useful when the first version is close to the expected result but requires refinement of details such as spacing, responsiveness, banner visibility, logo position, or button style.
You can repeat this cycle many times. Each new job creates a separate history entry, so you can return to previous prompts, payloads, and AI responses to check which instruction led to a specific change.
The module sends a structured payload to AI. The most important sections are:
Contains the current state of the Magento template:
AI uses this section as the base material for generation.
Important: if an AI result was previously applied using Apply Result, the template section already contains that updated version. This allows the next generation to work as a revision of the current template.
Contains Magento variables and directives detected in the template.
AI should preserve these values and should not invent unsupported variables.
Contains:
technical - global technical prompt from configuration,user - prompt entered in the template editor.The technical prompt protects Magento-specific structure. The user prompt describes the expected result for one template.
Contains optional metadata and content of the uploaded reference design.
The section is empty when no reference file has been uploaded.
Contains an optional screenshot showing current rendering, layout, visual, or validation errors.
This section has a purpose and description so AI knows that the file is used to understand the issue, not as a target design reference.
The section is empty when no screenshot has been uploaded.
For subsequent revisions, it is worth using error_screenshot together with a precise prompt that explains what should be fixed and what should not be changed. This allows AI to fix a specific issue without rebuilding the entire template.
Example: after applying the first AI result, the administrator notices that in Gmail the banner overlaps the order summary section. In the next request, they attach a screenshot of that view and enter a prompt asking only to fix banner spacing and width. The payload still contains the current Template Content and Template Styles, so AI works on the last saved version.
Contains structured image assets saved for the template:
Each asset contains a public media URL, label, alt text, target URL, sort order, and filename.
AI should use these URLs when building HTML and should not invent additional image URLs.
Contains basic store information, such as:
AI can use this to understand the language and context, but it should not receive real customer or order data.
Most likely cause:
Check:
bin/magento queue:consumers:start kowal.ai_email.generate.consumerCheck ACL permissions for:
Kowal_AiEmailThemeGenerator::settingsAfter changing administrator permissions, log out and log back in.
Check:
OpenAI API KeyMake sure the module is enabled and the configuration has been saved in the correct scope.
Check:
Automatically Apply ResultIf the option is set to No, open the job and click:
Apply ResultCheck whether the previous result was applied using:
Apply ResultThe next generation is based on the currently saved Magento template. If the job result has completed status but was not applied, the next job will still be based on the older template version.
The module validates the returned JSON. It may reject the result if:
script tag,Check the error message in the job and retry generation with a clearer prompt.
Recommended initial values:
Enabled = YesRequest Timeout = 120Maximum Retries = 2Automatically Apply Result = NoKeep Request and Response Payloads = Yes for testing, No or limited retention for productionRetention Days = 30Use manual result application until the team is confident that the prompts, selected model, and validation rules produce consistent templates.