Basic Name capture not working
# 🤝help
c
Hi Anyone know why my most basic name capture is not working. Thanks in advance
a
I thinks its because you storing it in type (x), mine works fine and I can subject it to substring operations by changing my type of value to extract at the top to Raw-Input
c
Thanks @average-megabyte-82737 . I created a new Bot and got it working with the {object} type. Not sure why it worked second time round 😂
a
@clean-branch-56468 No problem happy to help, something cool I found about the object type is lets say you wrote Vernon Shaw and stored it in the object then workflow.object.firstname returned Vernon and Surname Shaw, not exact synatx but kinda nice to have that built in given that substring operations are abit wonky in botpress
c
Is that if you create your own 'object' variable? currently to access "Vernon", If I use the UI to create a variable 'name' to access "Vernon" i use
workflow.name.first
not sure if that makes sense?
a
Yeah that works perfectly, so to store in its own standalone variable instead of accessing multiple times down the line you could speed up resources by doing it once after the initial capture. For example clientFirstName = workflow.name.first and then instead of doing that workflow access you just call your clientFirstName which is already a stored variable
a
I think Vernz is onto something. If you create your own object, its schema might not align with the built-in schema for names and errors could happen. By default, names are an object with
first
and
last
as fields.
c
If I decalre clientFirstName in one codeblock is it availabel globally or is it scoped?
a
depends on how you declare it.
workflow.clientFirstName
makes it available anywhere in that workflow.
user
and
session
variables have broader scopes. https://botpress.com/docs/cloud/studio/variables/#user-variables
c
Thanks @acceptable-kangaroo-64719 is was referring to @average-megabyte-82737 note https://discord.com/channels/1108396290624213082/1113959395823464529/1114144257700286505 "For example clientFirstName = workflow.name.first and then instead of doing that workflow access you just call your clientFirstName which is already a stored variable"
a
In the example that I gave I believe it would only be available within the same workflow as its some kind of implicitely referred currentWorkflow variable in and of itsself so to call it or your original from another workflow you would have to use the workflow specific accessor
c
Cool, thanks
20 Views