Skip to content

federicoiosca87/CRM_TemplatesHandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

99 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CMS Template Generator

A local dashboard tool for converting localized Word documents into CMS-ready template packages.

Use Case

"As a user, I want to upload a ZIP folder of localized content and images into the dashboard, and download 3 separate ZIPs ready for CMS import: one for OMS templates, one for SMS templates, and one for Terms & Conditions."

Problem Solved

Before: Content team manually copies content from Word docs into CMS for each language and template variant. Takes ~1 month per offer type.

After: Upload ZIP + images, configure offer metadata, download 3 CMS-ready packages. Takes ~5 minutes.

Features

  • πŸ“„ Upload localized content - ZIP containing Word documents
  • πŸ–ΌοΈ Upload images - For OMS/CRS templates
  • βš™οΈ Configure offer - Task type, reward type, send conditions, variants
  • πŸ”§ Custom types - Add new task/reward types on the fly
  • πŸ‘οΈ Preview content - Verify extracted content before generating
  • πŸ“₯ Download 3 packages - SMS, OMS (with images), TC - all CMS-ready

Workflow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  1. UPLOAD                                                  β”‚
β”‚  β”œβ”€β”€ ZIP with Word docs ({LANG}_{OfferName}.docx)          β”‚
β”‚  └── Images (PNG, JPG, etc.)                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  2. CONFIGURE (sidebar)                                     β”‚
β”‚  β”œβ”€β”€ Task Type (or custom)                                 β”‚
β”‚  β”œβ”€β”€ Reward Type (or custom)                               β”‚
β”‚  β”œβ”€β”€ Send Conditions                                        β”‚
β”‚  └── Template Variants (A-F)                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  3. PREVIEW                                                 β”‚
β”‚  β”œβ”€β”€ SMS templates per language                            β”‚
β”‚  β”œβ”€β”€ OMS templates per language                            β”‚
β”‚  └── T&Cs                                                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  4. DOWNLOAD                                                β”‚
β”‚  β”œβ”€β”€ πŸ“¦ CampaignWizardSmsTemplate.zip                      β”‚
β”‚  β”œβ”€β”€ πŸ“¦ CampaignWizardOmsTemplate.zip (+ images)           β”‚
β”‚  └── πŸ“¦ CampaignWizardTCTemplate.zip                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Input Format

ZIP file containing Word documents with naming: {LANGUAGE}_{OfferName}.docx

Example:

Bet&Get_CashFreespin.zip
└── Sett. Bet & Cash Free Spins -- 1550/
    β”œβ”€β”€ EN_bet_on_sb_get_CFS.docx
    β”œβ”€β”€ BR_bet_on_sb_get_CFS.docx
    β”œβ”€β”€ ARG_bet_on_sb_get_CFS.docx
    └── ...

Word Document Structure

The parser expects these sections (identified by headings):

Section Content
MY OFFERS Headline, Sub-headline, Task, Reward
LAUNCH OMS Template A/B/C: Title, Body, CTA
REMINDER OMS Template A/B/C: Title, Body, CTA
SMS Template A-F: Body
T&Cs/SIGNIFICANT TERMS SignificantTerms, TermsAndConditions

Output Format

Three CMS-compatible ZIP packages:

  1. MultiMCmsExport_CampaignWizardSmsTemplate_{date}_common_common_all.zip
  2. MultiMCmsExport_CampaignWizardOmsTemplate_{date}_common_common_all.zip
  3. MultiMCmsExport_CampaignWizardTCTemplate_{date}_common_common_all.zip

SMS & TC Structure:

Common/
β”œβ”€β”€ ContentTypeList.txt
β”œβ”€β”€ DocumentTypeList.txt
└── CampaignWizard{Type}Template/
    β”œβ”€β”€ en/
    β”‚   β”œβ”€β”€ ContentList.xml
    β”‚   └── DocumentList.xml
    β”œβ”€β”€ br/
    └── ...

OMS Structure (includes images):

Common/
β”œβ”€β”€ ContentTypeList.txt
β”œβ”€β”€ DocumentTypeList.txt
└── CampaignWizardOmsTemplate/
    β”œβ”€β”€ files/              ← Uploaded images
    β”‚   β”œβ”€β”€ banner.png
    β”‚   └── promo.jpg
    β”œβ”€β”€ en/
    β”‚   β”œβ”€β”€ ContentList.xml
    β”‚   └── DocumentList.xml
    └── ...

Installation

# Navigate to tool directory
cd tools/cms-template-generator

# Create virtual environment (recommended)
python -m venv venv
venv\Scripts\activate  # Windows
# source venv/bin/activate  # Mac/Linux

# Install dependencies
pip install -r requirements.txt

Usage

Local (Python)

# Start the dashboard
streamlit run app.py

The app will open in your browser at http://localhost:8501

Docker

Single-replica requirement: The OAuth PKCE flow stores state in process memory. The app must run as a single replica β€” do not scale horizontally without replacing the in-memory PKCE cache with a shared store. This is enforced in manifest.yaml (replicas: 1).

Build the image:

docker build -t crm-templates-handler .

Run with your local secrets mounted (recommended for local testing):

docker run --rm -p 8501:8080 \
  -v "$(pwd)/.streamlit/secrets.toml:/app/.streamlit/secrets.toml:ro" \
  crm-templates-handler

Open http://localhost:8501.

Note: Streamlit logs port 8080 (the internal container port) in the console β€” ignore it. The app is always accessible on the host port you mapped, 8501 in the command above.

OAuth configuration is resolved automatically from oauth_config.py based on the active environment (ENVIRONMENT env var injected by bego, or APP_ENV for direct Docker builds). The OAUTH_* environment variables shown in older docs are not supported β€” do not pass them to docker run. To use different OAuth settings, update oauth_config.py directly.

Steps:

  1. Configure Offer (sidebar)

    • Select Task Type (or "βž• Custom..." for new types)
    • Select Reward Type (or "βž• Custom..." for new types)
    • Choose Send Conditions (NotOptedIn, JoinedCampaign, etc.)
    • Select Template Variants (A, B, C, D, E, F)
  2. Upload Content

    • Upload ZIP file with Word documents
    • Upload images for OMS/CRS templates (optional)
    • Review the parsed document summary
  3. Preview

    • See uploaded images
    • Select a language to inspect extracted content
    • Verify SMS, OMS, and T&C content
  4. Generate & Download

    • Review configuration summary
    • Click "Generate CMS Packages"
    • Download 3 packages:
      • πŸ“¦ SMS Package
      • πŸ“¦ OMS Package (includes images)
      • πŸ“¦ TC Package
  5. Import to CMS

    • Upload each package to CMS admin interface

Language Mapping

Input (Word) CMS Code(s) Notes
EN en Base English
EN_PE en-pe English (Peru)
ARG es-ar-ba, es-ar-ca, es-ar-co All Argentina regions
BR br Brazilian Portuguese
GR el Greek (different code!)
ET et Estonian
RU_ET ru-ee Russian (Estonia)
... ... See config.py for full list

Configuration

Edit config.py to:

  • Add/modify language mappings
  • Update task types and reward types
  • Adjust template variants
  • Change CMS metadata defaults

Troubleshooting

"No Word documents found in ZIP"

  • Ensure ZIP contains .docx files (not .doc)
  • Check for nested folders in the ZIP

Missing sections in preview

  • Verify Word document has expected section headings (SMS, LAUNCH OMS, etc.)
  • Check for typos in section headers

XML validation errors on CMS import

  • Ensure all required fields have content
  • Check for special characters that need escaping

Files

File Purpose
app.py Streamlit dashboard UI
config.py Configuration (languages, types, metadata)
word_parser.py Word document parsing logic
xml_generator.py CMS XML generation
requirements.txt Python dependencies

Future Improvements

  • CSV input support (alternative to Word docs)
  • Validation rules (SMS character limits, required fields)
  • Direct CMS API integration (skip ZIP download)
  • Template diff viewer (compare with existing CMS content)
  • Batch processing (multiple offer types at once)

About

Repo to host the app to run convert templates for CRS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages