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

Implement Discord API Server Integration #1956

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from

Conversation

berrytern
Copy link
Collaborator

Description:

This pull request implements an API server for Discord communication, enabling internal component interactions through various key functionalities:

  1. Sending Messages: Endpoints for sending messages directly through Discord.
  2. Sending Files: Functionality to send files via Discord.
  3. Receiving Messages and Files: Endpoints to receive messages and files from Discord.
  4. Listening for New Messages: An endpoint to listen for new messages from Discord.
  5. Listening for Mentions: An endpoint that waits for new mentions.
  6. Answering in Threads: An endpoint that listens to messages and responds in the same thread.
  7. Emoji Reaction Add and Remove: An endpoint to add and remove reactions using Discord.

The implementation separates the Discord functionalities into a distinct Docker image (approximately 300 MB) built using multi-stage builds. We recommend reviewing this approach for potential implementation in the Langflow Dockerfile, for example. The solution is ready for use, and the components to interact with Discord are already available in the store.

berrytern and others added 12 commits May 12, 2024 07:57
…rd webhook service.

# Aider chat conversation:

USER: I need you to update my docker-compose.yml to also run my discord webhook that was set, the discord runs at 7880

ASSISTANT: Here are the diffs for the changes to the `docker-compose.yml` file to include the Discord webhook service running at port 7880:

```diff
--- docker-compose.yml
+++ docker-compose.yml
@@ ... @@
   backend:
     build:
       context: ./
       dockerfile: ./dev.Dockerfile
     env_file:
       - .env
     ports:
       - "7860:7860"
+      - "7880:7880"
     volumes:
       - ./:/app
     command: bash -c "uvicorn --factory langflow.main:create_app --host 0.0.0.0 --port 7860 --reload --loop asyncio"
     networks:
       - langflow
```

This change adds the port `7880` to the `ports` section of the `backend` service in your `docker-compose.yml`, allowing the Discord webhook to be accessible externally on port `7880`.
…n port 7880 in the background when executing `docker-compose up --build`.

# Aider chat conversation:

USER: THis way it will be already running int he background when I do docker compose up --build ? if not do it this way

ASSISTANT: To ensure that the Discord service runs in the background when you execute `docker-compose up --build`, I will modify the `docker-compose.yml` file to include the necessary configuration for the Discord service. This will involve setting up a separate service within the Docker Compose configuration that specifically handles the Discord functionality on port 7880.

Here are the diffs for the changes to the `docker-compose.yml` file:

```diff
--- docker-compose.yml
+++ docker-compose.yml
@@ ... @@
   backend:
     build:
       context: ./
       dockerfile: ./dev.Dockerfile
     env_file:
       - .env
     ports:
       - "7860:7860"
     volumes:
       - ./:/app
     command: bash -c "uvicorn --factory langflow.main:create_app --host 0.0.0.0 --port 7860 --reload --loop asyncio"
     networks:
       - langflow
+  discord:
+    build:
+      context: ./
+      dockerfile: ./dev.Dockerfile
+    env_file:
+      - .env
+    ports:
+      - "7880:7880"
+    volumes:
+      - ./:/app
+    command: bash -c "uvicorn --factory langflow.main:create_discord_app --host 0.0.0.0 --port 7880 --reload --loop asyncio"
+    networks:
+      - langflow
```

This change adds a new service named `discord` to the `docker-compose.yml` file. It uses the same Dockerfile and environment file as the `backend` service but runs a different command to start the Discord application on port 7880. This ensures that both the main application and the Discord service are up and running when you build and run the Docker Compose setup.
<fix> sharing /temp folder between discord and backend
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label May 23, 2024
Copy link

vercel bot commented May 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langflow ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2024 5:28am

import sys
import aiohttp

with open(file_path, "rb") as file:

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
random_string = "".join(random.choice(characters) for _ in range(64))
waveform = base64.b64encode(random_string.encode("utf-8")).decode("utf-8")
url = f"https://discord.com/api/v9/channels/{channel_id}/attachments"
with open(file_path, "rb") as file:

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants