Automating orders using OpenAI, WhatsApp API, MySQL, and Mercado Pago
🙋Mateo Lafalce
✉️ mateolafalce@protonmail.com
🔑 My GPG public key
📚 Blog
Faced with the need to automate order management for a local business in my city, it seemed like a perfect time to propose a solution using Artificial Intelligence through a chatbot interface.
For the proposed solution, we will need 5 components, all of which must be modular so that if we want to apply it to another domain, only the specific module files are modified:
* The web page proposed in the Github repository does not implement JWT or user management, but this is mainly because it is not the focus of this article.
Design
Workflow: A customer contacts via WhatsApp to buy a pizza, the system starts a conversation by responding with the products available at the moment. Once all the products the customer wants have been identified, the total with its corresponding subtotals is sent, asking the customer for confirmation along with a Mercado Pago payment link. Once the payment has been made correctly, the backend notifies the frontend to notify the pizza makers which pizza to make and where it should be sent.
Once the pizza is sent and the delivery driver has returned to the shop, the order is considered concluded.
There is still a need to implement an intelligent system to prevent overspending credits on the OpenAI API, by assigning weights to customers based on how many times they have purchased from the business.
The current implementation has the endpoints but not the direct connection with WhatsApp, as it requires prior validation as a legitimate business to use its API, so for now, the chat can only be accessed via inertia on the local host.
I hope this solution has provided value for any system or idea you have in mind and, above all, that it saves you a lot of time!!
This blog is open source. See an error? Go ahead and propose a change.