Prop
Save arbitrary user data to session / cache
If you have been developing websites, you probably come across this word. Here, Props are custom variables that you can use however you'd like - to store data in the user session under that variable.
The engine keeps track of the user session props internally.
Defining a prop
To define a prop on a particular template, provide the prop
attribute with your defined variable name
1000:
type: text
prop: username
message: "What is your name?"
routes:
"re:\\w+": next-stage
In the above, when user provides a response, it will be saved in the user session props under the key username
PS: The default chatbot comes with file-based session manager
implementation. So you can view this file anytime and see
how the data is being used
You can then access this user session data in your bot logic.
Managing Session Data
Depending on your Session Manager implementation, you might not be able to view the session data plainly.
The example bot comes with a helper endpoint to play around with session data
[PUT request] <bot-url>/jawce/api/session
Request payload
enum class SessionAction {
CLEAR,
ADD,
EVICT,
FETCH
}
// main request DTO
data class SessionRequest(
val action: SessionAction,
val sessionId: String, // user session id (phone number)
val key: String?, // session key to save or fetch
val data: Any? // session data to save
)
PS: You can provide *
as key to fetch all user session data