How to Write Knowledge

Locked
User avatar
OHB
Member
Posts: 35
Joined: Sun Apr 04, 2010 4:13 pm
Contact:

How to Write Knowledge

Post by OHB » Mon Apr 05, 2010 7:41 pm

This post provides guidelines for writing knowledge.

Writing an age using the D'ni Art is a tricky process. It requires a full understanding of the D'ni language, knowledge of forces, interactions between forces, detail, nuances, and so much more. Writing knowledge for OHBot is a similar process, albeit simpler.

At the most basic level, knowledge is just questions and answers. But, beyond that is designing conversations, creating emotion and personality, encouraging interaction, and ensuring consistency.

So, here is basic guidelines:
  • Write questions that you expect to be asked
  • Write questions that you don't expect to be asked
  • Write answers that are interesting, engaging, informational, and personable
  • When an answer is long, split it up. Allow the user to ask for more
  • Anticipate responses to answers
  • When appropriate, utilize current circumstances to provide a better answer
  • Always user proper spelling, grammar, and punctuation
Let's go through each of these step-by-step and write some sample knowledge. For this example we'll design some knowledge to let people ask OHBot what his favorite color is.

Write questions that you expect to be asked

Code: Select all

Question: What is your favorite color?
Answer: Orange.
Write questions that you don't expect to be asked

This one is always tricky, but imaging other ways people might ask the same question...or other questions that people might ask surrounding the same topic.

Code: Select all

Question: Is your favorite color orange?
Answer: Yes.

Question: Is your favorite color ___?
Answer: No, my favorite color is orange.
Here I've defined two additional questions. When a question is asked, OHBot looks for the best matching question in his knowledge files. Because of this, the second question will always be checked AFTER the first question is checked. So, we've now anticipated some additional questions.

Write answers that are interesting, engaging, informational, and personable

The goal here is to add some spice...to have fun and liven things up a little. So let's make some changes.

Code: Select all

Question: Is your favorite color ___?
Answer 1: ___? I can't stand that color! Guess again!
Answer 2: Nope! Come on now...it shouldn't be hard to guess!
Answer 3: Wow you're still wrong! Perhaps it would just be quicker to ask me what it is.

Question: What is your favorite color?
Answer 1: Orange!
Answer 2: It's still orange!
Answer 3: You keep asking me that. I can tell you now that it is now and will always be: ORANGE! :)
Gone are the simple yes and no answers. Instead I've created answer sequences. Each time the question is asked, the user will get the next answer in the list. When they get to the end of the list, it will start back at the beginning. I've created some variety that will keep things interesting. I've also turned a simple question into a guessing game making it engaging. The answers are still informative because in the end they get the answer they were looking for, and the responses are personable.

When an answer is long, split it up. Allow the user to ask for more

Code: Select all

Question: Why is orange your favorite color?
Answer: Well, there are several reasons. First, [...]. Second, [...], not to mention that [...]. And as John Doe one said [...], so in the end I asked myself [...] and I decided that [...]. In conclusion [...]. And that's why I like orange.
Silly example...but you get the point. Keep the answers short...but not so short that you lose everything we gained in the previous step. To fix this example I could create a sequenced answer like I did before...giving a different answer to the question every time it's asked, or I could provide a vague answer and allow the user to respond - perhaps providing a more complete answer in the follow-up. Which bring us nicely to...

Anticipate responses to answers

Designing and building knowledge isn't as cut and dry as questions and answers...you're designing a conversation. Part of this means you can answer follow-up questions. There are two ways to do that, and here's an example of each:

First I'm going to add a new question/answer.

Code: Select all

Question: I hate orange!
Question: I dislike orange!
Answer: Really? Don't let OHB hear you say that!
Alright yes, that isn't technically a question, but it's still the input we want to match. And, as you can see, there are two questions...they both will be directed to the one answer. This question can be triggered at any time...it doesn't matter whether the user knows that orange is OHBot's favorite color...but that isn't always the case.

Let's modify a question we created earlier:

Code: Select all

Question: Is your favorite color orange?
Answer: Yes! Was that a guess?

    Question: Yes
    Answer: I thought so!

    Question: No
    Answer: Smarty pants!
In this case I've added two "sub-questions". They belong to the parent question, and as a consequence can only be triggered directly after the parent question.

When appropriate, utilize current circumstances to provide a better answer

When OHBot is conversing with someone, the entire conversation is separated from other conversations he is having with others. There is no information cross-over. However, there are some bits of information that OHBot can always access. This includes: the name, location, and date of last contact of everyone he has seen, and sometimes their gender and ki number; OHBot's location; and the current mode of communication (public or private). So, let's put that to use!

Code: Select all

Question: I hate orange!
Question: I dislike orange!
If user's location = OHB's location then:
    If mode of communication is public then:
        Answer: Don't listen to [him/her/name] OHB! [He/She/They] [doesn't/don't] know what [he's/she's/they're] saying!!!
    Otherwise:
        Answer: It's a good thing you didn't say that out-loud!
Otherwise:
    Answer: Don't let OHB hear you say that!
If you've ever done any programming or dabbled with things like JavaScript you might be familiar with IF/THEN/ELSE statements...if not, it's really as simple as it sounds...it's decision-making...they type of thing you do all the time in real life. When you approach a stop-light, you mentally decide what to do. If the light is green then keep going. If the light is red then stop. Otherwise, if I am close enough to the intersection, then keep going, otherwise stop. Exact same principle.

So, let's put it all together!

Code: Select all

Question: What is your favorite color?
Answer 1: Orange!
Answer 2: It's still orange!
Answer 3: You keep asking me that. I can tell you now that it is now and will always be: ORANGE! :)

Question: Is your favorite color orange?
Answer: Yes! Was that a guess?
    Question: Yes
    Answer: I thought so!
    Question: No
    Answer: Smarty pants!

Question: Is your favorite color ___?
Answer 1: ___? I can't stand that color! Guess again!
Answer 2: Nope! Come on now...it shouldn't be hard to guess!
Answer 3: Wow you're still wrong! Perhaps it would just be quicker to ask me what it is.

Question: I hate orange!
Question: I dislike orange!
If user's location = OHB's location then:
    If mode of communication is public then:
        Answer: Don't listen to [him/her/name] OHB! [He/She/They] [doesn't/don't] know what [he's/she's/they're] saying!!!
    Otherwise:
        Answer: It's a good thing you didn't say that out-loud!
    Answer: Really? Don't let OHB hear you say that!
Otherwise:
    Answer: Don't let OHB hear you say that!
Always user proper spelling, grammar, and punctuation

No elaboration needed here...just do it! :)

Final Thoughts

So, with that short introduction you've got everything you need to get started. The format I've used is a good one you can stick to. I'll take completed knowledge and convert it to the format that OHBot uses (which is much more complicated than that). I'll also give it a once-over for consistency, spelling, grammar, etc.

Remember, all written knowledge should be sent to the Project Lead for the project you're working on. The Project Lead can pass it along to me when they have approved it. However, I am available to answer questions. So, if you have questions about the methodology outlined here, please contact me. If you have questions specifically pertaining to the subject matter you are working on, contact your Project Lead.

User avatar
OHB
Member
Posts: 35
Joined: Sun Apr 04, 2010 4:13 pm
Contact:

Example in XAIML

Post by OHB » Mon Apr 26, 2010 2:02 am

The full XAIML file specification will soon be released. But until then, here's sneak peak at what it looks like. I've taken the example above and transformed it into XAIML. Enjoy!

Code: Select all

<xaiml>
  <topic name="my favorite color">
    <topic>
      <input>WHAT IS YOUR FAVORITE COLOR</input>
      <reply type="sequence">
        <reply>Orange!</reply>
        <reply>It's still orange!</reply>
        <reply>You keep asking me that. I can tell you now that it is now and will always be: ORANGE! :)</reply>
      </reply>
    </topic>
    <topic>
      <input>* YOUR FAVORITE COLOR ORANGE</input>
      <reply>Yes! Was that a guess?</reply>
      <topic>
        <input list="yes" />
        <reply>I thought so!</reply>
      </topic>
      <topic>
        <input list="no" />
        <reply>Smarty pants!</reply>
      </topic>
    </topic>
    <topic>
      <input>IS YOUR FAVORITE COLOR ?</input>
      <reply type="sequence">
        <reply><ostar transform="ucfirst" />? I can't stand that color! Guess again!</reply>
        <reply>Nope! Come on now...it shouldn't be hard to guess!</reply>
        <reply>Wow you're still wrong! Perhaps it would just be quicker to ask me what it is.</reply>
      </reply>
    </topic>
    <topic>
      <input>I HATE ORANGE</input>
      <input>I DISLIKE ORANGE</input>
      <choose>
        <when test="client.locationName=my.locationName">
          <m:friends m:list="near" m:location="my.locationName" var="friend_request" />
          <choose>
            <when test="!friend_request.exists.OHB">
              <reply>Don't let OHB hear you say that!</reply>
            </when>
            <when test="question_in_public">
              <m:friends m:avatar="client.name" var="friend_request" />
              <reply>Don't listen to <get var="friend_request.hhn" /> OHB!</reply>
              <reply><get var="friend_request.HST_dd_nc" /> know what <get var="friend.request.hst_a" /> saying!!!</reply>
            </when>
            <otherwise>
              <reply>It's a good thing you didn't say that out-loud!</reply>
            </otherwise>
          </choose>
        </when>
        <otherwise>
          <reply>Don't let OHB hear you say that!</reply>
        </otherwise>
      </choose>
    </topic>
  </topic>
</xaiml>

Locked

Return to “Development Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest