Global listening for intent
# 👀feature-requests
c
Instead of having card-based intent, would be good to have global listening so that the conversation is more fluid. E.g. a user asks a question down the line of the conversation, would be good to jump into a workflow, have that question answered then continue on with the main flow once all questions are answered.
n
Very much needed global intents
c
Thanks @careful-keyboard-68830 for this suggestion.
g
Desperately need this
c
Great suggestion although I believe the new AI expressions can be used for this as well!
was pleasantly surprised when I tested them
f
@cold-jewelry-54343 can you explain how did you do it? 🙂
I think what @careful-keyboard-68830 request is, is to have the ability to switch flows based on a user input. For example, if the user at any given point says "Menu" then we should redirect them to the Menu workflow.
The only way to achieve this currently is by adding a transition after each capture information, then check if the user said something like "Menu" then we connect that transition to that flow.
You can do it using AI Transition, normal transition, at the end of the day you have to add it a lot and mintain it.
Did I get that correctly? @careful-keyboard-68830
I hope I explained it clearly @cold-jewelry-54343
c
Good morning @famous-jewelry-85388 ! A global intent would indeed be super useful. I did some testing with the AI expressions and they are already a move towards this direction ( the scope is just on a node by node basis while it should ideally also be used globally ). In my example I wanted to see if the AI expression could recognize unrelated/insulting answers instead of using regular expressions with additional intents and it worked pretty well. Still testing how best to use the node but its an interesting addition already. (questions asked: how much did you pay for a car? how old is the car ?). A Global scoped AI Intent would be great, so would a Global AI Expression: the intent could analyze the language intent while the expression could check for multiple conditions and branch out accordingly e.g.: Global AI intent = insulting -> do this/execute this/flow here Global AI expression = if this condition + this AI intent + this variable -> do this/execute this/flow here
f
Understood. Thanks @cold-jewelry-54343
c
yeps that's right, essentially global intents remove the need for having to add in a lot of AI transitions in each node 🙂
f
👍
g
$0.02 take to go w/ my feature request upvote: Global Intents... that toggle on/off inside nodes (in the same way the KB can be turned on/off in nodes).
Global defalt intent for: harmful/abusive language. 🔗 From another feature request thread https://discord.com/channels/1108396290624213082/1159995385272614922/1161406833135722578
c
Not reallyl ike that - harmdful langauge can only be identified cheaply in the most naive way - words, which may or may not be used in that context. For anything else you sadly need a full analysis of the conversational history atl east a couple of exchanges deep. And then you are not even sure how it works given GPT 3.5 limitations.
g
True that. Moderation ain't easy, but it's gotta start somewhere. The thread has a good discussion of why it's a worthy feature for BP.
c
What i really dislike is THAT - which is not an intent - as a global interrupt - it has a chance to really bugger up a workflow in the middle. It is "trivial" to put it into the core of a chat loop - which is generally not that complex to start with - and then not have any side worfklow i.e. for data collection - not to be interrupted. That is different from a "done, just delete my data" or "do you speak spanish?" issue which make sense as an interrupt.
c
yup this is really needed. At the moment I came up with a workaround using workflows + AI Task Node that analyzes the {{event.preview}}. GPT is actually pretty accurate in detecting offensive language. Its not perfect but after testing it catches around 80% of what we considered insults. Its just allot of work to put this into every node, it would be much faster and performance friendly if we would implement your suggestion.
c
Not sure that is a workaround - the AI task node can not interrupt a workflow, sadly. You may not have complex flows with data collection - anyone that does will get mad with the amount of ai nodes he would have to put in.
c
but we can task the AI Node to set an expression variable to true/false allowing you to direct or stop the flow.
c
Ah, so - you have to do that manually on EVERY. SINGLE. USER. INPUT. That is easy when you run a chatbot loop, it is way morechaoric when you collect 10 different text entries (name, email, company name, address and some more) i.e. for a reservation system.
c
This is true, have you found a alternative?
c
Nope. There is none. I could imagine a number of ways to make it easier (i.e. a "goto - return" card setup for breakouts - because most of the problem is not even the brakout INTO the intent node, it is that you need to handle every return separate), and without them - nope.
n
Consultation with ChatGPT on the the matter of Global Listening Devices for Botpress produced the following: 1) hooks 2) global flow and 3) catch all node Maybe one of these should be used.. Hooks i guess is the first solution but might add too much computational overhead as gpt advises (?) Then it got me thinking of how do you get flows with issues to "jump" to the Error flow without any connections? Is this done with a catch all node? How do we set this up? Last: is global flow as described by gpt as effective as it sounds? How would we set this up? GPT : "Another way is to create a "**global flow**" that listens for these intents. In Botpress, the nodes in the main flow are processed before any other flows. By setting up nodes that listen for these global intents (like "Help" or "Cancel") in the main flow, you can ensure they're always detected and acted upon. If none of the global intents match, the processing moves to the appropriate workflow or sub-flow." Additional to this, if one of the above can be used: How do we get the conversation back to the exact node that the Global Listening device intervened ? Not the beggining ofthe flow we were before the "jump" but the specific node .. Asking for too much, much ? 😇
c
@narrow-mechanic-29020 Im currently experimenting with "global flow" but it is quite difficult and gets complex very quick in case you want to flow back to a specific node. It is not the recognition of the language that is the issue but directing the flow accordingely: e.g. if you ask a specific question and the user decides to write offensive language the AI can detect that language and set a specific variable to true e.g. workflow.offensive = 1; . In an expression node you can than flow a node asking if he or she wants to try again. This works but it requires a set-up on a node by node (question) basis. This is not only allot of work but can clutter the workspace quickly. A possible solution would be to have "Global" "Trigger" Nodes, that listen to all user chat inputs and based on the trigger it would "trigger back" or "flow" to a certain node. We could place "tags" on nodes to identify which nodes to "trigger" or "flow" to, simplify the process.
n
Absolutely critically needed in order to feel like a natural conversation.
c
This post is getting lots of action. I like it.
c
i'm working on a relative good solution using a single workflow containing the "AI Agent" that does not loop back infinitely. It requires a specific workflow set-up with some custom code. It can take some time to set-up on large workflows but it works solid. If there is allot of desire I can see if I can make a youtube tutorial for this. Just to note that this isn't a solution but a temporary workaround
c
Keep it coming! 🔥
c
@cold-jewelry-54343 The problem with your approach is that it break apart the moment you are not having one of those typsical small AI loops where the AI does most of the work, but also need to offer this functionality on nodes that do data colection. Then every single user input must go through an intent card and back and that is a nightmare on doing. When you ask for an email and also need to get "can we speak spanish" that is a LOT of input needed - and thre is no easy way to route back to the same entry. So, you end up colleting one data point per node (so you can go back to it), and have a LOT of connections and most eay "get data store in bvariable" is "set routing variable, get data, route to intent, route back to processing - 2 loops, and capture and processing on separate nodes. NIGHTMARE.
s
I am a bit late to the party here but had a related need. In my case I wanted to detect special admin commands anywhere in my flow, specifically to be able to escape capture listen loops. The solution I came up with was to use the before incoming message hook to check for the admin commands and clear event.state.context which starts the flow from main where I route based on the words. This solution can be adapted to trigger a "global flow". Here's one way: 1. Use the webhook to always clear the context but to store the values in a user variable. 2. Set the first step of main to determine intent. If an intent that should re-route the user is detected, do so. Otherwise trigger a execute code that will re-set the context. I've not tested the above so I'm not sure it works exactly like that and I could see issue with wait cards but generally I get the sense that manually manipulating event.state.context or event.state could do the trick. Would be great if someone could do a little more digging and figure out exactly which fields need to be changed to allow us to trigger a specific card or node next, basically a jump-to-node/card script.
n
Check this out after 39’ :

https://youtu.be/NZvDA5XQRGI?si=gVihQDpJSHvvbz-B

. Also uses hook before incoming. I tried it with various quotes and works very nice for jumping around flows mid conversation. Even with “included” command where it catches them when part of a message and not alone in one. I am also very curious about more detailed manipulation through context which i tried and didn’t get very far. Finally I confirm that throwing things in user variables helps a lot.
This is for flow jumping. For node, after that @mysterious-greece-6693 gave a great tip here: https://discord.com/channels/1108396290624213082/1168559557182754856
Still, I also feel that playing with event and context will be cleaner, nevertheless the above two can work and allow for good versatility
s
@narrow-mechanic-29020 these are great, loved "dodgy" as a function name.