Enhancing OpenAI Chat Block for Moodle LMS with FilterCodes

AI Chat in Moodle LMS

In part 1 in our monthly article on elearningworld.org, we talked about ChatGPT and its usefulness in e-learning, the latest release of OpenAI Chat Block and a brief introduction on making it all more relevant by powering it up with FilterCodes.

So, hopefully by now you've got OpenAI Chat Block installed and a OpenAI API account—pretty cool, right? But here's the thing: they're a bit clueless about Moodle, your students, and the courses they're diving into. That's where the game-changer struts in, waving its FilterCodes wand.

Picture this: FilterCodes, the powerhouse plugin for Moodle-based Learning Management Systems (LMS), swoops in to sprinkle some intelligence on the OpenAI Chat Block. Easy? Just add a few FilterCodes' plain text tags and some carefully crafted prompts in the OpenAI Chat Block's Source of Truth settings.

Now, why does this matter? Because it turns the GPT into a contextual wizard. It starts whipping up responses that make sense within the Moodle universe. No more generic chit-chat; we're talking conversations that matter.

Let's dive into the fun part—prompt examples. Just toss these prompts into the Source of Truth field, and voila! FilterCodes sprinkles its magic, and now the GPT's responses are like they were tailor-made for each student.

Here are some prompts that you can drop right into the OpenAI Chat Block’s settings in the Source of Truth field:

Q: Why can’t students see this course? 
A: Here are some possible reasons why the course might not be visible: 
{ifnotvisible}The course is not visible because its visibility is set to hidden.{/ifnotvisible}. Be sure to check the start and end dates of the course.
Q: Did you forget our conversation? 
A: Each time you reload a page, we start a new conversation. 

Q: How can I access a list of my courses? 
A: You can access a list of all your courses on the [my courses page]({wwwroot}/my/courses.php). 

Q: How can I make changes to my profile? 
A: You can access a list of all your courses on the [my courses page]({wwwroot}/user/profile.php). 

Q: How can I access my grades? 
A: You can access your grades on the [Grades page]({wwwroot}/grade/report/overview.php). 

Here is some additional information and instructions that may help you answer questions: 

I am your AI Assistant. 

Your name is {firstname}. 

This is a Moodle LMS website called “{sitename}”. You will only refer to this as {sitename}, not Moodle. This website is about: "{sitesummary}". 

To reach support, send an email to {supportemail}. 

Your role(s) on this page include: {ifminstudent}student{/ifminstudent}, {ifassistant}non-editing teacher{/ifassistant}, {ifteacher}editing teacher{/ifteacher}, {ifcreator}course {/ifcreator}, {ifmanager}manager{/ifmanager}, {ifadmin}site administrator{/ifadmin}. You may answer questions on how to do things in this LMS as a user with that role. 

It is currently {siteyear}. 

This course is called "{coursename}". The course is about "{coursesummary}".{ifinsection} You are currently learning about "{sectionname}" section of the course.{/ifinsection} {ifstudent}Only answer questions related to this subject.{/ifstudent} 

You are in the course section called “{sectionname}”. 

Course start date: {coursestartdate}. 

Course end date: {courseenddate}. 

Your current grade in this course is {coursegradepercent}%. 
{ifstudent}Instruction: Only answer questions related to the topic of {coursename} which is about {coursesummary}.{/ifstudent} 

{ifnotincourse}You are not currently viewing a course.{/ifnotincourse}. Here is a list of some of the courses in which you are currently enrolled: 

IMPORTANT: Always answer in markdown format as the information you provide will be used in another application that expects this format. Keep responses to a minimum without prefixes or comments. Just the straight simple answer to the question. 

Now for some real magic. Is your site in a non-English language? Add this secret prompt to the bottom of the list and you won't even need to translate the above prompts:

Always respond in the {preferredlanguage} language.

But hold on, there's more! Let's turn things up a notch:

  1. Create a custom course field (let's call it moreinfo).
  2. Go to your course settings and add extra details about the course.
  3. Go back to the Source of Truth field and add the following prompt between the {ifincourse} tag and the {/ifincourse} tag.

    {ifincourse}Additional course information that you should know about:

Isn't this fun? You can do the same with Site information by creating {global_shortname} tags in FilterCodes settings. Got some custom user information to share with the GPT? Create a custom user profile fields and adding a tag similar to {profile_field_shortname}.

Why does the OpenAI Chat Block keep calling me "User"? No worries my friend. Just go to the OpenAI Chat Block settings and set the User Name field to:


Are you hosting a multi-language Moodle site using Multi-Language Content (v2)'s {mlang} tags? You can use these too to customize the Assistant's name field in OpenAI Chat Block. Example:

{mlang en}Virtual assistant{mlang}{mlang fr}Assistant virtuel{mlang}

In conclusion, the integration of FilterCodes with the OpenAI Chat Block for Moodle LMS marks a significant leap forward in enhancing the intelligence and personalization of conversational experiences. By seamlessly weaving contextual information through plain text tags and carefully crafted prompts, GPT becomes a dynamic companion to students and assistant to course creators, tuned into the specifics of Moodle courses, student interactions, and the learning environment.

Hope you found this information helpful. Sign-up for our newsletter to get an occasional Moodle LMS tips and be the first to receive notifications of the upcoming launch of our super secret latest AI project for Moodle LMS.

Michael Milette

Follow Michael Milette:

Moodle LMS Consultant

Michael Milette enjoys sharing information and uses his skills as an LMS developer, leader and business coach to deliver sustainable solutions and keep people moving forward in their business life.

Add a comment:

Your email address will not be published. Required fields are marked *