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_name
with yours - In .env
- Change
BASE_URL
with yours - (Not required) Set
SENTRY_DSN
to enable Sentry error reporting
- Change
- In main.ts
- Set the
Title
andDescription
of the API
- Set the
pnpm run tunnel
And 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) {
// ...
}