The Product class inherits from the Base class, which declares the mapped classes into tables. The session object manages the persistence layer and does the ORM operations. That instance is passed into the sessionmaker function to create a Session class which is instantiated to create a session object. You then define the engine instance which is the starting point of your application. You can choose your own specifications depending on your case. The port which is 5432 by default for PostgreSQL.The database is the name of the database you need to access in this tutorial it's mydb.The username and password of your database.Create a new database - for this project, we would call it mydb.Īs you can see, the url object defines the database URL with the following options: Initiate the Python project and the PostgreSQL databaseĭownload and set up PostgreSQL if you haven’t already. To be able to create these two records in the database, you should define a schema and then create a table based on that schema. Say, you have two products in your inventory: If you have no idea what ORM is, consult this wiki page! If you're new, create a free account here. To follow along with this tutorial, you need to have the following: Or, your inventory didn't have that particular product in the first place.This particular product is finished and it's no longer in the inventory.Saying that the product is not available means one of two options: When the client orders that product, the chatbot replies to place that order for them or says it's not available. This chatbot will fetch data from the PostgreSQL database and update inventory data in the database using the SQLAlchemy ORM.Īt the end of this tutorial, you'll be able to create a chatbot like so: It is then communicated with Pyngrok, which is a Python wrapper for ngrok that puts the FastAPI localhost on the internet. This chatbot is built using a FastAPI backend. You'll use Twilio's API to access the WhatsApp messaging product to let the clients send messages via WhatsApp and start the chatbot. In this tutorial, you will build this service using FastAPI, Twilio's WhatsApp messaging API, Pyngrok, and SQLAlchemy. This chatbot will help you engage with clients ordering your products and will tell them exactly about the status of the product - if it's there in the inventory or not. With this chatbot, you'll retain your time and get a reliable result. Today, you're going to learn how to manage your products in the inventory with a WhatsApp chatbot. Or you can hire someone else to work but they might not be honest enough. You can manage it on your own but you'll lose a lot of your time keeping track of products there. Owning an inventory is a big deal only if you're able to manage it efficiently.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |