git clone https://github.com/pairprog/nestjs-gpt-action-template.git
cd nestjs-gpt-action-template
pnpm install
cp .env.example .env- In package.json
> scripts > tunnel, changedomain_namewith yours - In .env
- Change
BASE_URLwith yours - (Not required) Set
SENTRY_DSNto enable Sentry error reporting
- Change
- In main.ts
- Set the
TitleandDescriptionof the API
- Set the
pnpm run tunnelAnd in another terminal window
pnpm run start:dev
# or
pnpm run start:debug- The OpenAPI schema's URL will be shown in the terminal window in blue.
- Copy it
- In "actions" section of your GPT app:
- Click "Create New Action"
- Click on "Import from URL"
- Paste the URL.
- Click "Import"
- Look at wikipedia.controller.ts and wikipedia.dto.ts to see how to add a new action
OpenAI provides identifying information with each query. You can access them in routes using the ChatGptHeaders decorator
@Post('/my/path')
function myPath(@ChatGptHeaders() headers: ChatGptHeaders) {
// ...
}