Inspiration

Having seen the use of chatbots on websites, the Hastings Direct story convinced me that I wanted to try and create a chatbot with a difference.

What it does

Current you can run the chat.js node file in the terminal and it uses the OpenAI API, to give both answers from Chat GPT 3.5 turbo and also remember the existing chat had while in conversation with the chatbot.

How we built it

This was using node.js.

In the chat.js file, I am using readline from node to create the interface to respond to the user. When a new message is typed, the chat completion is fetched, using OpenAI API, and the response is then output back to the user.

If the user asks a further question, it will not only take the message, but the history of the current chat as well before providing a response.

There is a starting question from the AI, and to end the chat type 'exit'.

Challenges we ran into

Attempted to create a front-end in React, to give the chatbot a better UI, but passing the responses to the frontend proved difficult.

React had an issue accepting objects, and in the time frame I was unable to identify how to pass to the frontend.

Accomplishments that we're proud of

Having never built a chatbot before I am very happy I was able to use environment variables to safely secure the API, then call the API to be able to use the power of Chat GPT in the terminal.

Give's really good grounding for future work in this area, especially creating frontend UI.

What we learned

Jumped too quickly from the terminal application to React. Spent time building a frontend UI before proving I able to pass data to the frontend and display it for the user.

What's next for Hastings Webchat

Develop a frontend to the chatbot, initially in very basic vanilla javascript, then begin to build a more significant UI for the frontend.

Eventually adding realtime data to the chatbot as well.

Built With

Share this project:

Updates