Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messaging API #17

Open
3 of 27 tasks
luandro opened this issue Nov 23, 2024 · 0 comments · May be fixed by #24
Open
3 of 27 tasks

Messaging API #17

luandro opened this issue Nov 23, 2024 · 0 comments · May be fixed by #24
Assignees
Labels
feature New feature
Milestone

Comments

@luandro
Copy link
Contributor

luandro commented Nov 23, 2024

Create a Messaging API that unifies communication with the Simulator, WhatsApp, and Telegram into a single, flexible API. This API will act as a central hub for handling incoming and outgoing messages, seamlessly integrating with Trigger.dev and Supabase to manage message processing and storage.

The workflow ensures:

  • Incoming messages are saved to the receivedMessages DB.
  • Responses are generated by the Plugin API.
  • Outgoing messages are saved to the toSendMessages DB and sent back via the API.
  • A cyclic design for managing multi-turn conversations effectively.

Tasks

  1. API Design

    • Define API endpoints for sending and receiving messages:
      • POST /api/messages/send
      • GET /api/messages/receive
      • GET /api/messages/health
    • Unify Simulator, WhatsApp, and Telegram as part of a single Messaging API.
  2. Integration with Trigger.dev and Supabase

    • Trigger.dev:
      • Save incoming messages to the receivedMessages DB.
      • Call the Plugin API to process and generate responses.
      • Save outgoing responses to the toSendMessages DB.
    • Supabase:
      • Set up the receivedMessages DB for storing incoming messages.
      • Set up the toSendMessages DB for tracking outgoing messages.
  3. Platform Integrations

    • Simulator:
    • WhatsApp:
      • Use WhatsApp Web JS or equivalent library for integration.
      • Support sending and receiving text, images, and other formats.
    • Telegram:
      • Use telegraf or equivalent library for integration.
      • Support sending and receiving text, images, and other formats.
  4. Message Processing

    • Develop a cyclic message-handling workflow:
      • Incoming messages → Trigger.devPlugin API → Outgoing responses.
      • Ensure responses are routed back to the Messaging API for delivery.
    • Implement robust error handling for message failures or delays.
  5. Testing

    • Test the unified API with all platforms (Simulator, WhatsApp, Telegram).
    • Validate that responses follow a cyclic workflow and maintain consistency.
    • Ensure edge cases (e.g., failed deliveries, duplicate messages) are handled effectively.
  6. Documentation

    • Write detailed documentation for:
      • API endpoints and usage.
      • Setting up integrations with platforms.
      • Configuring Trigger.dev and Supabase.
      • Workflow overview with examples.

Acceptance Criteria

  • The Messaging API integrates seamlessly with Trigger.dev, Supabase, and platforms.
  • Incoming and outgoing messages follow the cyclic workflow effectively.
  • Error handling and retry mechanisms are robust and operational.
  • Comprehensive documentation covers API usage and platform setup.

Workflow

flowchart TB
    subgraph MessagingAPI["Messaging API"]
        Input["Incoming Message (Simulator, WhatsApp, Telegram)"]
        Output["Outgoing Message"]
    end

    Input --> ThriggerReceived["Trigger.dev:
        - Save to receivedMessages DB
        - Call AI API"]

    ThriggerReceived --> ReceivedDB["Supabase: receivedMessages DB"]

    ThriggerReceived --> AIAPI["Plugin API:
        - Analyze Message
        - Generate Response"]

    AIAPI --> ThriggerSend["Trigger.dev:
        - Save to toSendMessages DB
        - Route Response"]

    ThriggerSend --> ToSendDB["Supabase: toSendMessages DB"]
    ThriggerSend --> Output
    Output --> Input
Loading
@luandro luandro added the feature New feature label Nov 23, 2024
@luandro luandro added this to the MVP milestone Nov 23, 2024
@luandro luandro moved this to In Progress in Earth Defenders Assistant Nov 23, 2024
@luandro luandro linked a pull request Dec 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants