Skip to main content

Generate realistic chat conversation mocks from dict/JSON input

Project description

Dialog Forge

Generate realistic chat conversation mocks from dict/JSON input with platform-specific styling.

Supported Platforms

  • WhatsApp — green bubbles, double-check marks, timestamps
  • Instagram — gradient bubbles, circular avatars, "Seen" labels
  • Facebook Messenger — blue bubbles, rounded UI, delivery indicators

Installation

pip install dialog-forge

# With image export support (PNG/JPG via Playwright)
pip install dialog-forge[export]

Quick Start

from dialog_forge import render_chat

conversation = {
    "platform": "whatsapp",
    "title": "Family Group",
    "participants": {
        "me": {"name": "Alice", "avatar": None},
        "friend": {"name": "Bob", "avatar": None},
    },
    "messages": [
        {
            "sender": "friend",
            "text": "Hey! Are you coming tonight?",
            "timestamp": "18:30",
            "status": "read",
        },
        {
            "sender": "me",
            "text": "Yes! On my way 🚗",
            "timestamp": "18:32",
            "status": "delivered",
        },
    ],
}

# Get HTML string
html = render_chat(conversation)

# Get PNG bytes
png_bytes = render_chat(conversation, format="png")

# Debug mode — prints the intermediate HTML path
html_debug = render_chat(conversation, format="png", debug=True)

API

render_chat(data, format="html", debug=False)

Parameter Type Default Description
data dict Conversation data (see schema below)
format str "html" Output format: "html", "png", or "jpg"
debug bool False When True, saves intermediate HTML to a temp file and prints its path

Returns: str (HTML) or bytes (image data)

Conversation Schema

{
  "platform": "whatsapp | instagram | facebook",
  "title": "Chat Title",
  "participants": {
    "sender_id": {
      "name": "Display Name",
      "avatar": "https://url-to-avatar.png (optional)",
      "gender": "male | female (optional)"
    }
  },
  "messages": [
    {
      "sender": "sender_id",
      "text": "Message content",
      "timestamp": "HH:MM",
      "status": "sent | delivered | read",
      "type": "text"
    }
  ]
}

Adding a New Platform

  1. Create src/dialog_forge/platforms/your_platform.py
  2. Subclass BaseRenderer and implement render(conversation) -> str
  3. Register it in src/dialog_forge/platforms/__init__.py

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dialog_forge-0.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dialog_forge-0.1.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file dialog_forge-0.1.0.tar.gz.

File metadata

  • Download URL: dialog_forge-0.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for dialog_forge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 87652903c33f2a0f815434906c6c378de1960add69465915d8ff6ebf1371510a
MD5 cf7d74e26c0d8c3d60c9428f26d6720f
BLAKE2b-256 54fcf29765cbbad8aa0d199f0fd4282def34de8824f11f4d54cbb4451fef7893

See more details on using hashes here.

File details

Details for the file dialog_forge-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dialog_forge-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for dialog_forge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21d4eab84af549bd6b6482e884aa5505f5e67916f21809ad87e291858d8bcca7
MD5 e329efa07a07235e0a1085d1bd5cd369
BLAKE2b-256 400c163ddbe1dd957b648956078031097f544d5214d650018c7441e05919a9bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page