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:
![Screenshot 2023-06-19 at 12 16 11 PM](https://private-user-images.githubusercontent.com/1719237/246920410-0a4dbc00-c34c-40b4-b68d-048f3db6895f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODU2OTAsIm5iZiI6MTcyMTE4NTM5MCwicGF0aCI6Ii8xNzE5MjM3LzI0NjkyMDQxMC0wYTRkYmMwMC1jMzRjLTQwYjQtYjY4ZC0wNDhmM2RiNjg5NWYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTdUMDMwMzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Mzg0NGFmZGE0NzI5OWE0NmMyYWZmZTE4ZjQ1ZmFjODMzZjAyMTM4MTM0ODMwYWEyZmQyNTRiNWI5ZTU4NzQyOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.i6v5stWkPitaNkDN5g07i-big6rf7UX7Tjid7Un6MhA)
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"
![Screenshot 2023-06-19 at 10 18 30 AM](https://private-user-images.githubusercontent.com/1719237/246920440-4fd9973f-35a4-4d3c-be03-eb1732d2d38f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODU2OTAsIm5iZiI6MTcyMTE4NTM5MCwicGF0aCI6Ii8xNzE5MjM3LzI0NjkyMDQ0MC00ZmQ5OTczZi0zNWE0LTRkM2MtYmUwMy1lYjE3MzJkMmQzOGYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTdUMDMwMzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZmM5MmU2Y2I2NGM2NGE3M2Y1ZGMzZTQzNjgzNjFhMmU0YTY1MDQ4ZjBhZjVkZWQ1MTNlNTkxZGE5MzMwNmUwNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.XMVuFy37WIkPj_IkqsOokYYe26diaVTISWaqIlTMGzM)
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:
![Screenshot 2023-06-19 at 11 35 53 AM](https://private-user-images.githubusercontent.com/1719237/246920641-01e751cf-b008-44ea-99a2-733b74993bca.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODU2OTAsIm5iZiI6MTcyMTE4NTM5MCwicGF0aCI6Ii8xNzE5MjM3LzI0NjkyMDY0MS0wMWU3NTFjZi1iMDA4LTQ0ZWEtOTlhMi03MzNiNzQ5OTNiY2EucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTdUMDMwMzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzFlOWViNWFjODE1MzMyNGUyYjExN2I4ZjBjMzBkNTRkM2VhYzFiNDIzODZjZGRhM2ZmZGU3ZDM0OWVlZDc0NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.JzFwkfScXBujia3NQIMybi9gxH3M4o2sSEiZn2JnXYQ)
And setup environment variables:
![Screenshot 2023-06-19 at 11 36 46 AM](https://private-user-images.githubusercontent.com/1719237/246920655-0666e0e7-90ee-406b-9d49-9bd98e37ee6c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODU2OTAsIm5iZiI6MTcyMTE4NTM5MCwicGF0aCI6Ii8xNzE5MjM3LzI0NjkyMDY1NS0wNjY2ZTBlNy05MGVlLTQwNmItOWQ0OS05YmQ5OGUzN2VlNmMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTdUMDMwMzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGUzNjE5ZmY1MTEyNjRhOTIyZDQ1Y2Q0NmQ2MTcyNGEzYTMxMzA1ZDI2MTU4MWUyOGZlODY2Mjc5M2RmZWJhNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.mDyF8_sGnAbEQK2zHWW7nPWcaOYiZ0YDGDp3YrFQ4Wk)
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:
![Screenshot 2023-06-19 at 11 43 43 AM](https://private-user-images.githubusercontent.com/1719237/246920739-fb6a9be3-5583-4213-8ade-c3a64e01bbed.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODU2OTAsIm5iZiI6MTcyMTE4NTM5MCwicGF0aCI6Ii8xNzE5MjM3LzI0NjkyMDczOS1mYjZhOWJlMy01NTgzLTQyMTMtOGFkZS1jM2E2NGUwMWJiZWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTdUMDMwMzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGY1YjY3ZDQxZmI0OTBiNTAzZGRmMzA4ZDU2MzU4ZjU5Yjc0M2Y1NjQxYmM5ZDkyZGE1N2VjMTBmNTM3NGU4MSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.xzpIz_4B6132UQy8NNy3sIyf7T525xU8LgxuQYg54cc)
Go to the Plugin store:
![Screenshot 2023-06-19 at 11 42 42 AM](https://private-user-images.githubusercontent.com/1719237/246920772-92340335-5cdd-4c79-9dc7-c662417202cf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODU2OTAsIm5iZiI6MTcyMTE4NTM5MCwicGF0aCI6Ii8xNzE5MjM3LzI0NjkyMDc3Mi05MjM0MDMzNS01Y2RkLTRjNzktOWRjNy1jNjYyNDE3MjAyY2YucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTdUMDMwMzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzAwNzdhNzg0MjdiZjM5MjUxMjRjNTA2NGRlNmM5MzU4Nzk1NGM2MThhZTNkNmUyMDMwMmM1OWQzMmY2ZmVkNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.BTYouN7l1h23LP5AF0ZvDrl-b1mUDZqAPgghj6L0PPk)
And follow the instructions to setup your plugin:
![Screenshot 2023-06-19 at 11 45 18 AM](https://private-user-images.githubusercontent.com/1719237/246920792-4c217822-1ef6-421d-933f-50462f97ce9e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODU2OTAsIm5iZiI6MTcyMTE4NTM5MCwicGF0aCI6Ii8xNzE5MjM3LzI0NjkyMDc5Mi00YzIxNzgyMi0xZWY2LTQyMWQtOTMzZi01MDQ2MmY5N2NlOWUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTdUMDMwMzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NTRkNTVlOTJjNGIxMzQ4Y2M5ZjAyODkyYzI4MWNlODdkZGVjN2ZjMmY2ODVhODRmNTQ0YTIyODY3NmY3M2QwNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Gs2Y4Q-POwPBdokrmHGED5i6nnG4d_mv2uEdtSNf9NE)
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):
![Screenshot 2023-06-19 at 11 47 33 AM](https://private-user-images.githubusercontent.com/1719237/246920809-66b920bb-cc37-4901-a147-ed35ea04b9d9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODU2OTAsIm5iZiI6MTcyMTE4NTM5MCwicGF0aCI6Ii8xNzE5MjM3LzI0NjkyMDgwOS02NmI5MjBiYi1jYzM3LTQ5MDEtYTE0Ny1lZDM1ZWEwNGI5ZDkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTdUMDMwMzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzA3NmFkZWJmNmYzMzVhMGM1NDE1YWM0N2U2NjAwYjRlY2I3YTNiMTQ3YWRkNzhiODRlMzM4NTBhMzc2YWFlYyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.coGxInxk2oPlcttbqNxZPRcB0AQT4jOUrOQNmweT-KA)
To make your Cloudflare Pages project pick up the new CHATGPT_VERIFICATION_TOKEN value, you'll have to redeploy:
![Screenshot 2023-06-19 at 11 48 45 AM](https://private-user-images.githubusercontent.com/1719237/246920861-409372ec-903f-4023-919a-46c69e3008b4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODU2OTAsIm5iZiI6MTcyMTE4NTM5MCwicGF0aCI6Ii8xNzE5MjM3LzI0NjkyMDg2MS00MDkzNzJlYy05MDNmLTQwMjMtOTE5YS00NmM2OWUzMDA4YjQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTdUMDMwMzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTU0NDZlZmIxNzE3Mjc4OTU2OTI2ZjJmNWJkMmYxNTU2NTVhNTk4NmIxYTA3YzM3NDk4ZjdkZmMyODdlOGFiOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.VoNHSobTxh3wGfmI88BkHK1_14sobQdA0Tda6bSKfP0)
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.