Skip to main content
This guide documents the testing routes for generating panchangam messages without sending them via WhatsApp. Use them to:
  • Test panchangam accuracy with different coordinates
  • Validate message formatting and template parameters
  • Debug without touching production webhooks
  • Test with coordinates that have no user in the database
Important: These routes do not send messages via WhatsApp. They only generate and save message data to files.

Overview

All generated messages are saved to logs/generated_whatsapp_messages/ as JSON files containing:
  • Complete panchangam data
  • Template parameters (42 for WhatsApp templates)
  • Formatted message text
  • User/coordinate and template selection info

Message generation routes

1. Generate message for user

Endpoint: GET /test/whatsapp/generate/<phone_number> Generates a panchangam message for an existing user and saves it to a file. Requirements: User must exist with latitude, longitude, and timezone set, and an active subscription.
curl -X GET http://localhost:5050/test/whatsapp/generate/1234567890
Success response includes status, file_path, filename, template_name, user_info, and formatted_message_preview. Errors: “User not found” or “User … missing location data” with details.

2. Generate message from coordinates

Endpoint: POST /test/whatsapp/generate-coords Generates a panchangam from coordinates without requiring a user in the database. Request body:
FieldTypeRequiredDescription
latitudefloatYes-90 to 90
longitudefloatYes-180 to 180
timezonestringYesIANA timezone (e.g. America/Los_Angeles)
datestringNoYYYY-MM-DD (default: current date in timezone)
country_codestringNo”1” for US (dailymessage template), else panchangam_global
curl -X POST http://localhost:5050/test/whatsapp/generate-coords \
  -H "Content-Type: application/json" \
  -d '{
    "latitude": 37.3688,
    "longitude": -122.0363,
    "timezone": "America/Los_Angeles",
    "date": "2025-01-16",
    "country_code": "1"
  }'
Success response includes status, coordinates, file_path, city_info, template_name, and formatted_message_preview. Errors: missing fields, invalid coordinates/date/timezone.

Helper routes

  • GET /test/whatsapp/users — List active users with phone and location data.
  • GET /test/whatsapp/info — Info about WhatsApp message types, templates, and test endpoints.
  • GET /test/country-templates — Test country-based template selection.

Output files

  • User-based: panchangam_{phone_number}_{YYYYMMDD_HHMMSS}.json
  • Coordinate-based: panchangam_coords_{lat}_{lon}_{YYYYMMDD_HHMMSS}.json (dots/neg replaced for filename safety)
Each file contains generated_at, user_info or coordinates, city_info, template_name, template_parameters, panchangam_data, and formatted_message.

Examples

Mumbai:
curl -X POST http://localhost:5050/test/whatsapp/generate-coords \
  -H "Content-Type: application/json" \
  -d '{"latitude": 19.0760, "longitude": 72.8777, "timezone": "Asia/Kolkata", "country_code": "91"}'
London:
curl -X POST http://localhost:5050/test/whatsapp/generate-coords \
  -H "Content-Type: application/json" \
  -d '{"latitude": 51.5074, "longitude": -0.1278, "timezone": "Europe/London"}'
For a user: List users with GET /test/whatsapp/users, then GET /test/whatsapp/generate/<phone_number>.

Template selection

  • US (country_code = “1”): dailymessage (utility)
  • Others: panchangam_global (marketing)

Troubleshooting

  • User not found — Check user exists and phone format.
  • Missing location data — Use the coordinate-based endpoint instead.
  • Invalid timezone — Use IANA names (e.g. America/Los_Angeles, Asia/Kolkata).
  • Invalid date — Use YYYY-MM-DD.
  • Files not appearing — Ensure logs/generated_whatsapp_messages/ exists and check app logs.