Quellcode durchsuchen

[Example] add example for nextjs app and discord/slack bots (#1111)

Co-authored-by: Deven Patel <deven298@yahoo.com>
Deven Patel vor 1 Jahr
Ursprung
Commit
99261e5fb5

+ 124 - 0
docs/examples/nextjs-assistant.mdx

@@ -0,0 +1,124 @@
+Fork the Embedchain repo on [Github](https://github.com/embedchain/embedchain) to create your own NextJS discord and slack bot powered by Embedchain.
+
+If you run into problems with forking, please refer to [github docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) for forking a repo.
+
+We will work from the `examples/nextjs` folder so change your current working directory by running the command - `cd <your_forked_repo>/examples/nextjs`
+
+# Installation
+
+First, lets start by install all the required packages and dependencies.
+
+- Install all the required python packages by running ```pip install -r requirements.txt```
+
+- We will use [Fly.io](https://fly.io/) to deploy our embedchain app, discord and slack bot. Follow the step one to install [Fly.io CLI](https://docs.embedchain.ai/deployment/fly_io#step-1-install-flyctl-command-line)
+
+# Developement
+
+## Embedchain App
+
+First, we need an Embedchain app powered with the knowledge of NextJS. We have already created an embedchain app using FastAPI in `ec_app` folder for you. Feel free to ingest data of your choice to power the App.
+
+<Note>
+Navigate to `ec_app` folder and create `.env` file in this folder and set your OpenAI API key as shown in `.env.example` file. If you want to use other open-source models, feel free to use the app config in `app.py`. More details for using custom configuration for Embedchain app is [available here](https://docs.embedchain.ai/api-reference/advanced/configuration).
+</Note>
+
+Before running the ec commands to develope the app, open `fly.toml` file and update the `name` variable to something unique. This is important as `fly.io` requires users to provide a globally unique deployment app names.
+
+Now, we need to launch this application with fly.io. You can see your app on [fly.io dashboard](https://fly.io/dashboard). Run the following command to launch your app on fly.io:
+```bash
+fly launch --no-deploy
+```
+
+To run the app in development, run the following command:
+
+```bash
+ec dev
+```
+
+Run `ec deploy` to deploy your app on Fly.io. Once you deploy your app, save the endpoint on which our discord and slack bot will send requests.
+
+
+## Discord bot
+
+For discord bot, you will need to create the bot on discord developer portal and get the discord bot token and your discord bot name.
+
+While keeping in mind the following note, create the discord bot by following the instructions from our [discord bot docs](https://docs.embedchain.ai/examples/discord_bot) and get discord bot token.
+
+<Note>
+You do not need to set `OPENAI_API_KEY` to run this discord bot. Follow the remaining instructions to create a discord bot app. We recommend you to give the following sets of bot permissions to run the discord bot without errors:
+
+```
+(General Permissions)
+Read Message/View Channels
+
+(Text Permissions)
+Send Messages
+Create Public Thread
+Create Private Thread
+Send Messages in Thread
+Manage Threads
+Embed Links
+Read Message History
+```
+</Note>
+
+Once you have your discord bot token and discord app name. Navigate to `nextjs_discord` folder and create `.env` file and define your discord bot token, discord bot name and endpoint of your embedchain app as shown in `.env.example` file.
+
+To run the app in development:
+
+```bash
+python app.py
+```
+
+Before deploying the app, open `fly.toml` file and update the `name` variable to something unique. This is important as `fly.io` requires users to provide a globally unique deployment app names.
+
+Now, we need to launch this application with fly.io. You can see your app on [fly.io dashboard](https://fly.io/dashboard). Run the following command to launch your app on fly.io:
+```bash
+fly launch --no-deploy
+```
+
+Run `ec deploy` to deploy your app on Fly.io. Once you deploy your app, your discord bot will be live!
+
+
+## Slack bot
+
+For Slack bot, you will need to create the bot on slack developer portal and get the slack bot token and slack app token.
+
+### Setup
+
+- Create a workspace on Slack if you don't have one already by clicking [here](https://slack.com/intl/en-in/).
+- Create a new App on your Slack account by going [here](https://api.slack.com/apps).
+- Select `From Scratch`, then enter the Bot Name and select your workspace.
+- Go to `App Credentials` section on the `Basic Information` tab from the left sidebar, create your app token and save it in your `.env` file as `SLACK_APP_TOKEN`.
+- Go to `Socket Mode` tab from the left sidebar and enable the socket mode to listen to slack message from your workspace.
+- (Optional) Under the `App Home` tab you can change your App display name and default name.
+- Navigate to `Event Subscription` tab, and enable the event subscription so that we can listen to slack events.
+- Once you enable the event subscription, you will need to subscribe to bot events to authorize the bot to listen to app mention events of the bot. Do that by tapping on `Add Bot User Event` button and select `app_mention`.
+- On the left Sidebar, go to `OAuth and Permissions` and add the following scopes under `Bot Token Scopes`:
+```text
+app_mentions:read
+channels:history
+channels:read
+chat:write
+emoji:read
+reactions:write
+reactions:read
+```
+- Now select the option `Install to Workspace` and after it's done, copy the `Bot User OAuth Token` and set it in your `.env` file as `SLACK_BOT_TOKEN`.
+
+Once you have your slack bot token and slack app token. Navigate to `nextjs_slack` folder and create `.env` file and define your slack bot token, slack app token and endpoint of your embedchain app as shown in `.env.example` file.
+
+To run the app in development:
+
+```bash
+python app.py
+```
+
+Before deploying the app, open `fly.toml` file and update the `name` variable to something unique. This is important as `fly.io` requires users to provide a globally unique deployment app names.
+
+Now, we need to launch this application with fly.io. You can see your app on [fly.io dashboard](https://fly.io/dashboard). Run the following command to launch your app on fly.io:
+```bash
+fly launch --no-deploy
+```
+
+Run `ec deploy` to deploy your app on Fly.io. Once you deploy your app, your slack bot will be live!

+ 2 - 1
docs/mint.json

@@ -174,7 +174,8 @@
         },
         "examples/full_stack",
         "examples/openai-assistant",
-        "examples/opensource-assistant"
+        "examples/opensource-assistant",
+        "examples/nextjs-assistant"
       ]
     },
     {

+ 129 - 0
examples/nextjs/README.md

@@ -0,0 +1,129 @@
+Fork this repo on [Github](https://github.com/embedchain/embedchain) to create your own NextJS discord and slack bot powered by Embedchain app.
+
+If you run into problems with forking, please refer to [github docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) for forking a repo.
+
+We will work from the examples/nextjs folder so change your current working directory by running the command - `cd <your_forked_repo>/examples/nextjs`
+
+# Installation
+
+First, lets start by install all the required packages and dependencies.
+
+- Install all the required python packages by running `pip install -r requirements.txt`.
+
+- We will use [Fly.io](https://fly.io/) to deploy our embedchain app and discord/slack bot. Follow the step one to install [Fly.io CLI](https://docs.embedchain.ai/deployment/fly_io#step-1-install-flyctl-command-line)
+
+# Developement
+
+## Embedchain App
+
+First, lets get started by creating an Embedchain app powered with the knowledge of NextJS. We have already created an embedchain app using FastAPI in `ec_app` folder for you. Feel free to ingest data of your choice to power the App.
+
+---
+**NOTE**
+
+Create `.env` file in this folder and set your OpenAI API key as shown in `.env.example` file. If you want to use other open-source models, feel free to change the app config in `app.py`. More details for using custom configuration for Embedchain app is [available here](https://docs.embedchain.ai/api-reference/advanced/configuration).
+
+---
+
+Before running the ec commands to develope/deploy the app, open `fly.toml` file and update the `name` variable to something unique. This is important as `fly.io` requires users to provide a globally unique deployment app names.
+
+Now, we need to launch this application with fly.io. You can see your app on [fly.io dashboard](https://fly.io/dashboard). Run the following command to launch your app on fly.io:
+```bash
+fly launch --no-deploy
+```
+
+To run the app in development:
+
+```bash
+ec dev  #To run the app in development environment
+```
+
+Run `ec deploy` to deploy your app on Fly.io. Once you deploy your app, save the endpoint on which our discord and slack bot will send requests.
+
+
+## Discord bot
+
+For discord bot, you will need to create the bot on discord developer portal and get the discord bot token and your discord bot name.
+
+While keeping in mind the following note, create the discord bot by following the instructions from our [discord bot docs](https://docs.embedchain.ai/examples/discord_bot) and get discord bot token.
+
+---
+**NOTE**
+
+You do not need to set `OPENAI_API_KEY` to run this discord bot. Follow the remaining instructions to create a discord bot app. We recommend you to give the following sets of bot permissions to run the discord bot without errors:
+
+```
+(General Permissions)
+Read Message/View Channels
+
+(Text Permissions)
+Send Messages
+Create Public Thread
+Create Private Thread
+Send Messages in Thread
+Manage Threads
+Embed Links
+Read Message History
+```
+---
+
+Once you have your discord bot token and discord app name. Navigate to `nextjs_discord` folder and create `.env` file and define your discord bot token, discord bot name and endpoint of your embedchain app as shown in `.env.example` file.
+
+To run the app in development:
+
+```bash
+python app.py  #To run the app in development environment
+```
+
+Before deploying the app, open `fly.toml` file and update the `name` variable to something unique. This is important as `fly.io` requires users to provide a globally unique deployment app names.
+
+Now, we need to launch this application with fly.io. You can see your app on [fly.io dashboard](https://fly.io/dashboard). Run the following command to launch your app on fly.io:
+```bash
+fly launch --no-deploy
+```
+
+Run `ec deploy` to deploy your app on Fly.io. Once you deploy your app, your discord bot will be live!
+
+
+## Slack bot
+
+For Slack bot, you will need to create the bot on slack developer portal and get the slack bot token and slack app token.
+
+### Setup
+
+- Create a workspace on Slack if you don't have one already by clicking [here](https://slack.com/intl/en-in/).
+- Create a new App on your Slack account by going [here](https://api.slack.com/apps).
+- Select `From Scratch`, then enter the Bot Name and select your workspace.
+- Go to `App Credentials` section on the `Basic Information` tab from the left sidebar, create your app token and save it in your `.env` file as `SLACK_APP_TOKEN`.
+- Go to `Socket Mode` tab from the left sidebar and enable the socket mode to listen to slack message from your workspace.
+- (Optional) Under the `App Home` tab you can change your App display name and default name.
+- Navigate to `Event Subscription` tab, and enable the event subscription so that we can listen to slack events.
+- Once you enable the event subscription, you will need to subscribe to bot events to authorize the bot to listen to app mention events of the bot. Do that by tapping on `Add Bot User Event` button and select `app_mention`.
+- On the left Sidebar, go to `OAuth and Permissions` and add the following scopes under `Bot Token Scopes`:
+```text
+app_mentions:read
+channels:history
+channels:read
+chat:write
+emoji:read
+reactions:write
+reactions:read
+```
+- Now select the option `Install to Workspace` and after it's done, copy the `Bot User OAuth Token` and set it in your `.env` file as `SLACK_BOT_TOKEN`.
+
+Once you have your slack bot token and slack app token. Navigate to `nextjs_slack` folder and create `.env` file and define your slack bot token, slack app token and endpoint of your embedchain app as shown in `.env.example` file.
+
+To run the app in development:
+
+```bash
+python app.py  #To run the app in development environment
+```
+
+Before deploying the app, open `fly.toml` file and update the `name` variable to something unique. This is important as `fly.io` requires users to provide a globally unique deployment app names.
+
+Now, we need to launch this application with fly.io. You can see your app on [fly.io dashboard](https://fly.io/dashboard). Run the following command to launch your app on fly.io:
+```bash
+fly launch --no-deploy
+```
+
+Run `ec deploy` to deploy your app on Fly.io. Once you deploy your app, your slack bot will be live!

+ 1 - 0
examples/nextjs/ec_app/.dockerignore

@@ -0,0 +1 @@
+db/

+ 1 - 0
examples/nextjs/ec_app/.env.example

@@ -0,0 +1 @@
+OPENAI_API_KEY=sk-xxx

+ 13 - 0
examples/nextjs/ec_app/Dockerfile

@@ -0,0 +1,13 @@
+FROM python:3.11-slim
+
+WORKDIR /app
+
+COPY requirements.txt /app/
+
+RUN pip install -r requirements.txt
+
+COPY . /app
+
+EXPOSE 8080
+
+CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]

+ 56 - 0
examples/nextjs/ec_app/app.py

@@ -0,0 +1,56 @@
+from dotenv import load_dotenv
+from fastapi import FastAPI, responses
+from pydantic import BaseModel
+
+from embedchain import App
+
+load_dotenv(".env")
+
+app = FastAPI(title="Embedchain FastAPI App")
+embedchain_app = App()
+
+
+class SourceModel(BaseModel):
+    source: str
+
+
+class QuestionModel(BaseModel):
+    question: str
+
+
+@app.post("/add")
+async def add_source(source_model: SourceModel):
+    """
+    Adds a new source to the EmbedChain app.
+    Expects a JSON with a "source" key.
+    """
+    source = source_model.source
+    embedchain_app.add(source)
+    return {"message": f"Source '{source}' added successfully."}
+
+
+@app.post("/query")
+async def handle_query(question_model: QuestionModel):
+    """
+    Handles a query to the EmbedChain app.
+    Expects a JSON with a "question" key.
+    """
+    question = question_model.question
+    answer = embedchain_app.query(question)
+    return {"answer": answer}
+
+
+@app.post("/chat")
+async def handle_chat(question_model: QuestionModel):
+    """
+    Handles a chat request to the EmbedChain app.
+    Expects a JSON with a "question" key.
+    """
+    question = question_model.question
+    response = embedchain_app.chat(question)
+    return {"response": response}
+
+
+@app.get("/")
+async def root():
+    return responses.RedirectResponse(url="/docs")

+ 3 - 0
examples/nextjs/ec_app/embedchain.json

@@ -0,0 +1,3 @@
+{
+    "provider": "fly.io"
+}

+ 22 - 0
examples/nextjs/ec_app/fly.toml

@@ -0,0 +1,22 @@
+# fly.toml app configuration file generated for ec-app-crimson-dew-123 on 2024-01-04T06:48:40+05:30
+#
+# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
+#
+
+app = "ec-app-crimson-dew-123"
+primary_region = "sjc"
+
+[build]
+
+[http_service]
+  internal_port = 8080
+  force_https = true
+  auto_stop_machines = false
+  auto_start_machines = true
+  min_machines_running = 0
+  processes = ["app"]
+
+[[vm]]
+  cpu_kind = "shared"
+  cpus = 1
+  memory_mb = 1024

+ 4 - 0
examples/nextjs/ec_app/requirements.txt

@@ -0,0 +1,4 @@
+fastapi==0.104.0
+uvicorn==0.23.2
+embedchain
+beautifulsoup4

+ 1 - 0
examples/nextjs/nextjs_discord/.dockerignore

@@ -0,0 +1 @@
+db/

+ 3 - 0
examples/nextjs/nextjs_discord/.env.example

@@ -0,0 +1,3 @@
+DISCORD_BOT_TOKEN=xxxx
+DISCORD_BOT_NAME=your_bot_name
+EC_APP_URL=your_embedchain_app_url

+ 11 - 0
examples/nextjs/nextjs_discord/Dockerfile

@@ -0,0 +1,11 @@
+FROM python:3.11-slim
+
+WORKDIR /app
+
+COPY requirements.txt /app
+
+RUN pip install -r requirements.txt
+
+COPY . /app
+
+CMD ["python", "app.py"]

+ 109 - 0
examples/nextjs/nextjs_discord/app.py

@@ -0,0 +1,109 @@
+import logging
+import os
+
+import discord
+import dotenv
+import requests
+
+dotenv.load_dotenv(".env")
+
+intents = discord.Intents.default()
+intents.message_content = True
+client = discord.Client(intents=intents)
+discord_bot_name = os.environ["DISCORD_BOT_NAME"]
+
+
+class NextJSBot:
+    def __init__(self) -> None:
+        logging.info("NextJS Bot powered with embedchain.")
+
+    def add(self, _):
+        raise ValueError("Add is not implemented yet")
+
+    def query(self, message, citations: bool = False):
+        url = os.environ["EC_APP_URL"] + "/query"
+        payload = {
+            "question": message,
+            "citations": citations,
+        }
+        try:
+            response = requests.request("POST", url, json=payload)
+            try:
+                response = response.json()
+            except Exception:
+                logging.error(f"Failed to parse response: {response}")
+                response = {}
+            return response
+        except Exception:
+            logging.exception(f"Failed to query {message}.")
+            response = "An error occurred. Please try again!"
+        return response
+
+    def start(self):
+        discord_token = os.environ["DISCORD_BOT_TOKEN"]
+        client.run(discord_token)
+
+
+NEXTJS_BOT = NextJSBot()
+
+
+@client.event
+async def on_ready():
+    logging.info(f"User {client.user.name} logged in with id: {client.user.id}!")
+
+
+def _get_question(message):
+    user_ids = message.raw_mentions
+    if len(user_ids) > 0:
+        for user_id in user_ids:
+            # remove mentions from message
+            question = message.content.replace(f"<@{user_id}>", "").strip()
+    return question
+
+
+async def answer_query(message):
+    if (
+        message.channel.type == discord.ChannelType.public_thread
+        or message.channel.type == discord.ChannelType.private_thread
+    ):
+        await message.channel.send(
+            "🧵 Currently, we don't support answering questions in threads. Could you please send your message in the channel for a swift response? Appreciate your understanding! 🚀"  # noqa: E501
+        )
+        return
+
+    question = _get_question(message)
+    print("Answering question: ", question)
+    thread = await message.create_thread(name=question)
+    await thread.send("🎭 Putting on my thinking cap, brb with an epic response!")
+    response = NEXTJS_BOT.query(question, citations=True)
+
+    default_answer = "Sorry, I don't know the answer to that question. Please refer to the documentation.\nhttps://nextjs.org/docs"  # noqa: E501
+    answer = response.get("answer", default_answer)
+
+    contexts = response.get("contexts", [])
+    if contexts:
+        sources = list(set(map(lambda x: x[1]["url"], contexts)))
+        answer += "\n\n**Sources**:\n"
+        for i, source in enumerate(sources):
+            answer += f"- {source}\n"
+
+    sent_message = await thread.send(answer)
+    await sent_message.add_reaction("😮")
+    await sent_message.add_reaction("👍")
+    await sent_message.add_reaction("❤️")
+    await sent_message.add_reaction("👎")
+
+
+@client.event
+async def on_message(message):
+    mentions = message.mentions
+    if len(mentions) > 0 and any([user.bot and user.name == discord_bot_name for user in mentions]):
+        await answer_query(message)
+
+
+def start_bot():
+    NEXTJS_BOT.start()
+
+
+if __name__ == "__main__":
+    start_bot()

+ 3 - 0
examples/nextjs/nextjs_discord/embedchain.json

@@ -0,0 +1,3 @@
+{
+    "provider": "fly.io"
+}

+ 22 - 0
examples/nextjs/nextjs_discord/fly.toml

@@ -0,0 +1,22 @@
+# fly.toml app configuration file generated for nextjs-discord on 2024-01-04T06:56:01+05:30
+#
+# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
+#
+
+app = "nextjs-discord"
+primary_region = "sjc"
+
+[build]
+
+[http_service]
+  internal_port = 8080
+  force_https = true
+  auto_stop_machines = true
+  auto_start_machines = true
+  min_machines_running = 0
+  processes = ["app"]
+
+[[vm]]
+  cpu_kind = "shared"
+  cpus = 1
+  memory_mb = 1024

+ 4 - 0
examples/nextjs/nextjs_discord/requirements.txt

@@ -0,0 +1,4 @@
+fastapi==0.104.0
+uvicorn==0.23.2
+embedchain
+beautifulsoup4

+ 1 - 0
examples/nextjs/nextjs_slack/.dockerignore

@@ -0,0 +1 @@
+db/

+ 3 - 0
examples/nextjs/nextjs_slack/.env.example

@@ -0,0 +1,3 @@
+SLACK_APP_TOKEN=xapp-xxxx
+SLACK_BOT_TOKEN=xoxb-xxxx
+EC_APP_URL=your_embedchain_app_url

+ 11 - 0
examples/nextjs/nextjs_slack/Dockerfile

@@ -0,0 +1,11 @@
+FROM python:3.11-slim
+
+WORKDIR /app
+
+COPY requirements.txt /app
+
+RUN pip install -r requirements.txt
+
+COPY . /app
+
+CMD ["python", "app.py"]

+ 122 - 0
examples/nextjs/nextjs_slack/app.py

@@ -0,0 +1,122 @@
+import logging
+import os
+import re
+
+import requests
+from dotenv import load_dotenv
+from slack_bolt import App as SlackApp
+from slack_bolt.adapter.socket_mode import SocketModeHandler
+
+load_dotenv(".env")
+
+
+def remove_mentions(message):
+    mention_pattern = re.compile(r"<@[^>]+>")
+    cleaned_message = re.sub(mention_pattern, "", message)
+    cleaned_message.strip()
+    return cleaned_message
+
+
+class SlackBotApp:
+    def __init__(self) -> None:
+        logging.info("Slack Bot using Embedchain!")
+
+    def add(self, _):
+        raise ValueError("Add is not implemented yet")
+
+    def query(self, query, citations: bool = False):
+        url = os.environ["EC_APP_URL"] + "/query"
+        payload = {
+            "question": query,
+            "citations": citations,
+        }
+        try:
+            response = requests.request("POST", url, json=payload)
+            try:
+                response = response.json()
+            except Exception:
+                logging.error(f"Failed to parse response: {response}")
+                response = {}
+            return response
+        except Exception:
+            logging.exception(f"Failed to query {query}.")
+            response = "An error occurred. Please try again!"
+        return response
+
+
+SLACK_APP_TOKEN = os.environ["SLACK_APP_TOKEN"]
+SLACK_BOT_TOKEN = os.environ["SLACK_BOT_TOKEN"]
+
+slack_app = SlackApp(token=SLACK_BOT_TOKEN)
+slack_bot = SlackBotApp()
+
+
+@slack_app.event("message")
+def app_message_handler(message, say):
+    pass
+
+
+@slack_app.event("app_mention")
+def app_mention_handler(body, say, client):
+    # Get the timestamp of the original message to reply in the thread
+    if "thread_ts" in body["event"]:
+        # thread is already created
+        thread_ts = body["event"]["thread_ts"]
+        say(
+            text="🧵 Currently, we don't support answering questions in threads. Could you please send your message in the channel for a swift response? Appreciate your understanding! 🚀",  # noqa: E501
+            thread_ts=thread_ts,
+        )
+        return
+
+    thread_ts = body["event"]["ts"]
+    say(
+        text="🎭 Putting on my thinking cap, brb with an epic response!",
+        thread_ts=thread_ts,
+    )
+    query = body["event"]["text"]
+    question = remove_mentions(query)
+    print("Asking question: ", question)
+    response = slack_bot.query(question, citations=True)
+    default_answer = "Sorry, I don't know the answer to that question. Please refer to the documentation.\nhttps://nextjs.org/docs"  # noqa: E501
+    answer = response.get("answer", default_answer)
+    contexts = response.get("contexts", [])
+    if contexts:
+        sources = list(set(map(lambda x: x[1]["url"], contexts)))
+        answer += "\n\n*Sources*:\n"
+        for i, source in enumerate(sources):
+            answer += f"- {source}\n"
+
+    print("Sending answer: ", answer)
+    result = say(text=answer, thread_ts=thread_ts)
+    if result["ok"]:
+        channel = result["channel"]
+        timestamp = result["ts"]
+        client.reactions_add(
+            channel=channel,
+            name="open_mouth",
+            timestamp=timestamp,
+        )
+        client.reactions_add(
+            channel=channel,
+            name="thumbsup",
+            timestamp=timestamp,
+        )
+        client.reactions_add(
+            channel=channel,
+            name="heart",
+            timestamp=timestamp,
+        )
+        client.reactions_add(
+            channel=channel,
+            name="thumbsdown",
+            timestamp=timestamp,
+        )
+
+
+def start_bot():
+    slack_socket_mode_handler = SocketModeHandler(slack_app, SLACK_APP_TOKEN)
+    slack_socket_mode_handler.start()
+
+
+if __name__ == "__main__":
+    start_bot()

+ 3 - 0
examples/nextjs/nextjs_slack/embedchain.json

@@ -0,0 +1,3 @@
+{
+    "provider": "fly.io"
+}

+ 22 - 0
examples/nextjs/nextjs_slack/fly.toml

@@ -0,0 +1,22 @@
+# fly.toml app configuration file generated for nextjs-slack on 2024-01-05T09:33:59+05:30
+#
+# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
+#
+
+app = "nextjs-slack"
+primary_region = "sjc"
+
+[build]
+
+[http_service]
+  internal_port = 8080
+  force_https = true
+  auto_stop_machines = false
+  auto_start_machines = true
+  min_machines_running = 0
+  processes = ["app"]
+
+[[vm]]
+  cpu_kind = "shared"
+  cpus = 1
+  memory_mb = 1024

+ 4 - 0
examples/nextjs/nextjs_slack/requirements.txt

@@ -0,0 +1,4 @@
+python-dotenv
+slack-sdk
+slack_bolt
+embedchain

+ 8 - 0
examples/nextjs/requirements.txt

@@ -0,0 +1,8 @@
+fastapi==0.104.0
+uvicorn==0.23.2
+embedchain[opensource]
+beautifulsoup4
+discord
+python-dotenv
+slack-sdk
+slack_bolt