Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

ai
community creator

How to create a chatbot in Pandorabots

Sonith Bingi

A chatbot is a computer program or conversational agent that interacts with a real person online to simulate the experience of talking to another human. It is predominantly used in customer service platforms to decrease the load of responding to numerous repetitive queries from customers. Chatbots have automated responses for services that range from fun and entertainment to receiving customer feedback and answering queries.

Pandorabots is one such platform that is used to build a conversational chatbot with use of AIML (Artificial Intelligence Markup Language). AIML is an extension of XML.

Basics of building a chatbot on Pandorabots

  • Create and name the bot and choose the language you desire to code in. Keep the content as Blank Bot.

  • Open the editor to code the bot.

  • The editor is a place where you can create and edit AIML and other bot files. Click Edit beneath the bot’s name to navigate to the editor.

  • Click on AIML and create a new file to start coding in AIML.

You will start coding inside the <aiml> tags.

Some basic tags

  • <category>: the base of the code for an AIML-based chatbot.

  • <pattern>: used to define an input. The text inside this tag is checked to match the input. If it does, then the text written inside the template tags is returned to the user.

  • <template>: The code/text written inside it is returned to the user if the <pattern> tag triggers it to do so.

<!--An example of an input-output code-->

<aiml>
  <category>
    <pattern>Give me some output</pattern>
    <template>Here is the output</template>
  </category>
</aiml>

This block of code returns the text, ‘Here is the output’ to the user when the user types, ‘Give me some output’.

The text inside the <template> tag is only returned if the characters entered by the user are exactly the same as those in <pattern> (after the case is ignored).

These tags form the core of AIML.

More code examples

Here are a couple of examples that show the convenience of using AIML.

Random greetings

<aiml>
  <category>
      <pattern>HELLO</pattern>
      <template>
          <random>
              <li> Hello </li>
              <li> Hi there! </li>
              <li> Hola </li>
              <li> Hey </li>
              <li> Hi </li>
          </random>
      </template>
  </category>
  <category>
      <pattern>HI</pattern>
      <template><srai>HELLO</srai></template>
  </category>
</aiml>

This block of code returns a greeting message to the user. The tag is used to randomly select one of the texts inside the list tags and return it to the user to receive the input ‘HELLO’.

The <li> tags are used to define a list of texts/elements.

Here, the <srai> tag is used to return the same output as when the user enters ‘HELLO’ to avoid code redundancy and save some time.

Generate a random number between 1 and 9

<aiml>
  <category>
    <pattern>Choose a random number between 1 and 9</pattern>
    <template>
      <random>
          <li>1</li>
          <li>2</li>
          <li>3</li>
          <li>4</li>
          <li>5</li>
          <li>6</li>
          <li>7</li>
          <li>8</li>
          <li>9</li>
      </random>
    </template>
  </category>
</aiml>

The <random> tag is used to randomise the number selection.


These are just a few examples of code that you can write for a chatbot. There is huge library of tags that can help users code a very advanced bot and the opportunities are endless!

RELATED TAGS

ai
community creator
RELATED COURSES

View all Courses

Keep Exploring