|
| 1 | +## Blog AI workflows | Next.js template |
| 2 | + |
| 3 | +<p align="center"> |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +</p> |
| 8 | + |
| 9 | +<p align="center"> |
| 10 | + <a href="https://www.inngest.com/docs?ref=github-workflow-sdk-example-nextjs-blog-cms-readme">Documentation</a> |
| 11 | + <span> · </span> |
| 12 | + <a href="https://www.inngest.com/blog?ref=github-workflow-sdk-example-nextjs-blog-cms-readme">Blog</a> |
| 13 | + <span> · </span> |
| 14 | + <a href="https://www.inngest.com/discord">Community</a> |
| 15 | +</p> |
| 16 | +<br/> |
| 17 | + |
| 18 | +This demo is Next.js blog back-office featuring some AI workflows helping with grammar fixes, generating Table of Contents or Tweets, built with [Inngest](https://www.inngest.com/?ref=github-workflow-sdk-example-nextjs-blog-cms-readme), [Supabase](https://supabase.com) and [OpenAI](https://github.com/openai/openai-node). |
| 19 | + |
| 20 | +Get started by cloning this repo and following the below setup instructions or directly deploy this template on Vercel. |
| 21 | + |
| 22 | +- [Getting Started - Local setup](#getting-started-local-setup) |
| 23 | + - [0. Prerequisites](#0-prerequisites) |
| 24 | + - [1. Setup](#1-setup) |
| 25 | + - [2. Database setup](#2-database-setup) |
| 26 | + - [3. Starting the application](#3-starting-the-application) |
| 27 | +- [Getting Started - Vercel/Deployment setup](#getting-started-verceldeployment-setup) |
| 28 | + - [0. Prerequisites](#0-prerequisites-1) |
| 29 | + - [1. Deploy on Vercel](#1-deploy-on-vercel) |
| 30 | + - [2. Inngest Integration setup](#2-inngest-integration-setup) |
| 31 | + - [3. Database setup](#3-database-setup) |
| 32 | +- [Demo tour](#demo-tour) |
| 33 | + |
| 34 | +## Getting Started - Local setup |
| 35 | + |
| 36 | +### 0. Prerequisites |
| 37 | + |
| 38 | +To run this demo locally, you'll need the following: |
| 39 | + |
| 40 | +- a [Supabase account](https://supabase.com) |
| 41 | +- an [OpenAI account](https://platform.openai.com/) |
| 42 | + |
| 43 | +### 1. Setup |
| 44 | + |
| 45 | +1. First, clone the repository and navigate the `examples/` folder: |
| 46 | + |
| 47 | +``` |
| 48 | +git clone |
| 49 | +
|
| 50 | +cd examples/nextjs-blog-cms |
| 51 | +``` |
| 52 | + |
| 53 | +2. Then, install the dependencies: |
| 54 | + |
| 55 | +```bash |
| 56 | +npm i |
| 57 | +# or |
| 58 | +yarn |
| 59 | +# or |
| 60 | +pnpm |
| 61 | +``` |
| 62 | + |
| 63 | +3. Finally, copy your local `.env.example` as `.env.local` and fill your `OPENAI_API_KEY`. |
| 64 | + |
| 65 | +### 2. Database setup |
| 66 | + |
| 67 | +This project needs a database to store the blog posts and workflows. |
| 68 | + |
| 69 | +Follow the below steps to get a database up and running with Supabase: |
| 70 | + |
| 71 | +1. Go to [your Supabase Dashboard](https://supabase.com/dashboard/projects) and create a new project |
| 72 | +1. While your database is being created, update your `.env.local` and fill the `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` |
| 73 | +1. Open the SQL Editor from the left side navigation, and copy the content of the `examples/nextjs-blog-cms/supabase/schema.sql` file |
| 74 | +1. Still in the SQL Editor, create a new snippet and do the same with the `examples/nextjs-blog-cms/supabase/seed.sql` file |
| 75 | +1. Navigate to the Table Editor, you should see two tables: `blog_posts` and `workflows` |
| 76 | + |
| 77 | +You are all set, your database is ready to be used! |
| 78 | + |
| 79 | +### 3. Starting the application |
| 80 | + |
| 81 | +First, start the Next.js application: |
| 82 | + |
| 83 | +```bash |
| 84 | +npm run dev |
| 85 | +# or |
| 86 | +yarn dev |
| 87 | +# or |
| 88 | +pnpm dev |
| 89 | +# or |
| 90 | +bun dev |
| 91 | +``` |
| 92 | + |
| 93 | +Open [http://localhost:3000](http://localhost:3000) with your browser to see the application. See our [Demo Tour section](#demo-tour) to trigger your first workflow. |
| 94 | + |
| 95 | +Finally, start the Inngest Dev Server by running the following command: |
| 96 | + |
| 97 | +``` |
| 98 | +npx inngest-cli@latest dev |
| 99 | +``` |
| 100 | + |
| 101 | +Open [http://localhost:8288](http://localhost:8288) with your browser to explore the [Inngest Dev Server](https://www.inngest.com/docs/dev-server?ref=github-workflow-sdk-example-nextjs-blog-cms-readme). |
| 102 | + |
| 103 | +## Getting Started - Vercel/Deployment setup |
| 104 | + |
| 105 | +### 0. Prerequisites |
| 106 | + |
| 107 | +To run this demo locally, you'll need the following: |
| 108 | + |
| 109 | +- an [Inngest account](https://www.inngest.com/?ref=github-workflow-sdk-example-nextjs-blog-cms-readme) |
| 110 | +- a [Supabase account](https://supabase.com) |
| 111 | +- an [OpenAI account](https://platform.openai.com/) |
| 112 | + |
| 113 | +### 1. Deploy on Vercel |
| 114 | + |
| 115 | +Use the below button to deploy this template to Vercel: |
| 116 | + |
| 117 | +[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Finngest%2Fworkflow-sdk%2Ftree%2Fmain%2Fexamples%2Fnextjs-blog-cms%2F&project-name=nextjs-blog-cms-ai-workflow-with-inngest&repository-name=workflow-sdk&demo-title=nextjs-blog-cms-ai-workflow-with-inngest&demo-description=Next.js%20blog%20back-office%20featuring%20some%20AI%20workflows%20helping%20with%20grammar%20fixes%2C%20generating%20Table%20of%20Contents%20or%20Tweets&demo-image=) |
| 118 | + |
| 119 | +**Once deployed, make sure to configure your `OPENAI_API_KEY` environment variable.** |
| 120 | + |
| 121 | +### 2. Inngest Integration setup |
| 122 | + |
| 123 | +Navigate to the [Inngest Vercel Integration page](https://vercel.com/integrations/inngest) and follow the instructions to link your Vercel application with Inngest. |
| 124 | + |
| 125 | +### 3. Database setup |
| 126 | + |
| 127 | +This project needs a database to store the blog posts and workflows. |
| 128 | + |
| 129 | +Follow the below steps to get a database up and running with Supabase: |
| 130 | + |
| 131 | +1. Go to [your Supabase Dashboard](https://supabase.com/dashboard/projects) and create a new project |
| 132 | +1. While your database is being created, update your Vercel project environment variables: `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` |
| 133 | +1. Open the SQL Editor from the left side navigation, and copy the content of the `examples/nextjs-blog-cms/supabase/schema.sql` file |
| 134 | +1. Still in the SQL Editor, create a new snippet and do the same with the `examples/nextjs-blog-cms/supabase/seed.sql` file |
| 135 | +1. Navigate to the Table Editor, you should see two tables: `blog_posts` and `workflows` |
| 136 | + |
| 137 | +You are all set, your database is ready to be used! |
| 138 | + |
| 139 | +## Demo tour |
| 140 | + |
| 141 | +This template is shipped with a Database seed containing three blog posts (two drafts) and two workflows. |
| 142 | + |
| 143 | +Here are some suggestions of steps to follow as a tour of this demo: |
| 144 | + |
| 145 | +### 1. Configuring an automation |
| 146 | + |
| 147 | +1. Navigate to the automation tab |
| 148 | +1. Click "Configure" on the "When a blog post is moved to review" automation |
| 149 | +1. Hover the "blog-post.updated" node to click on the "+" icon |
| 150 | +1. Select "Add a Table of Contents" on the right side panel |
| 151 | +1. Add another step from "Add a Table of Contents" by using the "+" icon and select "Perform a grammar review" |
| 152 | +1. Finally, add a "Apply changes after approval" as a final step |
| 153 | +1. Click on "Save changes" at the top right |
| 154 | + |
| 155 | +### 2. Move a blog post to review |
| 156 | + |
| 157 | +We now have an active automation that will trigger when a blog post moves to review. |
| 158 | + |
| 159 | +Let's trigger our automation: |
| 160 | + |
| 161 | +1. Navigate to the blog posts page |
| 162 | +1. Click on "Send to review" on the draft blog post |
| 163 | +1. Navigate to your [Inngest Dev Server](http://localhost:8288) or [Inngest Platform](https://app.inngest.com/?ref=github-workflow-sdk-example-nextjs-blog-cms-readme) and go over the "Runs" tab |
| 164 | +1. You can now see your automation running live, step by step, to finally pause |
| 165 | +1. Return to the demo app, the blog post should have the "Needs approval" status. Click on "Review" and compare the Original blog post with the AI revision using the tabs. |
| 166 | +1. At the bottom, click on the "Approve suggestions & Publish" button |
| 167 | +1. Back on the Runs page of the [Inngest Dev Server](http://localhost:8288) or [Inngest Platform](https://app.inngest.com/?ref=github-workflow-sdk-example-nextjs-blog-cms-readme), you see the workflow in a completed state. |
| 168 | +1. Going back to the demo application, on the "blog posts" tab, the blog post should be flagged as "Published" |
0 commit comments