How bestony/chatgpt-feishu works
Project Type and Purpose
• This is a lightweight, serverless-style Node.js integration that turns a Feishu bot into a ChatGPT frontend. There is no separate UI: all interaction happens via Feishu messages and webhooks.
• It handles event subscriptions from the Feishu platform, invokes the OpenAI ChatGPT API, then replies back in Feishu.
High-Level Architecture Components
• Feishu Platform (event source & message sink)
• User chat → Feishu message events
• Bot reply endpoint ← Feishu REST API
• AirCode Node.js Runtime (hosted serverless environment)
• event.js – the single entry-point function
• Environment Variables – APPID, SECRET, BOTNAME, KEY
• Dependencies – @larksuiteoapi/node-sdk, axios
• OpenAI API (external LLM service)
Component Relationships and Data Flows
a. Feishu User sends a chat message in a group or 1:1.
b. Feishu Platform pushes an HTTP POST (webhook event) to the deployed AirCode endpoint.
c. event.js:
1. Loads APPID, SECRET, BOTNAME, KEY from env vars.
2. Uses @larksuiteoapi/node-sdk to validate signature and parse the event.
3. Extracts user message content.
4. Calls OpenAI ChatCompletion API via axios, passing the user prompt and KEY.
5. Receives AI response text.
6. Uses @larksuiteoapi/node-sdk client to send a reply message back to Feishu.
d. Feishu Platform delivers the reply into the chat.
Architectural Patterns and Design Principles
• Event-driven, serverless function: single function triggered by HTTP events.
• Separation of concerns:
• Webhook handling and security (Feishu SDK)
• Business logic and prompt orchestration (in event handler)
• External API integration (OpenAI via axios)
• Configuration via environment variables for secrets and bot identity.
• No persistent storage—stateless, each invocation is independent.