Render docs · Inngest Agent Kit docs
Learn how to build and deploy a Hacker News agent with Inngest, Render, and Next.js.
This Hacker News Agent enables you to enter some interests such as Next.js or Serverless along with a set of questions. Each question get assigned to a frequency at which the AgentKit Network will be triggered to summarize to answer the question based on the latest Hacker News stories fetched by the indexer.
packages/app
: Next.js application with the Hacker News agent configuration UI and its Inngest AgentKit Networkpackages/indexer
: A Cron Job that indexes Hacker News content into a Render Postgres vector database
To deploy this project on Render, you need to have the following accounts:
The Postgres vector database is used to store the Hacker News stories and to serve as the vector database for the AgentKit Network.
To set up the Postgres vector database, you need to create a new Postgres database on Render and initialize it with the provided schema.
-
Then, from your project, Create a new Postgres database on Render.
-
Initialize the database with the provided schema
First, you'll need to clone this project locally to get the schema.sql file.
Then, to initialize the database with the provided schema, copy the psql command provided from the Postgres database dashboard (for external connections) and run it in your terminal as follows from the root of the project:
psql -Atx postgresql://<redacted>@<redacted>.render.com/<redacted> -f packages/indexer/schema.sql
The Indexer service is used to fetch Hacker News stories and to store them in the Postgres vector database.
The packages/indexer
directory contains a indexer.ts
file that will index Hacker News content into the Postgres vector database.
To set up the Indexer service Cron Job, you need to create a new Cron Job on Render using a Docker image set up with playwright and its chromium binary.
The docker.io/wittydeveloper/inngest-render-indexer:0.4
image is available publicly on Docker Hub for this project:
- Create a new Cron Job on Render using the "Existing image" option by pasting the image URL
docker.io/wittydeveloper/inngest-render-indexer:0.4
in the "Image URL " field. - Configure the Schedule to run on a daily basis:
0 0 \* \* \*
. - Configure the following environment variables:
DATABASE_URL
: The URL of your Postgres vector database (from the Connect button on the Postgres database dashboard).OPENAI_API_KEY
: Your OpenAI API Key.
You are good to go!
The Next.js app and AgentKit Network is used to serve as the frontend to configure the Hacker News agent and as backend to run the AgentKit Network.
The packages/app
directory contains a Next.js application that will serve as the frontend for the Hacker News agent.
To set up the Next.js app and AgentKit Network, you need to create a new Web Service on Render and configure it to run the Next.js application.
-
Create a new Web Service on Render using the "Public Github repository" option by pasting the repository URL
https://github.com/wittydeveloper/inngest-render-hacker-news-agent
in the "Repository URL" field. -
Configure the Root Directory to
packages/app/
. -
Configure the Build Command to
pnpm install; pnpm build
. -
Configure the following environment variables:
DATABASE_URL
: The URL of your Postgres vector database (from the Connect button on the Postgres database dashboard).INNGEST_EVENT_KEY
: The Event Key of your Inngest project.INNGEST_SIGNING_KEY
: The Signing Key of your Inngest project.OPENAI_API_KEY
: Your OpenAI API Key.RESEND_API_KEY
: Your Resend API Key.APP_PASSWORD
: The password to access the app.
You are good to go!
To try it out, go to your Render Web Service dashboard and copy the URL of your web service (ex: https://agenkit-render-tutorial.onrender.com).
The following page should be displayed:
Install dependencies by running the following command from the root of the project:
pnpm install
Run the indexer locally
Note: You'll need to set up the
.env.local
file.
pnpm build
pnpm start
Push a new Docker image version
Example:
docker build -t docker.io/wittydeveloper/inngest-render-indexer:0.5 .
docker push docker.io/wittydeveloper/inngest-render-indexer:0.5
Note: You'll need to set up the
.env.local
file. Don't forget to set theAPP_PASSWORD
password
Run the Next.js app locally
pnpm dev
Start the Inngest Dev Server
npx inngest-cli@latest dev