0

I have an entity with type: @sys.number-sequence, which matches a code 4 numbers long, for example: (Spoken) "1 2 3 4" or "1234".

In the Intent, if the user speaks a code that's 1, 2, 3, 5 or 6 characters in length and not just 4-long, this pattern does NOT match. So in the "User Says:" section, I had to add all of the below: 1 12 123 1234 12345 123456 (And map each one to my number-sequence entity)

... to handle all permutations of 1 through 6 long number sequences.

It's obviously a very hacky and ugly solution.

Is there a way I can define a number sequence type that will match any length of number sequence so that I can use it in phrase structures in a more flexible way?

In other words: I want to just define the placeholder match ONCE, and not have to redefine it for every length variation...

I don't see anything pertaining to "number sequence length" in the documentation of Dialog Flow types: https://dialogflow.com/docs/reference/system-entities

Tejas Bramhecha
  • 880
  • 5
  • 19
FranticRock
  • 3,233
  • 1
  • 31
  • 56

1 Answers1

1

The built-in entities like @sys.number-sequence will help you in finding numbers in sequence only. In api.ai, you can not specify the length of a number that you want either 4-digit or 6-digit. In addition, training agent for all permutations of any digit number is not a generalized solution.

What you can do is write a webhook, fetch this parameter @sys.number-sequence in your code & put a verification over there. If it is not of the number of digits you want, you can send a reply saying Please enter 6 digit number or say you have entered a correct code.

Tejas Bramhecha
  • 880
  • 5
  • 19
  • The reason I'm using "1" is it's actually able to allow any length of numbers. So it accepts all of: 1, 11, 111, 1111, 11111. If you put 1111, instead of 1 as a placeholder, then it only accepts 4 digit numbers, and rejects everything else. (Tested this many times). So with a 1 digit number, it's a lot more flexible, to allow any length of input. For validation purposes, your answer is still valid - to do it in the webhook. But I did end up with going with a placeholder of "1" - and now it matches all lengths of number-sequence. thanks. – FranticRock Feb 20 '18 at 21:13
  • try number 5212, 6212,7212 with your @sys.number-sequence and you would be blown away with the way it responds. for 5212 it would give you 5.5 value :D – Amit Apr 05 '18 at 16:50