0
votes

I'm creating a chatbot for fun and want to implement something to collect the user's name, but only if he says something like "my name is ..." or close to that; the intention of giving the name would come from the user, the bot won't ask for it, maybe only suggest it. Kind of like in Google Assistant, I think. So, it could be given at any time the user wants.
My idea is:

1st create an intent with different ways the user would tell his name to the bot (like in the example above).

2nd use slots and, if the intent is detected, save it as a variable. So far, I've managed.

3rd is the part that I'm stuck in, since it's only an idea and I don't know how I'd do it. Before saving the whole text as a variable, I'd like to delete the part that's included in the intent (my name is) and save only the rest in the variable. So, for example, the user says "my name is XXX"; the command deletes the "my name is" part and saves only "XXX" in the $name intent.

I don't know if this'd be possible, since I don't know coding. I used some special syntax before, like to capitalize the first letter of some other variable, but I don't really know how to use the JSON editor.

Is my idea viable? I don't know how I'd delete the intent corresponding portion and save only the remaining part as the intent. Dunno what would be the command for that, nor where I'd write it.
You can suggest something else if you have an idea.
Last thing, I'm created the skill in portuguese, so there's no access to the @sys-person entity. Thanks for reading.

1

1 Answers

0
votes

I use portuguese skills and face the same issue. I see two solutions, althougt they are not perfect:

Using intents:

When the intent is identified, the bot asks the name again, telling the user that he should only say his name, e.g without "my name is", then store the whole input on a context variable, using:

<? input.text ?>

For embedding such logic inside slots, you probaly will need to use digressions.

But, this is boring to the user.

Using entities:

Entities identification carries along they start and end position in the input text, but intents not. With this, is possible to slice the input, cutting the entity:

<? input.text.substring(entities.name.location[1], input.text.length()) ?>

Entites would be "My name is", "People call me", "I'm called", "I'm baptized", "I was baptized".

So, "Hello, my name is Gustavo", would be cut after "my name is" ending, resulting in "Gustavo". Additional input in the beggining is ignored, but problems arrise with additional input after the name. Also, you need to define more "my name is" like entities, likely all possibilities, than would need if using intents, cause even with fuzzy matching, entities identification doesn't take in account synonymus and similar meaning words.

https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-methods#dialog-methods-strings-substring

https://cloud.ibm.com/docs/assistant?topic=assistant-expression-language#expression-language-access-entity