-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Goal:
Implement a secure API endpoint to accept prompt submissions originating from the Lullabot Slack bot via the /add-prompt command, as outlined in Lullabot/lullabot-slackbot#71.
Requirements:
- Endpoint:
- Route: Define a suitable route (e.g.,
/api/submit-prompt). - Method: Accept
POSTrequests. - Authentication: Require an
Authorization: Bearer <SHARED_SECRET>header. TheSHARED_SECRETshould be configurable via environment variables for secure deployment.
- Route: Define a suitable route (e.g.,
- Request Payload (JSON):
- Expect a JSON body with the following fields:
content: (string) The full text content of the original Slack message.author: (string) The display name or username of the original Slack message author.invoker: (string) The display name or username of the Slack user who invoked the/add-promptcommand.permalink: (string) The permalink URL to the original Slack message.
- Expect a JSON body with the following fields:
- Core Logic:
- Validate the incoming request (Authentication, presence of required fields).
- Authenticate with the GitHub API using a securely stored token (e.g., a GitHub PAT or GitHub App credential managed within this project's secrets, NOT passed from the Slack bot).
- Create a new issue in this repository (
lullabot/prompt_library).- Title:
New Prompt Submission from Slack: @[Original Slack Author Name](using theauthorfield from the payload). - Body:
[Full text content from payload's `content` field] --- *Metadata:* * Submitted via `/add-prompt` by: @[Invoking Slack User Name] (from `invoker` field) * Original Author: @[Original Slack Author Name] (from `author` field) * Original Slack Message: [Link from `permalink` field] - Labels: Apply default labels like
new-prompt,from-slack(configurable via environment variables if desired).
- Title:
- Response Payload (JSON):
- On successful issue creation: Return status
201 Createdwith JSON body:{ "success": true, "issueUrl": "https://github.com/Lullabot/prompt_library/issues/[new_issue_number]" } - On failure (authentication error, validation error, GitHub API error): Return appropriate error status (e.g.,
400,401,500) with JSON body:{ "success": false, "error": "Descriptive error message" }
- On successful issue creation: Return status
Depends On: Lullabot/lullabot-slackbot#71