millions-xylophone-94406
07/06/2023, 5:26 PMearly-train-33247
07/07/2023, 1:23 AMearly-train-33247
07/07/2023, 1:24 AMearly-train-33247
07/07/2023, 1:24 AMearly-train-33247
07/07/2023, 1:26 AMacceptable-kangaroo-64719
07/07/2023, 11:18 AMearly-train-33247
07/08/2023, 1:40 AMearly-train-33247
07/08/2023, 1:40 AMsalmon-art-82621
07/08/2023, 6:39 AMearly-train-33247
07/11/2023, 1:09 AMsalmon-art-82621
07/11/2023, 9:18 AMacceptable-kangaroo-64719
07/11/2023, 12:24 PMworkflow.changeContext = true
before taking the user's input, and workflow.changeContext = false
when you're done, otherwist this will run on every user message and cause problems.
js
if (workflow.changeContext) {
console.log('\n\n\n Context hook triggered! \n\n\n')
let usr_msgs = []
event.state.session.history.map((turn) => {
if (turn.sender == 'user') {
usr_msgs.push(turn.preview)
}
})
let full_context = usr_msgs.join(' ')
event.preview = full_context //Oh I absolutely should not be allowed to do this
}
The above code will augment the user's most recent message with the last 3 - 6 messages they have previously sent the bot and join them all together into one message. For example, in this conversation:
Bot: Would you like to buy a car or a truck?
User: I want a truck please?
Bot: We have trucks in blue, green, and red
User: How much is the red one?
The hook would turn "How much is the red one?" into "I want a truck please? How much is the red one?"salmon-art-82621
07/11/2023, 12:31 PM