Git Product home page Git Product logo

group-exercise-jan-16's Introduction

Get started

Clone this repository. Open it in VScode and run

npm i

from the terminal. Start working by editing the ./src/pages/index.jsx file.

Info:

Example code for using the chatbot:

import { Chatbot } from "popcat-chatbot";

const chatbot = new Chatbot()
  .setName("Chat Bot")
  .setGender("Male")
  .setOwner("EEEF");

chatbot.chat("hello world").then(console.log).catch(console.error);

Task

Make a chatbot conversation app. We will use the "popcat-chatbot" package from npm, which is already a requirement in our package.json file.

In index.jsx, inside the Home class component, we will add:

An input field for the question we want to ask the chatbot. A "Send" button to ask the chatbot a question, or talk to them.

When user sends a question to the bot, create an object {question: the text inside the input, answer: answer received from the bot, timestamp: current timestamp, looks like this: 1671402915492}.

We will receive the answer from the chatbot by creating a chatbot instance object, and calling .chat() on it, which is a Promise, that gives us a response string from the bot.

Save the object in an array, and save that array to localstorage. Tip: Use componentDidUpdate();

When user loads the page, load answers from localstorage. Tip: Use componentDidMount();

Make a new "Answers" component, where we will display all the answers inside a div and two P tags, one for the question, one for the answer.

Optional: The Sort By Time button sorts the answer array by the timestamp in each answer. Use b.timestamp - a.timestamp.

Optional: Make the sort order(ascending or descending) by text and time buttons invert the sorting order every time you press the button.

group-exercise-jan-16's People

Contributors

doublemacro avatar hasanaytug avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.