Search code examples
aiml

Pandorabots - Detect Phone, Email, etc


Good Day. Does the Pandorabots AIML support complex REGEX? For example, a visitor typed "+1 (555) 123.4567" (only or inside some text) and the chatbot must understand that it's a phone#. Is it possible to use something similar with:

.* (+?\d[.-\s]?\(?\d{3}\)?[.-\s]?\d{3}[.-\s]?\d{4}) .*

GET ONLY -> 1$

If NO - How to correctly detect the phone, email or user name in the user's response.


Solution

  • You can't use REGEX in Pandorabots and will have to write categories yourself to handle this. Here is a basic one that uses the built in set called "number" to recognise phone numbers in the format +1 nnn nnn nnn

    <category>
        <pattern>1 <set>number</set> <set>number</set> <set>number</set></pattern>
        <template>Is that a phone number?</template>
    </category>
    

    You can create new sets yourself to validate input, so an improvement on my basic category would be to have a set of 3 digit numbers to validate against, rather than any numbers.

    Similarly, you can check for emails by seeing if there are @ and . characters in the input. Assuming you are using the standard substitutions, you can create a category like this:

    <category>
        <pattern>* AT * DOT *</pattern>
        <template>Thanks for your email.</template>
    </category>