RECENT POST

TOP POST

How To Create a Custom ChatGPT App That Can Access Data From An API

by | Feb 14, 2024

A Step-by-Step Tutorial For Creating a Custom GPT that can Verify A Phone Number

Imagine being able to craft your own intelligent GPT model that can verify a phone number within the ChatGPT ecosystem. Without any prior coding experience following a few simple steps, you can easily design a custom Numlookup AI that can validate phone numbers, among other functionalities, function in the same way as phone number reverse lookup API, cell phone carrier lookup API.

Creating a custom GPT for ChatGPT can be an exciting project, especially when it involves integrating external APIs to access data. 

For this step-by-step tutorial, we will use the Numverify phone validator API to demonstrate how to create a custom GPT for ChatGPT.

Numverify offers robust, real-time phone number validation and information services, making it an ideal choice for showcasing how external APIs can enhance the capabilities of a ChatGPT model. 

By integrating a phone number validation API into your own custom GPT, you can create a GPT capable of scanning documents for phone numbers, validating phone numbers uploaded in documents. Furthermore your GPT could generate and return files with validated numbers, streamlining processes and enhancing data integrity. This opens a new realm of possibilities, from improving customer interactions to automating data management tasks.

Step 1: Access Your Paid Numverify Account

As a paid user of Numverify, you already have access to an extensive range of features that make this API an exemplary choice for phone number validation and information retrieval. In this step-by-step tutorial, where we show you how to integrate the Numverify API into a custom GPT, you will be able to converse with an AI that not only engages in intelligent dialogue but also brings in a wealth of real-time data and functionalities related to phone number analytics.

Step 2: Run a Numverify Query

Go to your Numverify account dashboard and click ‘Run’ to run the phone number validation query.

A browser window will open and you should get a result similar to this:

https://apilayer.net/api/validate?access_key=YOUR_API_KEY&number=14158586273&country_code=&format=1

Followed by its JSON result

JSON result for validate

Keep that browser tab open, because later, you will be asked to paste the URL and the JSON result into ChatGPT so that it can assist you in creating a GPT schema, where your newly created GPT will be able to access the Numverify API.

Step 3: Creating a Custom GPT for the Chat GPT Website

Head over to the chat gpt website. You’ve likely familiarized yourself with OpenAI’s GPT store, absorbing the diverse range of GPT models available. 

It’s time to take your knowledge a step further by creating your own Custom GPT, one that uniquely accesses an external API – in our case, the Numverify API.

Navigate to the ‘Explore GPTs‘ section within the OpenAI platform. Here, you’ll find an array of pre-built GPT models, each serving different functions and industries. This exploration will not only give you inspiration but also a deeper understanding of how various GPT models are structured and deployed.

chatgpt

Once you’re in the ‘Explore GPTs’ section, look for the option to ‘Create‘ a new GPT model. This is where you’ll begin the process of building your custom model. Clicking on ‘Create’ will open up a new interface where you can start inputting the specifics for your custom GPT.

gpt create button

Define Your Custom GPT’s Parameters

In this stage, you’ll define the essential parameters of your custom GPT model. This includes naming your model, setting its language capabilities, and specifying other foundational elements that will dictate how your GPT will function. Be thoughtful about these choices as they form the core framework of your custom model.

Make some simple configurations, such as clicking on the + to add an image, naming and describing your GPT, writing some basic instructions, and including a conversation starter message. 

In the screenshot below, you can see it doesn’t need much effort to get started, you can make the instructions more comprehensive later.

Simple example: The brief example below demonstrates that your custom GPT only needs a skeleton outline of a few main points in the ‘instructions’ to work.

custom GPT skeleton outline instructions

Customize the Conversation Flow (Advanced example): In the advanced example below, the wording was generated by using the ‘Create’ tab where you can fine-tune your requirements using a chat.

Integrating the Numverify API isn’t just about technical connectivity; it’s also about ensuring that the conversation flow is natural and intuitive. Customize the ‘Instructions’ section for how your GPT model will use the Numverify data in its responses. This could involve setting up specific triggers for the API interaction or scripting responses that effectively incorporate the data retrieved from Numverify.

With the basic structure of your GPT model set up, it’s now time to integrate the Numverify API. This will involve inputting the API key and setting up the necessary endpoints for your GPT model to interact with. You’ll need to configure how your model sends requests to Numverify and how it processes the responses within the conversational context.

To get started with integrating the Numverify API, you’ll need to click the ‘Configure’ button to go straight to ‘Configure’ tab.

Ensure Code Interpreter is ticked and click ‘Create new action’.

Enabling the “Code Interpreter” in a custom GPT model is vital for accessing APIs and manipulating data. It allows the model to execute code necessary for making HTTP requests, processing real-time data, and handling complex operations like parsing and filtering. This feature is also key for maintaining security through proper data handling and authentication when interacting with external services. Essentially, it provides the flexibility and functionality needed to create dynamic, efficient, and secure applications.

Step 4: Connecting a Custom GPT to an API

In Authentication settings, select API. The Numverify API uses an API key, so make sure the authentication type selected is ‘API key’, and then click the ‘Save’ button.

Step 5a: Creating a Schema for a Custom GPT

Copy the Example Weather Schema: Start by locating the example Weather schema. Once you’ve found it, select the entire schema text and copy it to your clipboard. This schema will serve as a base or reference for your custom GPT schema.

Open a New ChatGPT Tab: Now, open a new browser tab and navigate to ChatGPT. This separate instance will allow you to work on creating your custom GPT without losing any progress or information from your current session.

Paste the Schema into ChatGPT: In the new ChatGPT tab, paste the Weather schema that you copied earlier into the message box. This action puts the example schema right in the conversation where you can reference and modify it.

Explain Your Objective to ChatGPT: After pasting the schema, add a message to ChatGPT explaining what you’re trying to achieve. You could say something like: “I am working on creating a schema for a custom GPT model. I want it to be similar to this Weather schema, but it should function with the Numverify API.”

Refer to Your Numverify Query from Step 2: Recall Step 2 where you ran a Numverify query. You should have the Numverify API URL and the JSON result from that query. Copy both the URL and the JSON result.

Paste the Numverify API URL and JSON Result: Back in the ChatGPT tab, paste the Numverify API URL and the JSON result. Make sure to provide an explanation for each. For the API URL, you might say, “This is the Numverify API URL I will be using,” and for the JSON result, you could explain, “This is an example of the JSON result from the Numverify API.”

Once ChatGPT has generated the adapted schema for you, incorporating the Numverify API’s functionalities:

Review the Generated Schema: Carefully examine the schema provided by ChatGPT. Ensure that it aligns with your requirements, particularly how it integrates the Numverify API. Check for the inclusion of necessary fields like phone number validation, country code, carrier information, and any other specific details you require from Numverify.

Step 5b: Numverify Schema Ready to Paste into ChatGPT

Rather than following the steps with 5a and using ChatGPT to generate a schema, you could simply copy the ready-prepared schema below that we generated earlier.

{
  "openapi": "3.1.0",
  "info": {
    "title": "Phone Number Validation Service",
    "description": "Validates and retrieves information about phone numbers.",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://apilayer.net/api"
    }
  ],
  "paths": {
    "/validate": {
      "get": {
        "description": "Validate and retrieve information about a phone number",
        "operationId": "ValidatePhoneNumber",
        "parameters": [
          {
            "name": "access_key",
            "in": "query",
            "description": "Your API access key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "number",
            "in": "query",
            "description": "The phone number to validate",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "country_code",
            "in": "query",
            "description": "Country code for the phone number",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "description": "The desired format of the response",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneNumberValidationResponse"
                }
              }
            }
          }
        },
        "deprecated": false
      }
    }
  },
  "components": {
    "schemas": {
      "PhoneNumberValidationResponse": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean"
          },
          "number": {
            "type": "string"
          },
          "local_format": {
            "type": "string"
          },
          "international_format": {
            "type": "string"
          },
          "country_prefix": {
            "type": "string"
          },
          "country_code": {
            "type": "string"
          },
          "country_name": {
            "type": "string"
          },
          "location": {
            "type": "string"
          },
          "carrier": {
            "type": "string"
          },
          "line_type": {
            "type": "string"
          }
        }
      }
    }
  }
}

This schema describes an API (Application Programming Interface) using the OpenAPI Specification (OAS) format, version 3.1.0. It’s for a “Phone Number Validation Service” and provides structured details on how the API works, its endpoints, and the data it exchanges. Let’s break it down:

1. openapi: “3.1.0” 

   – This indicates the version of the OpenAPI Specification that the API conforms to.

2. info

   – Provides metadata about the API.

   – title: “Phone Number Validation Service” – The name of the API.

   – description: Explains what the API does, i.e., validating and retrieving information about phone numbers.

   – version: “v1.0.0” – The current version of the API.

3. servers

   – Lists the base URL(s) for the API endpoints.

   – url: “https://apilayer.net/api” – The base URL where the API is accessible.

4. paths

   – Describes the available paths or endpoints in the API and their operations.

   – /validate: A specific endpoint path for validating phone numbers.

     – get: Indicates an HTTP GET method for the endpoint.

       – description: Explains the purpose of this endpoint.

       – operationId: A unique identifier for the operation.

       – parameters: Lists the parameters that can be included in the query string of the GET request.

         – access_key: A required API key for authentication.

         – number: The phone number to validate (required).

         – country_code: An optional parameter for the country code of the phone number.

         – format: An optional parameter to specify the response format.

       – responses: Defines the responses for the operation.

         – 200: Indicates a successful response and its content format.

5. components

   – Provides reusable components for the API.

   – schemas: Defines the structure of data objects used in the API.

     – PhoneNumberValidationResponse: Specifies the schema for the response of a successful phone number validation.

       – It’s an object with properties like “valid” (boolean), “number” (string), “local_format” (string), and others, each describing a piece of information about the validated phone number.

In summary, this schema is a comprehensive description of a web service that validates phone numbers. It includes information about how to access the service, the available operations, the expected request format, and the structure of the responses. It’s a blueprint for how to interact with the “Phone Number Validation Service” API.

Step 5c: Using the Created Schema

Now that you have the adapted schema provided by ChatGPT, copy it to your clipboard. 

Navigate to the environment where you are configuring your custom GPT and paste it over the example schema. 

configuring your custom GPT and paste it over the example schema

Step 6: Testing the Schema and Previewing the GPT

With the adapted schema now pasted in your working environment, click the ‘Test’ button.

schema test for validate phone number

After clicking ‘Test’ you will notice messages in the Preview section of the screen, in the preview screen click ‘Allow’, to allow ChatGPT to access the Numverify API at APILayer.

preview of allowing ChatGPT to access the Numverify API at APILayer

You may get a response like the one below where an error occurs because ChatGPT is trying to access the Numverify API without an API key:

error occurs because ChatGPT is trying to access the Numverify API without an API key

Provide ChatGPT with your API key

Provide ChatGPT with your API key

You should get a better result where ChatGPT returns the verification details for the test phone number in the API URL.

ChatGPT returns the verification details for the test phone number in the API url

In preview you should be able to test the number validation with other phone numbers now that you have provided the GPT with an API key.

Step 7: Deploying The Custom GPT

Before finalizing and saving your progress, it’s essential to provide a privacy policy URL. This step ensures transparency and compliance with data handling and privacy standards, which is crucial when dealing with user data and external APIs.

You won’t be able to save the GPT without one. This URL should link to the privacy policy associated with the API you are integrating into your GPT model. 

Then find the ‘Save’ button,, you need to decide how you want to deploy your GPT application. You’ll typically be presented with several options:

  • Only Me: Select this option if you want the custom GPT to be accessible only to you. This is a good choice if you’re still testing or if the GPT is for personal use.
  • Anyone with a Link: Choosing this option means that anyone who has the specific link to your custom GPT can access it. It’s a suitable choice for controlled sharing, where you want to give access to specific individuals or groups without making it public.
  • Everyone: If you select this option, your custom GPT will be publicly accessible to anyone. This is ideal if you’re creating a tool or service that you want to be widely available.
publish setting button

Congratulations! Your custom GPT is now deployed and ready for use. 

Step 8: Running The Deployed GPT

To run your deployed GPT, select ‘Explore GPTS’ from the main ChatGPT menu. 

ChatGPT menu

Click the button ‘My GPTs’ to see a list of your GPTs.

create button

Double-click the icon of your GPT from the list to run it.

icon of your GPT from the list

Remember you will need to provide your GPT with your Numverify API key to run it.

GPT with your Numverify API key

Congratulations on completing this detailed journey of developing and launching your unique GPT model. 

Your achievement in creating a custom GPT model is a powerful demonstration of the ability to merge the sophisticated features of conversational AI with the essential services of external data sources, similar to the functionality provided by services such as Numlookup to verify a phone number.

As you progress, keep in mind that the potential is boundless. Starting with Numverify API integration represents just the initial step. You have the opportunity to enhance your custom GPT model by incorporating additional APIs from API providers such as APILayer, addressing a wide array of needs and applications.

Continue to push the boundaries, innovate, and use your custom GPT model as a portal to uncover new horizons in the realms of AI and data integration. Your journey is far from over; it marks the commencement of an exciting exploration in the field of AI applications. Wishing you the best of luck and enjoyable coding experiences!