Anvil - Code For Chatbot
Anvil - Code For Chatbot
Anvil - Code For Chatbot
```````````````````````````````````````````````````````````````````````````````````
```````````````````
from ._anvil_designer import HomeTemplate
from anvil import *
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
import anvil.server
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
class Home(HomeTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run when the form opens.
```````````````````````````````````````````````````````````````````````````````````
`````````````````````
About
```````````````````````````````````````````````````````````````````````````````````
````````````````````
from ._anvil_designer import AboutTemplate
from anvil import *
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
import anvil.server
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
class About(AboutTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run when the form opens.
```````````````````````````````````````````````````````````````````````````````````
`````````````````````
Contact(feedback page)
```````````````````````````````````````````````````````````````````````````````````
`````````````````````
from ._anvil_designer import ContactTemplate
from anvil import *
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
import anvil.server
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
class Contact(ContactTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
#TODO: put items in designer
```````````````````````````````````````````````````````````````````````````````````
`````````````````````
Main(header or nav bar)
```````````````````````````````````````````````````````````````````````````````````
`````````````````````
from ._anvil_designer import MainTemplate
from anvil import *
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
import anvil.server
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
from ..Home import Home
from ..About import About
from ..Contact import Contact
from ..Pricing import Pricing
class Main(MainTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
self.content_panel.add_component(Home(), full_width_row=True)
```````````````````````````````````````````````````````````````````````````````````
```````````````
Pricing(Chat)
```````````````````````````````````````````````````````````````````````````````````
```````````````````
from ._anvil_designer import PricingTemplate
from anvil import *
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
import anvil.server
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
dict1 = dict()
class Pricing(PricingTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
```````````````````````````````````````````````````````````````````````````````````
``````````````````
### server code, add a module under"server code" then copy paste the following
code
```````````````````````````````````````````````````````````````````````````````````
`````````
import anvil.google.auth, anvil.google.drive, anvil.google.mail
from anvil.google.drive import app_files
import anvil.email
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
import anvil.server
from datetime import datetime
@anvil.server.callable
def add_contact_info(name, email, topic, question):
app_tables.contact.add_row(name=name, email=email, topic=topic,
question=question, time=datetime.now())
anvil.email.send(from_name="feedback form",
subject="Feedback form",
text=f"Feedback form from {name} ({email})\nRatings: {topic}\
nComment/Question: {question}")
```````````````````````````````````````````````````````````````````````````````````
``````````````````