Title: Windows Live Agents: Anything patterns
Slug: windows-live-agents-anything-patterns
Date: 2008-02-17 04:30:00
Author: Kartones
Lang: en
Tags: Development, Windows Live Agents
Description: How to create catch-all patterns in Windows Live Agents and an example of how to implement it.

 <p><span style="line-height: 1.428571429;">As you will have noticed, having a lot of work making WLAs means lot's of incoming posts about the topic.  I've planned at least another two or three more, but I'll try to talk about other topics too. Anyway, let's get to the topic.</span></p> <p>Sometimes, we might need to create a Catch-all pattern like the default "+ <font face="Courier New">CATCH=Anything</font>" , for example to get every user input under a filter under specific conditions.</p> <p>For example, we could be doing a search and want everything that the user types to be checked for available responses (instead of using multiple patterns, centralized in one).</p> <p> </p> <p><font face="Courier New">+ PASS=Anything {score=200}<br>  VALID = false<br>  if (PASS == "abracadabra")<br>    VALID = true<br>  if (VALID)<br>    - Congratulations, you guessed the magic word :)<br>  else<br>    - Invalid!</font>  </p><p>This code will only work if the user types correctly "<i>abracadabra</i>" in lowercase. Else it will fail. We have functions to do lowercasing and even thawed versions of a variable, but the less code the better, so go and take a look at <font face="Courier New">\BuddyScriptLib\Required\BasicMatching.pkg</font> library...  </p><p>Change the first line to the following:  </p><p><font face="Courier New">+ KEYWORD=AnythingThawed {score=200}</font>  </p><p>Voila! Now "<i>AbraCaDaBrA</i>" will work too, and if we add more ifs/checks, we only have to make sure they are typed in thawed version (lowercase and no special characters), no need to worry for formatting <font face="Courier New">PASS</font>.</p>