hello everyone i am trying to build to my website a chatbot that will get data from woocommerce about my products (500+) and send it back to chatgpt 4 and answer the user the problem is it takes around 300,000 tokens for each action because the woocommerce api is scraping alot of data how i can specify the data he gets from the api? or to filter it i cant pay so much money for each action.
What is the error message (if any)?: Error in sub-node ‘OpenAI Chat Model‘
This model’s maximum context length is 16385 tokens. However, your messages resulted in 270253 tokens (270095 in the messages, 158 in the functions). Please reduce the length of the messages or functions.
I would say for a start you should be limiting your woo commerce search, you are obtaining a number of fields from the user such as min/max prices, category etc but you aren’t using that in the woo-commerce node. So when the AI tool is used it is just returning 50 product details not specific to what you are after.
What I would do is produce a daily output of your inventory and stock, say on a sheet, airtable, pinecone, etc… your choice. This should be done as a rag setup.
I would have a trigger and webhook set up to update the database once per day at start of business day, and after a product update, or inventory change (ie a purchase happens).
The second step is to have clear categories, and subcategories for the products. From there give each category a switch and separate agent that corresponds to specific details. Lest say the category is Shoes > nike> Travis Scott
I would connect an agent to have all of my category mapping and that first agent would determine what sub flow or connected agent is needed to perform functions for that product category.
Department store might have hundreds of thousands of products, descriptions etc… if have a rag database that is self served or is processed elsewhere will allow you to keep growing the machine, introduce self learning, and hopefully save you from running so many credits. Additionally, you can use an open source model to retrieve your rag information and then send it to your openai connected chat agent. This will also help you break up the cost of processing.
Hope this helps… Category mapping and clear product organization will be the hardest part everything else should fall into place.
Ok so they way I see it, you could either do a custom API call to woocommerce filtering the data returned or, some how reformat the data coming from the current node and then pass that to the model, reducing your token usage.
In the WooCommerce node you can just add additional fields to let the agent search on, just open the WooCommerce node and click Add option and add things like Min Price, Max Price, Search. With the latest update you can now just click on the button to the right of the field and let the model define the parameter, or you can use the fromAI I said about.
thanks bro its working!
now i only need to understand how to help the bot to understand better the question from the user because if i dont give him the exactly product name he dont find it.
Depending on the number of products you have in each category, you could create a sub workflow instead of a WooCommerce tool node which your bot could give the category and price range and it would return a list of just the product names and product IDs, this would reduce your token count and the bot could look for the product and do a specific product query using the product code if you need more information about the product.
Or if you are after a more robust solution which would scale you could also look at using a RAG database as described above which would allow for more fuzzy searches.