This repository contains the source code for the Listen Notes ChatGPT plugin. This plugin is built with PodcastAPI.com and deployed on serverless Cloudflare Pages using JavaScript. It allows users to interact with the Listen Notes Podcast Database through the ChatGPT interface. Users can search for podcasts, find episodes, get recommendations, and more.
To use the Listen Notes ChatGPT plugin, you'll need to enable the plugin on chat.openai.com first:
You can try prompts like these:
- "what are some recent podcast episodes talking about Sam Altman, in English"
- "give me a random podcast episode to listen"
- "how many episodes does the daily podcast have"
- "有哪些好的中文播客,关于犯罪的"
- "find me some podcasts about charles manson"
To run this repo on your local development environment, follow these steps:
0) Install Cloudflare Wrangler
npm install -g wrangler
1) Clone the repository to your local machine.
git clone https://github.com/ListenNotes/listennotes-chatgpt-plugin.git
2) Install the necessary dependencies.
yarn install
3) Create a .dev.vars
file in the root directory of this project (at the same level as package.json).
Put these variables in the .dev.vars
file:
LISTEN_API_KEY = "your_podcast_api_key_from_podcastapi.com"
CHATGPT_SECRET = "your_custom_secret_which_is_like_a_password"
CHATGPT_VERIFICATION_TOKEN = "a_secret_generated_on_chat.openai.com"
NODE_VERSION = '17'
Variables | Description | Required for dev? |
---|---|---|
LISTEN_API_KEY | API key for Podcast API, which can be obtained at listennotes.com/api/pricing | Yes |
CHATGPT_SECRET | A custom secret for interacting with proxy endpoints defined in functions/api/v2 | Yes |
CHATGPT_VERIFICATION_TOKEN | A verification token generated on chat.openai.com. For dev purposes, you can put a random string or leave it blank for now. | No |
NODE_VERSION | Pin the nodejs version to 17.0, which is to make Cloudflare Pages happy. | No |
4) Test the proxy endpoints
Run the dev server first:
yarn dev
Then use curl to send a request (Note: Replace $CHATGPT_SECRET with the value that you set in the .dev.vars
file):
curl -X GET --location "http://localhost:8788/api/v2/search_podcasts?q=nba" \
-H "Authorization: Bearer $CHATGPT_SECRET"
This plugin can be adapted to work with other APIs. To do this, you'll need to modify the endpoints and the corresponding functions in the code.
Specifically, you'll need to change three things:
-
Update ai-plugin.json: Learn more on openai.com.
-
Update proxy endpoints with other APIs: Those proxy endpoints are running on Cloudflare Pages edge to send API requests. You may want to learn how Cloudflare Pages functions work first.
-
Update openapi.json: ChatGPT relies on this openapi spec to know what proxy endpoints are available. You may want to learn more on openai.com.
To deploy the Listen Notes ChatGPT plugin to production on Cloudflare Pages, follow these steps:
You'll setup deployment configuration like this:
And setup environment variables:
Note: At first, you may just put a random string for CHATGPT_VERIFICATION_TOKEN because you'll get the real verification token later from openapi.com.
And setup custom domain for your Cloudflare Pages project:
Go to the Plugin store:
And follow the instructions to setup your plugin:
You'll see the verification token, then go back to the Cloudflare Pages dashboard to setup the value of CHATGPT_VERIFICATION_TOKEN (you can delete the old variable and add a new one):
To make your Cloudflare Pages project pick up the new CHATGPT_VERIFICATION_TOKEN value, you'll have to redeploy:
Then go back to the ChatGPT UI to verify the verification token.
By this point, you should be able to test your plugin on chat.openai.com.
To list your plugin on the Plugin Store, please refer to the guidelines provided on this page for submitting your plugin for review.