OpenAI announced a new mindblowing feature on the DevDay (Nov 2023). It's the custom GPT. With it, you can create your custom-tailored chat GPT. The most exciting part is you can feed your custom GPT with a PDF or even connect it to the internet!
- Read more about custom GPT here.
In this blog post, we'll learn how to connect custom chatGPT with Google (a.k.a. internet!)
What are we going to build?
We'll create an SEO tool that analyzes Google Search results page (Google SERP) and give us advice accordingly. By default, custom GPT can browse the web with Bing Search but not with Google. We can extend its capabilities by using an external API with Actions.
Flow of our custom GPT:
- A user will give a keyword to analyze.
- We'll get information from Google SERP using external API in Actions.
- Chat GPT will give advice based on this accurate live data.
Note: The sky is the limit of what we can do with the ability of custom GPT to connect to external API.
- Since we need access to Google, we will use a simple API from SerpApi. SerpApi has APIs to connect to various search engines, including Google. Therefore, register at serpapi.com and get your API key for free.
- Register and subscribe to chat GPT Plus.
- Feel free to read the basics of how to create a custom GPT? Feel free to follow our step-by-step tutorial here.
Documentation link: Google Search API .
Step-by-step tutorial to connect custom GPT to the internet
Make sure you have already subscribed to Chat GPT to follow along.
Step 1: Create a new custom GPT
From your chat.openai.com dashboard, Click on the "explore" button.
Click the "Create a GPT" button.
Step 2: Fill in the basic information
It will redirect you to the "GPT Builder" section. You need to provide this data:
- What it does (in short sentences)
- GPT's name (It will give you a suggestion)
- A profile picture (It will auto-generate for you as well)
Step 3: Give specific instruction
Next, tell the builder about the details of what it will do in the background. Here is mine for this "SEO tool sample":
- It will analyze Google Serp for the user.
- User will provide a keyword
- It analyze Google SERP (Via actions - external API)
- It returns with advices to suggest user what to cover on their page
Follow up instruction
- It take top 5 results from Google SERP
- It analyze what the user-intent based on that top ranking results
- It analyze the people-also-ask-for or related-search
- Return a complete advice based on that (not general SEO advise)
Step 4: Define user interaction
Explain how the user (or you) will interact with this tool. Here is mine:
if user type this: "keyword: $input" - then $input is the keyword user want to cover.
Step 5: (Optional) Choose capabilities
Since we will only use an external API, I'll uncheck all capabilities in the "configure tab". To make sure it only relies on SerpApi.
Step 6: Create the OpenAPI schema
We'll need an OpenAPI schema for our actions. Therefore, we need to create the structure of our schema first.
You can learn and build it yourself, or if you're lazy like me, ask chatGPT to build it for you. I'm copy-pasting the sample curl request from the API documentation.
The returned result is imperfect, but it is enough for the base structure. In my case, I need to add the "servers" block and "operationId." Here is my complete schema:
{
"openapi": "3.0.0",
"info": {
"title": "SerpApi Search Service",
"version": "1.0.0"
},
"servers": [
{
"url": "https://serpapi.com"
}
],
"paths": {
"/search": {
"get": {
"summary": "Perform a search using SerpApi",
"operationId": "seachGoogle",
"parameters": [
{
"name": "api_key",
"in": "query",
"required": true,
"schema": {
"type": "string",
"enum": ["YOUR_REAL_SERPAPI_API_KEY"]
}
},
{
"in": "query",
"name": "engine",
"required": true,
"schema": {
"type": "string"
},
"description": "The search engine to use, e.g., 'google'."
},
{
"in": "query",
"name": "q",
"required": true,
"schema": {
"type": "string"
},
"description": "The query string for the search."
},
{
"in": "query",
"name": "location",
"required": false,
"schema": {
"type": "string"
},
"description": "The geographical location for the search."
},
{
"in": "query",
"name": "google_domain",
"required": false,
"schema": {
"type": "string"
},
"description": "The specific Google domain to use for the search."
},
{
"in": "query",
"name": "gl",
"required": false,
"schema": {
"type": "string"
},
"description": "The country to use for the search."
},
{
"in": "query",
"name": "hl",
"required": false,
"schema": {
"type": "string"
},
"description": "The language setting for the search."
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"type": "object"
}
}
},
"additionalProperties": false
}
}
}
},
"401": {
"description": "Unauthorized"
},
"400": {
"description": "Bad request"
}
}
}
}
}
}
Feel free to add or remove parameters based on your needs. The code above is my "final schema." Feel free to copy and paste it.
Just for your information, I needed to change the api_key
structure from this.
{
"in": "query",
"name": "api_key",
"required": true,
"schema": {
"type": "string"
},
"description": "The API key for authentication."
},
to store the api_key value in the enum array like this:
{
"name": "api_key",
"in": "query",
"required": true,
"schema": {
"type": "string",
"enum": ["YOUR_REAL_SERPAPI_API_KEY"]
}
}
Otherwise, the chatGPT won't be able to validate your API key.
Step 7: Use it in action configuration
To add the schema, click on the "create new action" in the configure tab
Now, add the schema inside the textbox
Step 8: Test the GPT SEO tool
You can click on the "test button" below.
The GPT will test and run the results for us. You'll receive an error message if anything is wrong.
It will also run a search with a sample keyword for us. It shows us the top 5 results with a link to the content to ensure the GPT is not hallucinating.
Step 9: Test with a user input
We've determined that the user can put the keyword like this:
Besides the accurate top-ranking results, our custom GPT reflects the actual "people also search" content from the Google Live results page.
It returns concrete SEO tips after giving us information from the top-ranking results.
Optional Extended feature
More specific action
You can adjust our GPT by interacting in the chat box or from the configure tab. For example, you can ask the GPT to return 5 article ideas for you instead of only returning SEO tips.
Scraping individual page
You can add multiple APIs from different resources at customGPT. You can add tools like Webpilot AI to scrape the individual top-ranking pages. To analyze the header, structure, and more.
FAQ
Is ChatGPT connected to the internet?
With the recent update, ChatGPT can use Bing search results to get information from the internet.
How much does custom GPT by OpenAI cost?
It costs $20/month since you must subscribe to ChatGPT Plus to use it.
Top comments (0)