Tech and Programming Tutorials

How to Customise Your Own Chatbot with ChatGPT API

- Advertisement -

In the previous article, we explored how to build an AI chatbot with ChatGPT API. We hope you found it helpful and were able to create a functioning chatbot. Now, it’s time to take your chatbot to the next level by customizing it to your specific needs.

On the other hand, if you are new to this platform, I suggest you visit our first article which will give you the basics, requirements, and step-by-step tutorial to create your first ai chatbot.

Customizing your chatbot means teaching it new skills and abilities. For business owners, you can make your ai chatbot more specific to your business or brand, making it easier for users to engage with your brand or seek assistance.

And for individuals or educators, you can make the ai chatbot only respond to questions based on specific categories of industries. For instance, if your courses are technology related, you will not expect your students to ask questions about food and nutrition.

- Advertisement -

In this article, we will show you how to customize your chatbot with ChatGPT API. I will suggest you read our previous article to get the basics of creating a chatbot. However, if you have already created your chatbot or know your way around then let’s hit the road.

Create Your Personalized ChatGPT API-Powered Chatbot

The “gpt-3.5-turbo” model is capable of assigning a role to your AI. You can make it angry, lovely, funny, or a specialist in technology, sports, health, education or what have you.

All you need to do is to change a single line in the code to suit whatever you want the AI chatbot to do. With this example, I have created a chatbot and personalized it to respond to only technology-related questions.

Follow these steps to personalize your ai chatbot. Please note that the steps below assumed that you have already created your ai chatbot from the previous article and it is working:

  1. First, navigate to the Python script which was named “”.
  2. Then right-click on it and select “Edit with Notepad++”.
customized ai chatbot - changing the role of the ai chatbot and making it only respond to specific niche
personalizing the ai chatbot
  1. Change the highlighted text to your preferred specialization. Ensure you only edit the message inside the double apostrophe. Don’t mess up with the code, otherwise, it will return an error when you run it.

The message part of the code will look like what you see below:

messages = [
    {"role": "system", "content": "You are an AI specialized in technology. Do not answer anything other than technology-related queries."},

As you can see, the chatbot has been directed to only respond to technology-related questions. I have also changed the title and description of the chatbot page to include my brand; thus Lizbotech.

- Advertisement -

The complete Python code of the customized ChatGPT-powered AI Chatbot is also shown below:

import openai
import gradio as gr

openai.api_key = "sk-Gb9waBBQD5pbXduxCzVWT667lbkFJCErDBwASVIYhjUENHFBP"

messages = [
    {"role": "system", "content": "You are an AI specialized in technology. Do not answer anything other than technology-related queries"},

def chatbot(input):
    if input:
        messages.append({"role": "user", "content": input})
        chat = openai.ChatCompletion.create(
            model="gpt-3.5-turbo", messages=messages
        reply = chat.choices[0].message.content
        messages.append({"role": "assistant", "content": reply})
        return reply

inputs = gr.inputs.Textbox(lines=7, label="Chat with Lizbotech Bot")
outputs = gr.outputs.Textbox(label="ChatBot Answer")

gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Lizbotech AI Chatbot",
             description="Ask Lizbotech anything you want",

Let’s test our personalized AI Chatbot

Open Terminal and press “Ctrl+C” to stop the chatbot if you are already running. If it is not already running, then copy the “” as a path and run it in the command prompt as you did previously.

python "C:\apps\"

As usual, you will get a local and public URL. Open the local URL in the web browser and you will get a personalized AI chatbot that only answers technology-related questions.

That’s it. Now our AI Chatbot only answers questions that fall under technology and will never respond to anything else. The result below is very satisfying as it can help you control what your kids, friends, relatives, or employees can do with your personalized chatbot.

final output of the answer provided by the personalized ai chatbot powered by chatgpt

With this customization, you can create a personal AI health assistant, an AI that only provides music-related information, or AI that only responds to law questions or anything you wish. It can be marriage, insurance, politics, religion, education, etc.

Wrapping Up on Customising your AI Chatbot

Customizing your chatbot with ChatGPT API is a powerful way to enhance its capabilities and make it more useful. By following the steps outlined in this article, you can create a custom chatbot that can assist You and your users in a more efficient and effective way. Remember to continually monitor and refine your chatbot to ensure it’s meeting the needs of your audience. With ChatGPT API, the possibilities for customization are endless.

It doesn’t end here! If you need more information, tutorials, and regular tech updates, kindly join our telegram group below.

- Advertisement -


Boateng Oduro is passionate about learning new technologies and working on them. He is a teacher and an engineer who loves to read, write, and teach. He's always curious about things and very determined to track the latest technologies and the trends for the future.

Leave a Reply

Your email address will not be published. Required fields are marked *

- Advertisement -
Back to top button