How to capture wildcards / user name?

I want to capture the user’s name; basically almost anything they type in.

bot: What’s your name
human: randomanything

Is there a way to do capture eg the “next input” to a slot?

Otherwise I would have to do all kinds of hijinks, like discussed here

ideally I would like to also be able to have escapes

bot: what’s your name.
human: I’m not telling you

recognize as [intent: deny] or similar.

related topics don’t seem to address this fairly basic chatbot need…

1 Like

Hi @dcsan. Your question is a bit tough to follow, but I think you are looking for a custom action that gets the entire input field using tracker.latest_message.text. Is this correct?

It sounds like you will want to have a story where the user provides and you collect the username and then another story where the user denies, causing the assistant to have to handle it differently.

I might recommend checking out the Rasa Masterclass.

Hi :slight_smile: I’m not sure it’s the good answer you’re looking for because I’m not sure I correctly understand. But I will try !

To capture text in a slot you can use the slot mapping functions of forms and populate the slot with self.from_text().

More infos at https://rasa.com/docs/rasa/core/forms/#custom-slot-mappings.

To have bypass, if the NLU is correctly trained it will detect the intent deny. Then use the validation function to raise an exception, return something, use stories to handle the case.

More at RASA Bot stories and Building bot using Forms.

I use the second solution (not sure it is the good one) :

	def validate(self, dispatcher, tracker, domain):
		slot_values = self.extract_other_slots(dispatcher, tracker, domain)
		if tracker.get_slot(REQUESTED_SLOT):
			slot_values.update(self.extract_requested_slot(dispatcher, tracker, domain))
			if tracker.latest_message['intent'].get('name') == "deny"
				t = self.deactivate()
				t.append(FollowupAction("action_custom"))
				return t
1 Like

Thanks for the replies, sorry if it’s not clear.

I think you’re right that custom actions aka slot-filling is the way to go. But ideally I was looking to avoid a custom action/python code

The problem is that a user’s name cannot really be defined in normal intent matching terms. If they say “My name is [xxxx]” maybe we can catch a pattern but not if they just say the name itself, Bob. So I did try with a regex pattern

## regex:username
- [a-z]{3,}

ie anything with three+ letters should match So given this regex username entity, I was hoping to get a match on a path like this

## get_name
* greet
  - utter_greet
  - utter_ask_username
* give_username
  - utter_thanks
  - utter_goodbye

where the related intent is:

## intent:give_username
- my name is [alan](username)
- [bob](username)

However this matches all kinds of other intents.
If I type bob it will match though…
Maybe my regex entity isn’t working

So it seems something else is taking priority in the matching.

Update: NLU check

I tried rasa shell nlu to try and understand the matching a bit more.

3 letters matches well to username

abc
{
  "intent": {
    "name": "give_username",
    "confidence": 0.15361180901527405
  },
  "entities": [],
  "intent_ranking": [
    {
      "name": "give_username",
      "confidence": 0.15361180901527405
    },

five letters matches as an ‘affirm’ (based on standard rasa)

nancy
{
  "intent": {
    "name": "affirm",
    "confidence": 0.16830478608608246
  },
  "entities": [],
  "intent_ranking": [
    {
      "name": "affirm",
      "confidence": 0.16830478608608246
    },
    {
      "name": "give_username",
      "confidence": 0.14397381246089935
    },

using the phrase “my name is …” (part of the intent def) fails too

even 3 letters fails

my name is hot
{
  "intent": {
    "name": "myname",
    "confidence": 0.4133380949497223
  },
  "entities": [],
  "intent_ranking": [
my name is abcdef
{
  "intent": {
    "name": "affirm",
    "confidence": 0.47324347496032715
  },
  "entities": [],
  "intent_ranking": [

with the specific example in the training set we get a match

my name is bob
{
  "intent": {
    "name": "give_username",
    "confidence": 0.5735953450202942
  },
  "entities": [
    {
      "start": 11,
      "end": 14,
      "value": "bob",
      "entity": "username",
      "confidence": 0.8531587364384371,
      "extractor": "CRFEntityExtractor"
    }
  ],
  "intent_ranking": [

so it seem something about the way I defined the entity isn’t catching

1 Like

I think that you need to add more example in the NLU in order to train it. The confidences in intents aren’t really good on some examples…

For the entity name extraction you maybe can use SpacyEntityExtractor. There is a PERSON entity in it, it may help you :blush:

1 Like

well fundamentally the problem is there isn’t really an intent, just the user replying with their name, which can be anything. So the intent == the entity.

## intent:give_username
- [bob](username)
## regex:username
- [a-z]{3,}

anyway I think slots are the way to go.

thanks!

2 Likes

I’m with you, @dcsan! It’s about time we get rid of intents

Thanks @amn41 , I’ve read that post with interest and the linked forum topic.

This paper is relevant about “Conversational Entity Dialogue Model” using entities to fully model the conversation also allows relations between entity properties to come out.

image

The conversational entity dialogue model (CEDM) is proposed as an alternative way of statistical dialogue modelling having the concept of entities at the core of the model. Entities being objects or relations offer an intuitive way of modelling complex task-oriented dialogues.

hadn’t read that - thanks for sharing! will take a look. At first glance looks like it might be related to this

Hello @dcsan , I am stuck at same thing as you were . I am trying to figure out how to capture the user name, be the user input in any format. did you get a way to do so? please let me know if there is any way.

Thanks! :slight_smile: