Can I re-float the post from @xpandertn regarding ...
# 🤝help
r
https://discordapp.com/channels/1108396290624213082/1128385867145302207 I agree with @cool-hospital-14870 it doesn't work as suggested in docs. Known issue? Workarounds?
a
Hey @ripe-cat-27461, session variables are supported we just haven't added them to the type/linter yet, so they get a scary red underline.
r
Hey @acceptable-kangaroo-64719, I did ignore the grumbles and run the code. And it didn't seem to work. Was it because my session variable isn't about Peter The Panda hahahahahha. Off to try again now that the Malaysian Oracle has pronounced ....
a
what code are you running? Can you share some screenshots?
r
@acceptable-kangaroo-64719 I cut you a quick video here

https://youtu.be/g531_Tqehxc

Let me know what I've done wrong. If you hear tell of any video that needs editing at Botpress, hit me up. My video editing skills are working better than my bot building attempts at the moment
a
Thanks for the video! What was the error in the logs? Because I copied your exact setup and its working on my end. Other things to try: * refresh the page * log out & log back in again

https://cdn.discordapp.com/attachments/1134432116638236754/1134461048716537876/image.png

c
I'll have to retry myself. I never got them to work appropriately
b
hello thread!
can I suggest watching this video:

https://www.youtube.com/watch?v=2THIkCcehHM

there are basically two ways to use session variables, which essentially just let you "reference variables across workflows"
r
@acceptable-kangaroo-64719 logged out, had some lunch. Logged in. Still the same. Error is ...
In the execute code card ...

https://cdn.discordapp.com/attachments/1134432116638236754/1134489526090350613/image.png

Error executing action "inline-ins-04721c839a.js" in flow:Main:node:detect_intents [SyntaxError, Invalid or unexpected token]
@bumpy-butcher-41910 As you so eruditely explain in your "Reference variables across workflows" video, we have to go to a bit more trouble to pass workflow scoped variables around. That's exactly why I'm interested in session variables, which - although I haven't been able to create one successfully yet - I assume that when I do, I'll be able to just grab it from everywhere. Simples! Let me know if I've got this right.
b
eruditely!! that's big praise
in theory you're right, but my understanding here is that session variables are a kind of "hacky" workaround, and they don't work together well with different workflows etc
r
@bumpy-butcher-41910 Re: "eruditely" as a human language model, I have access to such KBs as "thesaurus.com"
b
hahahaha
r
@bumpy-butcher-41910 Actually, Botpress Docs actually mention the use case I want session variables for - building a shopping cart. Clearly, we don't want to forget what the shopping cart items were while we're collecting the shipping address. And we probably don't want to be forced into designing the bot as just one workflow for the sole purpose of being able to remember useful things.
@bumpy-butcher-41910 Anyway, though, it's all a moot point if I can't get them to work.
@bumpy-butcher-41910 If things start to get busier over there and you need to off-load video editing - which is laborious. I'm here to help. Hit me up if you need to see a showreel. Just need to have a way of making money if I can't get session variables to work 😉
b
yeah that's a fair point - as we expanded the range of what bots can do it became necessary to redesign session variables so they wouldn't break anything else - i.e. as input/output variables. the session variables you're asking about are really just a legacy feature hanging on for dear life
noted about video editing 👀
r
@bumpy-butcher-41910 >> the session variables you're asking about are really just a legacy feature hanging on for dear life. Hmmm. As a full stack developer, with more years under my belt than I care to reveal just now, I would suggest that we are desperately going to need variables which last as long as the conversation does. It's a fundamental issue in web development due to the "stateless" nature of HTTP.
I mean, if early on, we find out the user's name is "Bill" and we got that in greeting-workflow. We can personalize all other workflows with his name. Because he's not going to change his name during the conversation. But then if he's actually returning something and we're in the return-workflow, why not be able to pull it from the session scope? Pretty normal in web dev
b
honestly I don't disagree and I'm happy to defer to your authority here - what I'm going to suggest is, if you have the time, can you write this up in #1111026806254993459? this is really valuable feedback and will be more impactful coming from you than filtered through me!
r
@bumpy-butcher-41910 errrm. Since it's already implemented, wouldn't it be an unnecesary distraction?
@bumpy-butcher-41910 Docs seem to be pretty clear it's a permanent feature. See image below. And for exactly the normal use cases you get in web dev too

https://cdn.discordapp.com/attachments/1134432116638236754/1134498079760990289/image.png

@acceptable-kangaroo-64719 @bumpy-butcher-41910 Got it working following your example. It seems the session variable needs to be declared with single quotations makes. For example
session.userfirstname = 'Janice'
whereas the docs code example as you can see in the image above, uses double quotation marks. Who knew !
@acceptable-kangaroo-64719 session variables - i.e. last as long as the conversation does and can be referenced from any workflow - are here to stay, right? Please. Pretty please
a
I think so, yeah
r
@acceptable-kangaroo-64719 @bumpy-butcher-41910 Appreciate your input 👏
f
Hi, I have replied to the video with the below: 1) for the generative AI to work, only click enter, no need to click on the stars (0:50). When you clicked it, you disabled it. 2) instead of session, try event.state.session (1:35) 3) the double quotes around the "Hello world" are wrongly formatted. (1:35) Hence, I did a PR to update the documentation
Thanks for clearing it for us
r
@famous-jewelry-85388 Hey there. Understood and much appreciated.
I did get it working: the double quotation marks seemed to be the main issue
2 Views