AI Chatbot in Revit using Python

AI Chatbot in Revit using Python


Following my previous article on the C# Chatbot using the Revit API, I’ve decided to elaborate more on the fixed Chatbot in this article by creating an AI Chatbot using Python and Flask. This article informs the reader on the creation of a Chatbot using python and how its then added into Revit as a Web browser dockable plugin. 

No alt text provided for this image

Firstly, AI chatbots develop their answers to complicated questions using natural language processes and machine learning. These Chatbots operate more efficiently the more they are trained which means the more they are taught the more efficient the response to the user will be.

In comparison to a fixed Chatbot, an AI Chatbot system learns in accordance with its experiences rather than a data feeding process. AI Chatbots use algorithms whenever an input is received, they then analyze the input, form the context and thereafter provides the user with accurate results 

My inspiration for this AI Chatbot stemmed from one of the frequent problems we face when working with clients, which is support cases. A support case is when a client has a query regarding the Revit software and needs our prompt assistance. The current process to handle a support case is, the client calls in with their problem and any available technical staff assists. This process however has several problems mainly the turnaround time that the staff takes to resolve the problem queried.

The motive of the AI Chatbot is to provide solutions more promptly to users and to mitigate the issue of delayed solutions due to turn around times. This AI Chatbot will provide split-second reactions to the users and mitigate longer turnaround times . This AI chatbot would provide round the clock assistance which the technical resource could not.

To add the chatbot to Revit and collect all the user data, a dockable web browser plugin was used that points to the hosted chatbot on Heroku. 

No alt text provided for this image

The WPF plugin implements the IDockablePaneProvider Interface as shown In the figure below

No alt text provided for this image

The chromium web browser was used as seen in the figure below

No alt text provided for this image

Flask, Keras and Tensor Flow are used to build the chatbot to create the machine learning model.

The figure below indicates the app directory structure.

No alt text provided for this image

The libraries used to train the network and saving the model to be consumed by the flask app is shown below

No alt text provided for this image

Below is a snippet of the code used to prepare the training data to be fed to the neural network. A data.json file was used as a data source with a dictionary being used to represent the data. The data was sourced from the Autodesk Knowledge network and the accepted solutions provided to the clients. 

No alt text provided for this image

Figure below shows the final step in preparing the data for training. I create a test and a train list. 

No alt text provided for this image

For the deep learning model, a three-layer model is created with the first layer containing 128 neurons, the second layer having 64 neurons and the third output layer having neurons equal to the number of intents to predict. ReLu activation function is used for the first two layers whilst the SoftMax activation function is used in the third layer.

No alt text provided for this image

In summary we have 3 dense layers and 2 dropout layers. The total number of parameters in the model is 46,328 as seen below. Once this is done the next step will be to compile and train the model.

No alt text provided for this image

The model was configured to use the SGD (stochastic gradient descent) optimizer which is a Gradient descent (with momentum) optimizer. After compiling the model, the model is trained and saved to be used in our flask app.

No alt text provided for this image

The figure below shows the libraries to be used and the flask app routes. 

No alt text provided for this image

Below is a figure showing two functions, one that gets the user text and returns the tokens and the other that returns our words array for the chatbot to predict.

No alt text provided for this image

The following functions are for predicting the response. The functions use the chatbot_model.h5 file that was generated after the training to provide a response to the user.

No alt text provided for this image

Lastly, I’ve used some basic html and JavaScript that receives users input and displays bot responses as seen in the figures below.

No alt text provided for this image

Figure below shows the JavaScript code that gets user input and returns the bots response

No alt text provided for this image

In conclusion the AI Chatbot is meant to mitigate delayed turn around times and provide prompt feedback to users queries, my project is currently under Research and Development so your feedback would be appreciated towards the development of an efficient and user friendly Chatbot.

Please like, share and leave your comments and suggestions below. 





















Great job and we are looking to produce the similar kind of idea.

Like
Reply

I am fascinated and over the moon by great Idea. thank you. I would love to hear more on this topic

Like
Reply

Any development on this post?

Like
Reply

To view or add a comment, sign in

More articles by MJ Mthimunye

  • Automating Beam Rebar Detailing in Revit from Tekla Structural Designer

    Structural engineers and BIM teams have long faced the same friction: the design is done in one platform, and the…

  • GameStudio Pinball Viewer Proof of Concept

    Pinball machines have maintained a steady level of popularity over the years, appealing to a diverse audience across…

  • Automated Wall Finishes in Revit

    Wall finishes in a building model are materials or treatments applied to wall surfaces. They serve to enhance the…

  • Connect Revit to Power BI using SQL

    In today's data-driven world, the use of dashboards has become increasingly popular due to their numerous advantages…

  • React Native and 3D BIM

    3D BIM has been used for many years now and is recently being integrated with new BIM workflow processes. Being able to…

    2 Comments
  • C# Chatbot using Revit API

    There are many advantages to using chatbots. With chatbots you get to collect valuable data and metrics about each user…

    2 Comments

Others also viewed

Explore content categories