stale-author-40821
05/31/2023, 10:25 AMacceptable-kangaroo-64719
05/31/2023, 10:42 AMstale-author-40821
05/31/2023, 10:47 AMacceptable-kangaroo-64719
05/31/2023, 10:48 AMstale-author-40821
05/31/2023, 10:50 AMfamous-jewelry-85388
05/31/2023, 2:10 PMfamous-jewelry-85388
05/31/2023, 2:12 PMstale-author-40821
06/02/2023, 1:34 PMacceptable-kangaroo-64719
06/02/2023, 1:37 PMMain would be empty in Timeout or vice-versa. User variables are supposed to be global though, and available in every flow. You can read more about variables here https://botpress.com/docs/cloud/studio/variables/stale-author-40821
06/02/2023, 1:40 PMuser.message_history var, it should be global, right?acceptable-kangaroo-64719
06/02/2023, 1:44 PMstale-author-40821
06/02/2023, 1:50 PMlast_node and message_history).
2. When I start a new conversation, these vars are empty 👍
3. When I force a timeout, the workflow has the information and it's stored in the user var (just message_history in that case) 👍
4. When I send another message to the chatbot, the user vars have no value in the Main workflow 😭
Something am I doing wrong? 🙏stale-author-40821
06/06/2023, 7:39 AMacceptable-kangaroo-64719
06/06/2023, 10:10 AMstale-author-40821
06/06/2023, 1:00 PMlast_node and message_history) in the user variables section, but... seems not workingstale-author-40821
06/06/2023, 1:00 PMacceptable-kangaroo-64719
06/06/2023, 1:16 PMacceptable-kangaroo-64719
06/06/2023, 1:16 PMstale-author-40821
06/06/2023, 1:36 PMuser object, in the timeout flow
2. print the whole user object in the main flow
i've been changing most of the configuration and tried so many different things but it's not working at allacceptable-kangaroo-64719
06/06/2023, 1:40 PMstale-author-40821
06/06/2023, 1:42 PMuser object is completely emptyacceptable-kangaroo-64719
06/06/2023, 1:50 PMstale-author-40821
06/06/2023, 1:51 PMacceptable-kangaroo-64719
06/06/2023, 1:53 PMuser.message_history and workflow.chatgpt_message_history the same type?stale-author-40821
06/06/2023, 1:54 PMacceptable-kangaroo-64719
06/06/2023, 2:12 PMAfter_Incoming_Message hook called save_history that runs this code:
js
if (!workflow.message_history) {
workflow.message_history = []
}
event.state.session.history.map((message) => {
let entry = `${message.sender}: ${message.preview}`
console.log(entry)
if (!workflow.message_history.includes(entry)) {
workflow.message_history.push(entry)
}
})
console.log(workflow.message_history)
2. In my Timeout flow, I'm running this code:
js
if (workflow.username) {
user.username = workflow.username
}
if (workflow.usercolor) {
user.usercolor = workflow.usercolor
}
if (workflow.userpet) {
user.userpet = workflow.userpet
}
if (workflow.message_history) {
user.past_message_history = workflow.message_history
}
3. Bot user.past_message_history and workflow.message_history are arrays of strings.acceptable-kangaroo-64719
06/06/2023, 2:12 PMstale-author-40821
06/06/2023, 2:16 PMTimeout flow.
When the timeout triggers, I my workflow variables have the correct value, so I guessed I can store directly the value into the user vars. Despite that, the rest is quite the same..stale-author-40821
06/06/2023, 2:21 PMacceptable-kangaroo-64719
06/06/2023, 3:10 PMjs
if (!user.message_history) {
user.message_history = []
}
event.state.session.history.map((message) => {
let entry = `${message.sender}: ${message.preview}`
if (!user.message_history.includes(entry)) {
user.message_history.push(entry)
}
})stale-author-40821
06/06/2023, 3:13 PM