https://discord.gg/botpress logo
Bot that retrieves the URL of the page viewed, tod...
# 🤝help
c
Hello, I'm not a developer and tried to create a bot with AI, but I couldn’t get it to work. I’d really appreciate advice on how to build the following setup: Before any user interaction, the bot should retrieve: - the page URL - today’s date - whether the user interacted with the bot in the last 7 days Based on the URL and time of year, the bot should: - choose the correct start node (e.g. "Product") - load values like disp_choix, intro, link - auto-open the chat window if needed (and no recent interaction) I plan to use a table (TargetingTable) with these fields: - url_pattern (String): part of the URL to check - start_date, end_date (String): MM-DD format - year (optional): specific year or empty for all years - node_depart, disp_choix, intro, link - auto_open (Boolean): true/false - last_interaction_check (Boolean, optional): true = check for interaction in the last 7 days The URL doesn't need to match exactly—just include the url_pattern. Also, I want to manage the rules outside the injected code (so no redeployment needed when editing them). From what I understood, I need to: • create and query a dynamic table • use sendCustomEvent to pass the URL to the bot • use "Expression" cards in Botpress to route to the right node based on node_depart Thanks in advance to anyone who can help or guide me!
p
I would suggest you implement similar logic to the following video:

https://youtu.be/dDGY_wHFt3s?feature=shared▾

If there's anything specific you'd like to know, let me know :))
c
Thank you I really can't do it... Could someone give me the code to inject into my pages so that the bot retrieves the url of the page visited by the user when the page loads (at least before any interaction with the bot) ? As well as what to put in the flow ?
I've tried a lot of different ways with the help of several AIs, it never works. Is it really possible to retrieve the URL of the page visited by the user before any user interaction with the page or the bot ?
p
You should be able to use this to access the url of your page: const fullURL = window.location.href;
c
Yes, I used window.location.href: I put a client-side code to send it to the bot and a Trigger to retrieve it. But it doesn't work, despite several attempts with different methods. If anyone has 10 minutes to try...
Nobody ?
5 Views