Create Working Chatbot in HTML CSS and JavaScript | Chatbot HTML CSS JavaScript

Sdílet
Vložit
  • čas přidán 25. 08. 2024

Komentáře • 274

  • @CodingNepal
    @CodingNepal  Před 29 dny +12

    If you get an API error then please read this. If you’re getting the source code from the description link, you can skip this, as the file is already updated.
    This chatbot project initially uses the OpenAI API to generate responses. However, OpenAI no longer offers free API keys; the minimum cost to get started is $5.
    If you're willing to pay for the OpenAI API, follow the video steps as they are and ensure you purchase the API key during setup. Your chatbot should work without any issues.
    For those who prefer not to pay, you can use Google's free Gemini API. Follow these steps to update your script.js file:
    1. 22:48 In line 6, paste your API key, which you can get for free from aistudio.google.com/app/apikey
    2. 21:24 In line 18, update the API URL to:
    const API_URL = `generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent?key=${API_KEY}`
    3. 21:46 In line 20, update the requestOptions object to:
    const requestOptions = {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
    contents: [{
    role: "user",
    parts: [{ text: userMessage }]
    }]
    }),
    };
    4. 25:24 In line 36, update:
    messageElement.textContent = data.candidates[0].content.parts[0].text; // Update message text with API response
    This will allow your chatbot to function without API errors using the free Google Gemini API.

  • @CodingNepal
    @CodingNepal  Před rokem +37

    Create AI Image Generator Website in HTML CSS and JavaScript: czcams.com/video/fA_tWwPMapM/video.html
    Create your own ChatGPT in HTML CSS and JavaScript: czcams.com/video/atKtG29iroY/video.html

    • @longathelstan
      @longathelstan Před rokem +5

      Can you share source code

    • @muhammadvitoni1802
      @muhammadvitoni1802 Před rokem +3

      an error occurred even though I entered the API_keys correctly
      is there any solution for that?

    • @living._truth3270
      @living._truth3270 Před 9 měsíci

      how would you modify this to work as a livechat instead of a chat bot

    • @zainslamdien8138
      @zainslamdien8138 Před měsícem

      @@longathelstan source code.
      class Assistant {
      constructor(apiKey, assistantId) {
      this.apiKey = apiKey;
      this.assistantId = assistantId;
      this.init();
      }
      async init() {
      this.chatbotToggler = document.querySelector(".chatbot-toggler");
      this.closeBtn = document.querySelector(".close-btn");
      this.chatbox = document.querySelector(".chatbox");
      this.chatInput = document.querySelector(".chat-input textarea");
      this.sendChatBtn = document.querySelector(".chat-input span");
      this.inputInitHeight = this.chatInput.scrollHeight;
      this.bindEvents();
      }
      bindEvents() {
      this.chatInput.addEventListener("input", this.adjustInputHeight.bind(this));
      this.chatInput.addEventListener("keydown", this.handleEnterKey.bind(this));
      this.sendChatBtn.addEventListener("click", this.handleChat.bind(this));
      this.closeBtn.addEventListener("click", this.closeChatbot.bind(this));
      this.chatbotToggler.addEventListener("click", this.toggleChatbot.bind(this));
      }
      adjustInputHeight() {
      this.chatInput.style.height = `${this.inputInitHeight}px`;
      this.chatInput.style.height = `${this.chatInput.scrollHeight}px`;
      }
      handleEnterKey(e) {
      if (e.key === "Enter" && !e.shiftKey && window.innerWidth > 800) {
      e.preventDefault();
      this.handleChat();
      }
      }
      closeChatbot() {
      document.body.classList.remove("show-chatbot");
      }
      toggleChatbot() {
      document.body.classList.toggle("show-chatbot");
      }
      createChatLi(message, className, id) {
      const chatLi = document.createElement("li");
      chatLi.classList.add("chat", `${className}`);
      if (id) {
      chatLi.id = id;
      }
      chatLi.innerHTML = `${message}`;
      return chatLi;
      }
      async createThread() {
      try {
      const response = await fetch("api.openai.com/v1/threads", {
      method: "POST",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      });
      if (!response.ok) {
      const errorData = await response.json();
      console.error("Error creating thread:", errorData);
      throw new Error(`Failed to create thread: ${JSON.stringify(errorData)}`);
      }
      this.thread = await response.json();
      console.log("Thread Created:", this.thread);
      } catch (error) {
      console.error("Error in createThread method:", error);
      throw error;
      }
      }
      async generateResponse(chatElement, messageId) {
      const messageElement = chatElement.querySelector("p");
      try {
      await this.createThread();
      const messageResponse = await fetch(`api.openai.com/v1/threads/${this.thread.id}/messages`, {
      method: "POST",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      body: JSON.stringify({
      role: "user",
      content: this.userMessage,
      }),
      });
      if (!messageResponse.ok) {
      const errorData = await messageResponse.json();
      console.error("Error creating message:", errorData);
      throw new Error(`Failed to create message: ${JSON.stringify(errorData)}`);
      }
      const runResponse = await fetch(`api.openai.com/v1/threads/${this.thread.id}/runs`, {
      method: "POST",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      body: JSON.stringify({
      assistant_id: this.assistantId,
      model: "gpt-4-turbo"
      }),
      });
      if (!runResponse.ok) {
      const errorData = await runResponse.json();
      console.error("Error creating run:", errorData);
      throw new Error(`Failed to create run: ${JSON.stringify(errorData)}`);
      }
      const run = await runResponse.json();
      console.log("Run Created:", run);
      await this.checkStatusAndPrintMessages(this.thread.id, run.id, messageElement, messageId);
      } catch (error) {
      console.error("Error fetching response:", error);
      messageElement.classList.add("error");
      messageElement.textContent = "Oops! Something went wrong. Please try again.";
      } finally {
      this.chatbox.scrollTo(0, this.chatbox.scrollHeight);
      this.userMessage = null; // Reset the user message
      }
      }
      async checkStatusAndPrintMessages(threadId, runId, messageElement, messageId) {
      const delay = ms => new Promise(res => setTimeout(res, ms));
      while (true) {
      const runStatusResponse = await fetch(`api.openai.com/v1/threads/${threadId}/runs/${runId}`, {
      method: "GET",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      });
      if (!runStatusResponse.ok) {
      const errorData = await runStatusResponse.json();
      console.error("Error retrieving run status:", errorData);
      throw new Error(`Failed to retrieve run status: ${JSON.stringify(errorData)}`);
      }
      const runStatus = await runStatusResponse.json();
      console.log("Run Status:", runStatus);
      if (runStatus.status === "completed") {
      const messagesResponse = await fetch(`api.openai.com/v1/threads/${threadId}/messages`, {
      method: "GET",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      });
      if (!messagesResponse.ok) {
      const errorData = await messagesResponse.json();
      console.error("Error retrieving messages:", errorData);
      throw new Error(`Failed to retrieve messages: ${JSON.stringify(errorData)}`);
      }
      const messages = await messagesResponse.json();
      console.log("Messages Retrieved:", messages);
      const assistantMessages = messages.data.filter(msg => msg.role === "assistant");
      if (assistantMessages.length > 0) {
      const lastMessage = assistantMessages[assistantMessages.length - 1];
      const content = lastMessage.content[0].text.value;
      messageElement.textContent = content; // Update the "Checking..." message
      }
      break;
      } else {
      console.log("Run is not completed yet, retrying...");
      await delay(3000); // Wait for 3 seconds before checking again
      }
      }
      }
      async handleChat() {
      this.userMessage = this.chatInput.value.trim();
      if (!this.userMessage) return;
      this.chatInput.value = "";
      this.chatInput.style.height = `${this.inputInitHeight}px`;
      const messageId = `msg-${Date.now()}`;
      this.chatbox.appendChild(this.createChatLi(this.userMessage, "outgoing", messageId));
      this.chatbox.scrollTo(0, this.chatbox.scrollHeight);
      setTimeout(() => {
      const incomingChatLi = this.createChatLi("", "incoming", messageId);
      this.chatbox.appendChild(incomingChatLi);
      this.chatbox.scrollTo(0, this.chatbox.scrollHeight);
      this.generateResponse(incomingChatLi, messageId);
      }, 600);
      }
      }
      // Initialize the assistant
      const assistant = new Assistant(
      "YOUR API-KEY HERE",
      "YOUR ASSISTANT-ID HERE"
      );

    • @zainslamdien8138
      @zainslamdien8138 Před měsícem

      @@muhammadvitoni1802 Check your restrictions.

  • @danieloluwakemi9088
    @danieloluwakemi9088 Před rokem +12

    Awesome, I can't believe it, never though I would do something like this even though I'm just calling an API, it's still very cool. Great work bro, the amount of projects in this channel is just insane! this cannel is really underrated, nice video.

    • @gamingarea9011
      @gamingarea9011 Před 7 měsíci

      is the API is free ? and if it is free then for how long ?

  • @tasneemayham974
    @tasneemayham974 Před 8 měsíci +9

    THIS IS THE MOSSTTT UNDERRATEDDD CZcamsE VIDEOO I HAVE EVERRR SEEEEEEEN IN MY ENTIRE LIFFEEEEE!!!!!!!!!!!!!!!
    THANKK YOUUUUUUU!!!!!!!!!! SOOOOOOOOO MUCHCHHHHHHCHCHCHCHC!H!!!
    Incrediblyyy Helpful!!!

  • @exrew
    @exrew Před rokem +61

    why is this channel so underrated 😭😭

    • @user-jk6jh4zb6k
      @user-jk6jh4zb6k Před rokem +2

      Bcz he don't make it with voice

    • @Ciencia_con_s
      @Ciencia_con_s Před rokem

      Communities*
      Spanish (from spain) devs communities.
      They choose whose to 'grow'

    • @liftedup299
      @liftedup299 Před rokem +1

      200k subscribers is not underrated bro

    • @MujHaci
      @MujHaci Před měsícem +1

      oyda azerbaycanli gormek sevindirdi 😄

    • @exrew
      @exrew Před měsícem

      @@MujHaci :D

  • @parindyapigera1790
    @parindyapigera1790 Před 5 měsíci +2

    I have been looking for this dude, Thank you so much!!

  • @nanasatoruu19
    @nanasatoruu19 Před 10 měsíci +4

    why mine didnt answer correctly and always got error message, but in console after I inspect, everything is fine..????

  • @yalejolopez-gd1ez
    @yalejolopez-gd1ez Před rokem +1

    You are the best, I send you a hug from Colombia. 🙌

  • @codingwave56
    @codingwave56 Před rokem +7

    Thank You So Much 🤗
    Amazing Project For Me...
    i learnt so many things from it.

  • @fighter8931
    @fighter8931 Před rokem +9

    MashAllah !
    what a great video !
    I can't wait to subscribe

  • @vaishnavisabbanwar4987
    @vaishnavisabbanwar4987 Před 5 měsíci +1

    thanks sir your this video was really helpful to me

  • @MrOse-nh5pd
    @MrOse-nh5pd Před 10 dny

    Thank you for this video.

  • @CromwellEdonis
    @CromwellEdonis Před 4 měsíci +1

    You are my savior.

  • @hz-vz8qj
    @hz-vz8qj Před 8 měsíci +1

    Most awesome tutorial ever!

  • @CricketGuruji15
    @CricketGuruji15 Před rokem +6

    Can you make it using Nodejs , ExpressJs and React for realtime updates?

  • @krishnachaitanya-md8wl
    @krishnachaitanya-md8wl Před 5 měsíci +5

    Sir, I have gone through your source code. But the chatbot was only replying with one message "oops ! something went wrong". I have placed my own API key in it..even then it is showing only the same thing. What to do to make the chatbot work.

    • @XylomICP
      @XylomICP Před 5 měsíci

      same here I also added the api and it says script line 39

    • @Kishan_Panchal
      @Kishan_Panchal Před 4 měsíci

      so fir hua ki nai

    • @Kishan_Panchal
      @Kishan_Panchal Před 4 měsíci

      mera bhi same aa raha haii

    • @XylomICP
      @XylomICP Před 4 měsíci

      Okay so I found out something apparently we need to add out payment details for it to work I abandoned this method and instead created the chatbot with rule based chatbot

    • @Kishan_Panchal
      @Kishan_Panchal Před 4 měsíci

      @@XylomICP okay

  • @TradeEngineer2821
    @TradeEngineer2821 Před 9 měsíci +6

    Bro, when I made this Chatbot, I coded it perfectly with no errors, but after using my API Key , I m getting the error 'Too many requests , you have completed your current quota', Please tell what should I do

    • @khushboogupta6784
      @khushboogupta6784 Před 7 měsíci

      same, Have you got any solution?

    • @tuskinggiant
      @tuskinggiant Před 7 měsíci

      maybe try generating API key with a new account which is not logged in to GPT

  • @jasono873
    @jasono873 Před rokem +3

    Awesome Tutorial 👍

  • @gehanadel3616
    @gehanadel3616 Před rokem +9

    it was brilliant but GPT doesn't be supported in my country so if you can recommend something else or do another video with another technique I will appreciate it

  • @abcedutechnadiaabdalla
    @abcedutechnadiaabdalla Před 8 měsíci +3

    Thank you very much. A wonderful explanation that helped me a lot.

    • @gamingarea9011
      @gamingarea9011 Před 7 měsíci

      is the API is free ? and if it is free then for how long ?

  • @abhishekkumar-gv6sz
    @abhishekkumar-gv6sz Před rokem +1

    awesome video brother'❤❤, pls explain how to create an account and API key.

  • @mdms4549
    @mdms4549 Před rokem +4

    Thanks bro 😊😊😉, can you make a valid evaluation form that validates both login and registration?

  • @laxmidhakal2987
    @laxmidhakal2987 Před rokem

    Love from US

  • @nishagawade3248
    @nishagawade3248 Před rokem +2

    if you will explain with your voice, then it will give you more views and people will like your content

  • @herbyprein9096
    @herbyprein9096 Před 6 měsíci

    Great tutorial 👍. Because I am new to this topic two questions: 1) How can I embed the bot in my Wordpress site? 2) I am using most of the time a local LLM (LM Studio) for testing. I changed the api-url, the api-key and the model name, but it didn't work (error messages field is required). Any hints for me?

  • @albertgarciabernat8452
    @albertgarciabernat8452 Před 3 měsíci

    really good job

  • @reallife1482
    @reallife1482 Před rokem

    🎉 super awesome ❤️😎

  • @nguyenhoangdung3823
    @nguyenhoangdung3823 Před 11 měsíci

    thank you very much

  • @longathelstan
    @longathelstan Před rokem +1

    Amazing i like this video

  • @gauravpatel96
    @gauravpatel96 Před rokem +1

    Bro listen, How to pass the API in deployment it is getting revoked, I'm not able to set up environment variables please help

  • @binukbe4401
    @binukbe4401 Před rokem +5

    Nice bro but how would you implement exporting and importing chat history?

    • @CodingNepal
      @CodingNepal  Před rokem +2

      Watch this video: czcams.com/video/atKtG29iroY/video.html Here I've shown how to save chat history to the browser's local storage and retrieve it from there.

    • @ompandey4595
      @ompandey4595 Před 7 měsíci

      ​@@CodingNepal as ur from nepal so pls speak if u speak ur viewership will increase

  • @FocusTTocus
    @FocusTTocus Před 5 měsíci

    the best thank you

  • @julianarobayo7980
    @julianarobayo7980 Před 9 měsíci +2

    I get error in the Line starting with "fetch" in js, help

  • @Azalea_tube
    @Azalea_tube Před rokem +2

    can we use Bard API_KEYS instead? open ai available in only 45 countries. pls make a video. and let me know if you see this comment.

  • @ankurjadhav9558
    @ankurjadhav9558 Před 8 měsíci

    great video worked for me thank you. and another thing can we use any free API if yes please suggest the name

  • @shoaeebosman1886
    @shoaeebosman1886 Před 11 měsíci

    Thank you

  • @imadbenmadi
    @imadbenmadi Před rokem +4

    source code please

  • @kiran_sh1
    @kiran_sh1 Před rokem

    awesome.....

  • @user-ru8rp4jq2l
    @user-ru8rp4jq2l Před rokem +1

    🔥🔥🔥

  • @KkppPv-wu9wb
    @KkppPv-wu9wb Před 4 měsíci

    It will be beneficiary if you just include the font details on the description

  • @zainslamdien8138
    @zainslamdien8138 Před měsícem

    Hi, love your coding. you are a legend. Can you perhaps create a chatbot with openai assistant ? Thanks

    • @CodingNepal
      @CodingNepal  Před měsícem

      Glad to hear that! What do you mean by OpenAI assistant? OpenAI API or something else?

    • @zainslamdien8138
      @zainslamdien8138 Před měsícem

      @@CodingNepal hi legend, you know the openai assistants where you create threads and runs and it will connect to a vector database. but its all good, i used your code and converted it into an assistant. if you want the code then let me know. thanks

    • @husnainshahid1932
      @husnainshahid1932 Před měsícem +1

      @@zainslamdien8138 can you show ur project?

    • @zainslamdien8138
      @zainslamdien8138 Před měsícem

      @@husnainshahid1932 Here is the code bro,
      class Assistant {
      constructor(apiKey, assistantId) {
      this.apiKey = apiKey;
      this.assistantId = assistantId;
      this.init();
      }
      async init() {
      this.chatbotToggler = document.querySelector(".chatbot-toggler");
      this.closeBtn = document.querySelector(".close-btn");
      this.chatbox = document.querySelector(".chatbox");
      this.chatInput = document.querySelector(".chat-input textarea");
      this.sendChatBtn = document.querySelector(".chat-input span");
      this.inputInitHeight = this.chatInput.scrollHeight;
      this.bindEvents();
      }
      bindEvents() {
      this.chatInput.addEventListener("input", this.adjustInputHeight.bind(this));
      this.chatInput.addEventListener("keydown", this.handleEnterKey.bind(this));
      this.sendChatBtn.addEventListener("click", this.handleChat.bind(this));
      this.closeBtn.addEventListener("click", this.closeChatbot.bind(this));
      this.chatbotToggler.addEventListener("click", this.toggleChatbot.bind(this));
      }
      adjustInputHeight() {
      this.chatInput.style.height = `${this.inputInitHeight}px`;
      this.chatInput.style.height = `${this.chatInput.scrollHeight}px`;
      }
      handleEnterKey(e) {
      if (e.key === "Enter" && !e.shiftKey && window.innerWidth > 800) {
      e.preventDefault();
      this.handleChat();
      }
      }
      closeChatbot() {
      document.body.classList.remove("show-chatbot");
      }
      toggleChatbot() {
      document.body.classList.toggle("show-chatbot");
      }
      createChatLi(message, className, id) {
      const chatLi = document.createElement("li");
      chatLi.classList.add("chat", `${className}`);
      if (id) {
      chatLi.id = id;
      }
      chatLi.innerHTML = `${message}`;
      return chatLi;
      }
      async createThread() {
      try {
      const response = await fetch("api.openai.com/v1/threads", {
      method: "POST",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      });
      if (!response.ok) {
      const errorData = await response.json();
      console.error("Error creating thread:", errorData);
      throw new Error(`Failed to create thread: ${JSON.stringify(errorData)}`);
      }
      this.thread = await response.json();
      console.log("Thread Created:", this.thread);
      } catch (error) {
      console.error("Error in createThread method:", error);
      throw error;
      }
      }
      async generateResponse(chatElement, messageId) {
      const messageElement = chatElement.querySelector("p");
      try {
      await this.createThread();
      const messageResponse = await fetch(`api.openai.com/v1/threads/${this.thread.id}/messages`, {
      method: "POST",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      body: JSON.stringify({
      role: "user",
      content: this.userMessage,
      }),
      });
      if (!messageResponse.ok) {
      const errorData = await messageResponse.json();
      console.error("Error creating message:", errorData);
      throw new Error(`Failed to create message: ${JSON.stringify(errorData)}`);
      }
      const runResponse = await fetch(`api.openai.com/v1/threads/${this.thread.id}/runs`, {
      method: "POST",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      body: JSON.stringify({
      assistant_id: this.assistantId,
      model: "gpt-4-turbo"
      }),
      });
      if (!runResponse.ok) {
      const errorData = await runResponse.json();
      console.error("Error creating run:", errorData);
      throw new Error(`Failed to create run: ${JSON.stringify(errorData)}`);
      }
      const run = await runResponse.json();
      console.log("Run Created:", run);
      await this.checkStatusAndPrintMessages(this.thread.id, run.id, messageElement, messageId);
      } catch (error) {
      console.error("Error fetching response:", error);
      messageElement.classList.add("error");
      messageElement.textContent = "Oops! Something went wrong. Please try again.";
      } finally {
      this.chatbox.scrollTo(0, this.chatbox.scrollHeight);
      this.userMessage = null; // Reset the user message
      }
      }
      async checkStatusAndPrintMessages(threadId, runId, messageElement, messageId) {
      const delay = ms => new Promise(res => setTimeout(res, ms));
      while (true) {
      const runStatusResponse = await fetch(`api.openai.com/v1/threads/${threadId}/runs/${runId}`, {
      method: "GET",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      });
      if (!runStatusResponse.ok) {
      const errorData = await runStatusResponse.json();
      console.error("Error retrieving run status:", errorData);
      throw new Error(`Failed to retrieve run status: ${JSON.stringify(errorData)}`);
      }
      const runStatus = await runStatusResponse.json();
      console.log("Run Status:", runStatus);
      if (runStatus.status === "completed") {
      const messagesResponse = await fetch(`api.openai.com/v1/threads/${threadId}/messages`, {
      method: "GET",
      headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${this.apiKey}`,
      "OpenAI-Beta": "assistants=v2",
      },
      });
      if (!messagesResponse.ok) {
      const errorData = await messagesResponse.json();
      console.error("Error retrieving messages:", errorData);
      throw new Error(`Failed to retrieve messages: ${JSON.stringify(errorData)}`);
      }
      const messages = await messagesResponse.json();
      console.log("Messages Retrieved:", messages);
      const assistantMessages = messages.data.filter(msg => msg.role === "assistant");
      if (assistantMessages.length > 0) {
      const lastMessage = assistantMessages[assistantMessages.length - 1];
      const content = lastMessage.content[0].text.value;
      messageElement.textContent = content; // Update the "Checking..." message
      }
      break;
      } else {
      console.log("Run is not completed yet, retrying...");
      await delay(3000); // Wait for 3 seconds before checking again
      }
      }
      }
      async handleChat() {
      this.userMessage = this.chatInput.value.trim();
      if (!this.userMessage) return;
      this.chatInput.value = "";
      this.chatInput.style.height = `${this.inputInitHeight}px`;
      const messageId = `msg-${Date.now()}`;
      this.chatbox.appendChild(this.createChatLi(this.userMessage, "outgoing", messageId));
      this.chatbox.scrollTo(0, this.chatbox.scrollHeight);
      setTimeout(() => {
      const incomingChatLi = this.createChatLi("", "incoming", messageId);
      this.chatbox.appendChild(incomingChatLi);
      this.chatbox.scrollTo(0, this.chatbox.scrollHeight);
      this.generateResponse(incomingChatLi, messageId);
      }, 600);
      }
      }
      // Initialize the assistant
      const assistant = new Assistant(
      "YOUR API-KEY HERE",
      "YOUR ASSISTANT-ID HERE"
      );

  • @mcombatti
    @mcombatti Před rokem +6

    It's bad practices to include API key in Javascript. Anyone who views the bot could view your secret key, & run your API account thru the roof astronomically.

  • @ammarabhatti8261
    @ammarabhatti8261 Před 5 měsíci +3

    I've completed this project now anyone tell me how to solve API issue cuz I cant find it on stack-overflow if there is error 429 (too many requests ) and it is expired how will I solve this

    • @ANUJAGUPTA-jx5ri
      @ANUJAGUPTA-jx5ri Před 4 měsíci

      same , im getting that error, what did you do to resolve it?

    • @ammarabhatti8261
      @ammarabhatti8261 Před 4 měsíci

      @@ANUJAGUPTA-jx5ri the only solution was to make a new id and generate API key, we can't use free API if we are already using openapi for a long time.... They offer free APIs to new users only (for some time )you should make new id and then generate your API key that will work .... May be there's another solution but I haven't found any yet

    • @yashmadaan4024
      @yashmadaan4024 Před 3 měsíci

      Same error is coming to me also!
      Did you get the solution of it ?

    • @caidenmacgregor3271
      @caidenmacgregor3271 Před 29 dny

      Same, anyone have a solution?

    • @KoYanNaing-b5v
      @KoYanNaing-b5v Před 11 dny +1

      I believe u have to spend 5 dollars for the API to work

  • @LuckyRathod20
    @LuckyRathod20 Před 10 měsíci

    Nice🙂

  • @salonirajput6690
    @salonirajput6690 Před 11 měsíci

    Your content is awesome but can you please start explaining the code instead of using music 🎵 🎶 . It's a request ☺️

  • @Jhunti44
    @Jhunti44 Před rokem

    I'm able to get it worked in my asp support chat project. i'm just gonna figure out how to save to the convo in the DB.

  • @Abid.kanwal
    @Abid.kanwal Před rokem

    sir make a tutorial about " About us page generator, contact us page generator, terms and conditions page generator, disclaimer page generator and also privacy policy page generator. please please please please.

  • @christianjayenclona4652
    @christianjayenclona4652 Před 3 měsíci

    Is this chatbot can be integrated to database for fetching data like customer orders

  • @ShankarKaligi
    @ShankarKaligi Před 2 měsíci

    nice

  • @X3NOGLADIAT0R850
    @X3NOGLADIAT0R850 Před 3 měsíci

    guys im getting authorization error code 401 errors, i put in the api key in the authorization bearer im also signed in open ai how do i fix this

  • @sujonpramanik1151
    @sujonpramanik1151 Před rokem

    awesome project

  • @alelimiranda8006
    @alelimiranda8006 Před 4 měsíci

    What is the content of material-symbols-outlined?

  • @chatgpt6628
    @chatgpt6628 Před rokem

    Hi Great Please Show me How to Add Custom Data i mean Custom Response and Custom Answers PLZ PLZ

  • @aaryan1i3u82uru3
    @aaryan1i3u82uru3 Před 2 měsíci

    i tried doing it but when i used a new OpenAI API Key, it always says "Oops! We are having trouble generating the response at this time". i've tried everything but it still doesn't work. what do i do?

    • @CodingNepal
      @CodingNepal  Před 29 dny

      Please read the pinned comment for this.

  • @rxdeveloper873
    @rxdeveloper873 Před rokem +4

    it's great and thanks but I have followed all your steps in the video and whenever I try to chat there is an error and the console says "You didn't provide an API key. You need to provide your API key in an Authorization header" Although I have put the API as you did in the video

    • @kunalpawar7527
      @kunalpawar7527 Před 11 měsíci +2

      Same here bro. Pls reply if your issue is solved now.

  • @knowledgeisdone
    @knowledgeisdone Před rokem +1

    4th comment pin pls and can you make a sidebar that can randomize any photo and set it and is fixed on top and also save in localstorage. And also shows his name and age.
    For example:


    Save
    Edit
    // Get elements
    const nameInput = document.getElementById('name');
    const roleInput = document.getElementById('role');
    const imageInput = document.getElementById('image');
    const saveButton = document.getElementById('save-button');
    const editButton = document.getElementById('edit-button');
    // Check if data exists in local storage
    if (localStorage.getItem('userData')) {
    // Retrieve and populate data from local storage
    const userData = JSON.parse(localStorage.getItem('userData'));
    nameInput.value = userData.name;
    roleInput.value = userData.role;
    imageInput.disabled = true;
    saveButton.disabled = true;
    } else {
    editButton.disabled = true;
    }
    // Save data to local storage
    saveButton.addEventListener('click', function() {
    const userData = {
    name: nameInput.value,
    role: roleInput.value
    };
    localStorage.setItem('userData', JSON.stringify(userData));
    nameInput.disabled = true;
    roleInput.disabled = true;
    imageInput.disabled = true;
    saveButton.disabled = true;
    editButton.disabled = false;
    });
    // Enable editing
    editButton.addEventListener('click', function() {
    nameInput.disabled = false;
    roleInput.disabled = false;
    imageInput.disabled = false;
    saveButton.disabled = false;
    editButton.disabled = true;
    });
    In sidebar. The photo is fixed at top and in the place of role there are radi🥺 os.tje 🥺 format 🥺 can 🥺 look 🥺 like 🥺 this 🙏:
    (Image 🙏) (Name 🙏)
    (Image 🙏) (age 🙏)•(role 🙏)
    Please 🥺 it's 🥺 my 🙏 request 🥺🥺🥺🥺🥺🥺🙏🙏🙏🙏🙏🙏🥺🥺🙏🥺🥺

  • @abdulwahabAlani
    @abdulwahabAlani Před rokem +2

    Nice bro but please in The future video please explain in detail so we will understand the code better instead of using background music

  • @ruchitshah9954
    @ruchitshah9954 Před rokem

    uncaught TypeError: Cannot read properties of null (reading 'addEventListener')

  • @ritikmanta0028
    @ritikmanta0028 Před 10 měsíci +1

    Bro do we need to work on back-end for this ?

  • @nghiahoang9201
    @nghiahoang9201 Před rokem +1

    dear bro.
    I want to push the file to github, to deploy for friends to use,
    but the file contains the api key.
    so is there any way to deploy?

    • @KaptanSingh-oy1bp
      @KaptanSingh-oy1bp Před rokem

      Bro, Are you solved this problem? Because i am facing same problem.

    • @nghiahoang9201
      @nghiahoang9201 Před rokem

      @@KaptanSingh-oy1bp
      As far as I know, putting the API key into the evn variable (.evn), then putting the .evn file into the .gitignore file solves the API leak problem. But I get an error when I import the .evn variable into the .js file

  • @saggysshorts
    @saggysshorts Před 11 měsíci

    Omg that’s what I’m finding on CZcams since last two months 😭

  • @azzamhaer
    @azzamhaer Před rokem

    Please make youtube video downloader in php. i've done subscribed you with 3 account😉

  • @meetpitroda4217
    @meetpitroda4217 Před 10 měsíci +1

    How to make government rule Regulations chatbot
    Can be created by. Website api key like government api key

  • @giorgishautidze
    @giorgishautidze Před 21 dnem

    can i copy and paste on editor pls

  • @user-dk5zf8fq7h
    @user-dk5zf8fq7h Před 9 měsíci

    Bro one small doubt.you implement the package how to modify example "hi to reply message how can i help you"... Please tell me bro... Waiting for you bro....

  • @m1ke79
    @m1ke79 Před měsícem

    hey mate!
    is this chatbot free to use? even for commercial projects?
    best regards,
    mike :)

    • @CodingNepal
      @CodingNepal  Před měsícem

      Hey Mike, this chatbot is free for any use.
      Thanks!

  • @koushiksarkar1999
    @koushiksarkar1999 Před rokem

    Scientific calculator for engineering study make it bro

  • @tasneemayham974
    @tasneemayham974 Před 8 měsíci

    Brother, may you please make a video on how to continue from here to hide our API key?
    Because, we cannot host this chatbot as the API key is hardcoded into our key, so may you please make a video on how do we evade this problem?

  • @mg882
    @mg882 Před 5 měsíci

    Do you use websocket?

  • @IFGaurav
    @IFGaurav Před 5 měsíci

    can i use custom info for this chatbot?

  • @user-cb4dh2gx5e
    @user-cb4dh2gx5e Před 3 měsíci +1

    api key is free or paid

  • @flash-e4c
    @flash-e4c Před měsícem

    Yeah Is it using Internet to answer questions

  • @abgaming4545
    @abgaming4545 Před 11 měsíci

    what is the import url in the css code can u send this ????

  • @priurajj5385
    @priurajj5385 Před 2 měsíci

    Launch json configuration error what to do

  • @flormonserratlazaroflorent5675

    una pregunta, si quisiera usar este chatbot enlazado con una base de datos? si se podria? en vez de usar OpenAI?

    • @CodingNepal
      @CodingNepal  Před 26 dny

      Yes! You can configure the chatbot to request responses from your own database instead of OpenAI. You have the flexibility to customize it as needed.

    • @flormonserratlazaroflorent5675
      @flormonserratlazaroflorent5675 Před 26 dny

      @@CodingNepal y si quiero poner una imagen en el boton, y otra imagen en el icono en vez del robot se puede?

  • @BrainBoostAI820
    @BrainBoostAI820 Před 4 měsíci

    For the API usage, do you have to pay for it after using it once?

    • @SpeedyPaws-zk1tp
      @SpeedyPaws-zk1tp Před 3 měsíci

      yes, you need to add some credits to your openai account

  • @HoangNguyenViet-n6z
    @HoangNguyenViet-n6z Před měsícem

    Can you guide me to use other free APIs

  • @m.areeshrashid705
    @m.areeshrashid705 Před rokem

    Please Resume Generator HTML CSS JavaScript & Create ReactJS Project.

  • @witcet
    @witcet Před 8 měsíci

    Api key paste karne ke baad bhi error aa raha hai defeat wala, api key pasted correctly, plz help me what I do

  • @yogeshnoob1121
    @yogeshnoob1121 Před rokem

    its showing something went wrong please help

  • @bachduy3807
    @bachduy3807 Před 2 měsíci

    I want integrative with java servlet , bro can u help me ? 😢

  • @9-xyz-cba
    @9-xyz-cba Před rokem

    Please Create like and comment functionality using ajax and php.

  • @yousufansari1999
    @yousufansari1999 Před 10 měsíci

    Hi sir Im used your chatbot my isnot workihng

  • @1240JunaidShaikh-ve9mq
    @1240JunaidShaikh-ve9mq Před 10 měsíci

    Y I'm getting the something went wrong error.. I did checked tha code it's same and I created my own api key also .. can u please help ?

  • @avinashmr3947
    @avinashmr3947 Před 7 dny

    bro how you add that hi image in html code i con t understand

  • @aakashgautam5260
    @aakashgautam5260 Před rokem +1

    Bhaiya ji from your description the source code is never downloaded🙁

    • @CodingNepal
      @CodingNepal  Před rokem

      Source code link: www.codingnepalweb.com/create-chatbot-html-css-javascript/

  • @SIRIVURIVENKATASIVAVARMA

    i need source code its not available in website bro?

    • @CodingNepal
      @CodingNepal  Před rokem

      Source code has bee uploaded. Link is in the video description.

  • @Movie_explode
    @Movie_explode Před rokem

    how to embed on website

  • @vishalrahangdale3624
    @vishalrahangdale3624 Před rokem

    I make video from this channel with explanation in hindi

  • @DeepakKumar-ck7pn
    @DeepakKumar-ck7pn Před 10 měsíci

    How Solve the problem Too Many Request

  • @Parthkothawade
    @Parthkothawade Před 6 měsíci

    Nowadays Nepal is getting smarter and challenging other developer...

  • @realkidding1213
    @realkidding1213 Před rokem

    make it on using socket

  • @AdventureIsTheLife01
    @AdventureIsTheLife01 Před rokem

    Sir how you learnt Javascript plz telll me !!!!!!
    anything will help !!!!
    javascript part was literally hard for me..

  • @snowqueen2965
    @snowqueen2965 Před 3 měsíci

    I got the 429 to many request error while trying to get response from server.. How to resolve it.. Pls tell me as soon as possible

    • @CodingNepal
      @CodingNepal  Před 3 měsíci +1

      It seems OpenAI no longer provides free credits for API usage. The minimum cost to get started is now $5. Once the payment is made, the chatbot should work as expected.

  • @a.asupreme3318
    @a.asupreme3318 Před 6 měsíci

    i love you tank yoiu

  • @ajayrathod7585
    @ajayrathod7585 Před 2 měsíci

    is anyone successfully run the provided code? i'm getting the same error after creating the new account for api!! what can i do please suggest me..

    • @CodingNepal
      @CodingNepal  Před 29 dny

      Please read the pinned comment for the solution.

  • @celvinang276
    @celvinang276 Před 5 měsíci

    "If I may ask, what algorithm does this chatbot use?"

  • @yubiroaster6285
    @yubiroaster6285 Před rokem

    Wow❤

  • @zohamitkar
    @zohamitkar Před 2 měsíci

    can it give any answers like chatgpt or other AI's???

    • @CodingNepal
      @CodingNepal  Před 29 dny

      Yes, it uses OpenAI API to generate response so it give answer like ChatGPT.

  • @anuradhajayasinghe1651
    @anuradhajayasinghe1651 Před 4 měsíci

    🙂🙂👏