Python Chat Bot Tutorial – Chatbot with Deep Learning (Part 1)

Ever wanted to create an AI Chat bot? This python chatbot tutorial will show you how to create a chatbot with python using deep learning .


Download JSON File:

Text-Based Tutorial:


💻 Enroll in The Fundamentals of Programming w/ Python

📸 Instagram:
🌎 Website
📱 Twitter:
⭐ Discord:
📝 LinkedIn: …
📂 GitHub:
🔊 Podcast:

💵 One-Time Donations: …
💰 Patreon:

⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡

– Tech With Tim
– Python Chat bot
– Chat bot python tutorial
– Python chat bot tutorial
– Python Tutorials
– Create chatbot with python


    1. Simply work.. nobody seems to care enough to help me with my issue.. even when I offer money. I joined your discord server and honestly am very discouraged.

    2. @Tech With Tim When I triy to install tflearn it doesn’t work but everything else does. I am using PyCharm linked with Anaconda on mac. How could I fix this?

  1. Great tutorials Tim. I subscribed and will be following closely. I am getting an error “NameError: name ‘model’ is not defined” when I add the bbag_of_words and chat functions. When I call the chat function, after I type “hello”, I get the error – “NameError: name ‘model’ is not defined” .

  2. Hello Tim, I would like to use my chatbot to help the customers on my website. Do you know, where can I find a dataset to improve my chatbot for a marketing discussion?

  3. If you use venv you can set a virtual environment with all of your environment settings like python version, no need to uninstall other versions.

  4. Hey Tim, I just started programming again and was trying to follow osome of your tutorials. But as of writing this most module versions have been updated and its reallyhard to keep track of which install of whc mdule works with each other.
    Again as of writing this the current combo of packages that work:
    Python 3.6 !=3.7/8
    nltk==1.14.0 (latest)
    numpy==1.16.6 !=1.17 or above
    tensorflow==1.15, !=2.x and above
    tflearn==0.3.2 (latest)
    Please like this if this helped you solve any problems you ran into so that others can see it 🙂

    I also ran into “please install/reinstall (curses/h5py/scipy for an optimal experience”)
    resolved by pip install (scipy, h5py, windows-curses)

    This wasn’t a huge problem but is it possible for future vids/tuorials to specify/show which package you have installed to run the program.

    Thx for the great vid tutorial.

    1. I have installed all the packages as told but still I am getting this error
      please help

      (chatbot) C:UsersIOTLABDesktopkbot>python
      2020-02-14 11:09:40.205540: W tensorflow/stream_executor/platform/default/] Could not load dynamic library ‘cudart64_100.dll’; dlerror: cudart64_100.dll not found
      2020-02-14 11:09:40.210738: I tensorflow/stream_executor/cuda/] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
      WARNING:tensorflow:From The name tf.summary.merge is deprecated. Please use tf.compat.v1.summary.merge instead.

      WARNING:tensorflow:From The name tf.summary.FileWriter is deprecated. Please use tf.compat.v1.summary.FileWriter instead.

      WARNING:tensorflow:From The name tf.GraphKeys is deprecated. Please use tf.compat.v1.GraphKeys instead.

      WARNING:tensorflow:From The name tf.get_collection is deprecated. Please use tf.compat.v1.get_collection instead.

      WARNING:tensorflow:From The name tf.add_to_collection is deprecated. Please use tf.compat.v1.add_to_collection instead.

      WARNING:tensorflow:From The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

      WARNING:tensorflow:From The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.

      WARNING:tensorflow:From The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

      WARNING:tensorflow:From The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

      WARNING:tensorflow:From calling TruncatedNormal.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
      Instructions for updating:
      Call initializer instance with the dtype argument instead of passing it to the constructor
      WARNING:tensorflow:From The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead.

      WARNING:tensorflow:From calling reduce_sum_v1 (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
      Instructions for updating:
      keep_dims is deprecated, use keepdims instead
      WARNING:tensorflow:From The name tf.log is deprecated. Please use tf.math.log instead.

      WARNING:tensorflow:From The name tf.trainable_variables is deprecated. Please use tf.compat.v1.trainable_variables instead.

      WARNING:tensorflow:From The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

      WARNING:tensorflow:From The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

      2020-02-14 11:09:42.065833: W tensorflow/stream_executor/platform/default/] Could not load dynamic library ‘nvcuda.dll’; dlerror: nvcuda.dll not found
      2020-02-14 11:09:42.069888: E tensorflow/stream_executor/cuda/] failed call to cuInit: UNKNOWN ERROR (303)
      2020-02-14 11:09:42.075515: I tensorflow/stream_executor/cuda/] retrieving CUDA diagnostic information for host: DESKTOP-01MHI4D
      2020-02-14 11:09:42.079406: I tensorflow/stream_executor/cuda/] hostname: DESKTOP-01MHI4D
      2020-02-14 11:09:42.082188: I tensorflow/core/platform/] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
      WARNING:tensorflow:From The name tf.summary.scalar is deprecated. Please use tf.compat.v1.summary.scalar instead.

      WARNING:tensorflow:From where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
      Instructions for updating:
      Use tf.where in 2.0, which has the same broadcast rule as np.where
      WARNING:tensorflow:From The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.

      WARNING:tensorflow:From The name tf.global_variables_initializer is deprecated. Please use tf.compat.v1.global_variables_initializer instead.

      WARNING:tensorflow:From The name tf.local_variables_initializer is deprecated. Please use tf.compat.v1.local_variables_initializer instead.

      WARNING:tensorflow:From The name tf.variables_initializer is deprecated. Please use tf.compat.v1.variables_initializer instead.

      WARNING:tensorflow:From The name tf.get_collection_ref is deprecated. Please use tf.compat.v1.get_collection_ref instead.

      Run id: FNADY6
      Log directory: /tmp/tflearn_logs/
      Training samples: 20
      Validation samples: 0

      Traceback (most recent call last):
      File “”, line 79, in
      File “”, line 308, in load
      self.trainer.restore(model_file, weights_only, **optargs)
      File “”, line 490, in restore
      self.restorer.restore(self.session, model_file)
      File “”, line 1282, in restore
      ValueError: The passed save_path is not a valid checkpoint: C:UsersIOTLABDesktopkbotmodel.tflearn

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File “”, line 81, in, output, n_epoch=1000, batch_size=8, show_metric=True)
      File “”, line 216, in fit
      File “”, line 339, in fit
      File “”, line 816, in _train
      tflearn.is_training(True, session=self.session)
      File “”, line 95, in is_training
      File “”, line 798, in eval
      return _eval_using_default_session(self, feed_dict, self.graph, session)
      File “”, line 5407, in _eval_using_default_session
      return, feed_dict)
      File “”, line 956, in run
      File “”, line 1103, in _run
      raise RuntimeError(‘Attempted to use a closed Session.’)
      RuntimeError: Attempted to use a closed Session.

  5. awsome vid thanks again for making this stuff so incredibly accessible right now I am actually moving from my job as a junior data scientist at one company to a much higher role as a senior ML data scientist at another and I was wondering what would you recommend as the best way to push my knowledge to the level it needs to be at for that kind of jump.

    Still fairly new to Machine Learning and feel I just did very well in the interview and got a bit lucky so I really want to make sure I up my game before I actually start the job in a few months so I don’t blow this opportunity. Any advice you could give would be amazing thanks.

  6. What makes this chatbot ‘simple’ and ‘slightly intelligent’? How would you go about making it more complex?

  7. Hey Tim, are you planning on having an updated version of a chatbot, Im completely lost as a beginner and a lot of tools are updated. Seems selfish because this video was done a year ago, but you’re a great teacher and I actually understand what you’re teaching. Thanks

  8. For users having errors with installing tensorflow through pip,
    Make sure you’re using python 64 bit and not 32 bit. that pretty much solved the trick for me

    1. Even I faced this issue and after trying for many hours found that it was a bit issue between Python and OS. After that I have installed TensorFlow many times in different environments.
      Use below command to know your Python bit version
      import struct
      print(struct.calcsize(“P”) * 8)

  9. God bless you. I am despairing while writing my bachelor thesis. I cannot manage building a bot. Your instructions are very clear and helpful and for the first time i get further than installing tflearn or some other package before getting an error message. ^-^

  10. Hi Tim I get an error message “unindent does not match any outer indentation level (, line 14) ” which you want us to write following ” words = []” – thanks for your help letting me test the code and train the chatbot

  11. For the people wondering why when you make the amount of epochs higher the chatbot doesn’t get better: #1 the dataset is very very (very) small. Find a public dataset of q”s and a’s and use that instead. #2 it will overfit if your dataset is too small so geta dataset of at least 1000 q”s and a’s.

  12. For everyone who wants to follow this tutorial, make sure you have Python 64 bit instead of 32 bit, otherwise Tensorflow won’t work.

    1. OMG thank you so much 🙏
      I was wondering why it couldn’t find a matching version of tensorflow 🤨
      Cheers buddy 👍🤙🤙

  13. @Tim, this cannot be pure coincidence that EVERY time I search for something python related on youtube, one of your videos show up. I am surprised by the diversity of python applications you have covered. Be in Django (first time I found your tutorial), JavaScript, Machine Learning, Data Science, Interview tips, and now a chatbot. I have learned a lot from your videos from time to time. I’d be delighted to meet you if you ever come to Seattle again. Keep up the great work.

  14. If you get error with installing Tensorflow, you need to go to registry editor HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlFileSystem and set LongPathsEnabled to value 1

  15. I’ve been doing a codecademy course on chatbots, this will be an excellent means of assistance. Thank you very much.

  16. you can use alot of if functions to mimic it but in Python 3.9 and it would be more simple-to-write. That was for if you don’t want it to Be Open-Source and Public/for Business Purposes.

  17. Nice example of how to create a basic chatbot in Python – thanks for taking the time to make the vid

  18. Awesome tutorial Tim so cool get this project started finally! I’ll be here on your channel for a while working on this project learning cool stuff

    PyCharm was so hard install but finally got it up and running, it looks okay but honestly I really miss my old VS Code IDE was so comfortable there (VS Code tho doesn’t seem want import our libraries and modules. It took like 2hrs to install PyCharm and get all libraries imported and errors cleared. In lower right of window reads Python Interpreter Version 3.10 what you think will run okay? I don’t know how to change and I don’t see any errors yet

    Okay see you in next tutorial 🤘

    1. I got this chat bot working eventually (recently) in a conda environment, using VS Code. I am new to creating requirement.txt files , but the versions of the packages I used are:
      numpy == 1.22.3

      tflearn == 0.5.0
      tensorflow == 2.8.2
      nltk = 3.7
      python_version == 3.8.5
      Not sure about the Python version. It might just work with 3.10 as well.
      I had mostly difficulties in getting the Python packages to work.
      Anyway, just wanted to leave a note here that you can still get this to work. For me, a beginner, it took a while, but I learned a lot from it. I also found a lot of useful tips in the comments on here as well. I hope this one helps too. Enjoy!

Leave a Reply

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

© 2024 EVERYTHING CHATGPT - WordPress Theme by WPEnjoy