How to use Python Chatterbot in HTML page?

Asked

Viewed 648 times

1

I’m developing a Chatbot in python, using the Chatterbot library. I wonder how I can "embed" this chatbot into an HTML page.

  • I’m a beginner.
  • Using USB Web Server

Follows the code:

# -*- coding: utf-8 -*-
from chatterbot.trainers import ListTrainer

from chatterbot import ChatBot

bot = ChatBot('Bot')

nome = input('Digite seu nome: ')

conv = [
    'Oi',
    'Olá',
    'Tudo bem?',
    'Estou bem obrigado'
]

bot.set_trainer(ListTrainer)

bot.train(conv)

print('-='*40)

print('Bem Vindo ao Chat!')

print('-='*40)

while True:

    quest = input('Você: ')

    response = bot.get_response(quest)

    if float(response.confidence) > 0.5:

        print('Bot:', response)

    else:

        print('Bot: Não entendi, isso não está na minha base de dados')
  • You need to use some Python Webframework to use Python in an HTML page for example. The ones I know are the Django and the Turbogears.

  • 1

    So that you can use an I.A in HTML, I indicate the AIML which is a language already totally directed to this area.

1 answer

0


You’ll need to study a bit about how HTTP requests and forms of HTML to serve a page that communicates with your server.

For the server itself, you have options like flask and the Django to receive and process the requests. Django is quite powerful, but it can be tricky to use for a beginner and you will most likely not need all of its features. I therefore recommend the flask, which is very simple and will suit you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.