Skip to content

Conversation

@rakshabesafe
Copy link
Owner

This commit introduces an autoreply feature for WhatsApp messages.

Key changes:

  1. Database Schema:

    • Added last_sent_at (TIMESTAMP) column to the autoreplies table to track the last time an autoreply was sent.
    • Updated migrations.go to include this new column.
  2. API Endpoints & Handlers:

    • Added a new GET /chat/autoreply endpoint to list all configured autoreplies for you.
    • Created GetAutoReplies handler in handlers.go.
    • Modified AddAutoReply in handlers.go to initialize last_sent_at to NULL.
    • Updated routes.go to map the new GET endpoint.
  3. Autoreply Logic:

    • Implemented the core autoreply logic in wmiau.go within the myEventHandler.
    • When a message is received, the system checks if an autoreply rule exists for the sender.
    • An autoreply is sent if a rule exists and if no reply has been sent to that number in the last 5 minutes.
    • The last_sent_at timestamp is updated after an autoreply is sent.
  4. API Documentation:

    • Updated static/api/spec.yml to include the new GET /chat/autoreply endpoint and its response schema (AutoReplyEntry).

This feature allows you to configure automatic replies to incoming messages with a 5-minute cooldown period per recipient.

This commit introduces an autoreply feature for WhatsApp messages.

Key changes:

1.  **Database Schema:**
    *   Added `last_sent_at` (TIMESTAMP) column to the `autoreplies` table to track the last time an autoreply was sent.
    *   Updated `migrations.go` to include this new column.

2.  **API Endpoints & Handlers:**
    *   Added a new `GET /chat/autoreply` endpoint to list all configured autoreplies for you.
    *   Created `GetAutoReplies` handler in `handlers.go`.
    *   Modified `AddAutoReply` in `handlers.go` to initialize `last_sent_at` to NULL.
    *   Updated `routes.go` to map the new GET endpoint.

3.  **Autoreply Logic:**
    *   Implemented the core autoreply logic in `wmiau.go` within the `myEventHandler`.
    *   When a message is received, the system checks if an autoreply rule exists for the sender.
    *   An autoreply is sent if a rule exists and if no reply has been sent to that number in the last 5 minutes.
    *   The `last_sent_at` timestamp is updated after an autoreply is sent.

4.  **API Documentation:**
    *   Updated `static/api/spec.yml` to include the new `GET /chat/autoreply` endpoint and its response schema (`AutoReplyEntry`).

This feature allows you to configure automatic replies to incoming messages with a 5-minute cooldown period per recipient.
@rakshabesafe rakshabesafe merged commit 4935c8a into main May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants