Search code examples
pythondiscord.pyaiml

Using AIML files' Predicate and Sessions with discord.py


I was learning about AIML files with Python. I know I need to use aiml module of Python, but I want to use it with discord.py.

I want to make it so that, suppose I am talking with the bot, and I tell that my dog name is Blake. And there is another person whose dog name would be Tiger. How can I store it? In a db or I should use json files? I can make the sessionID as the user ID. But then, I need some guidance regarding storing all this information...

Sorry for not showing any code that I wrote, because I am not able to understand how can I achieve this. Some help/guidance would be appreciated, so that, the bot would be able to respond, like I ask it, what's my dog's name, then it would answer with Blake...

Thank you


Solution

  • To set a predicate in AIML, you should use

    <category>
        <pattern>MY DOG IS CALLED *</pattern>
        <template>Ok, I will learn your dog is called <set name="dog"><star/></set></template>
    </category>
    

    You can keep track of each person by keep a note of their clientid. Your AIML interpreter should keep a track of these predicates and you don't need to specify how to store them.