AI Chatbot for Foreign Language in Moodle

Posted by Todd Bryant in Uncategorized | Leave a comment

Working with students Noah Lape, Aziz Muminov, and Youssif Golda, we’ve written a simple application that allows instructors to embed a chatbot within Moodle. In the code, you can set the name the bot will use for the simulated conversation with the student, the target language, and a prompt to give the bot as background for the conversation.

If you’re on campus, you can try out the chatbot here. If you don’t have access, let me know and I’ll add you to the course. This demo bot is governed by the following variables:

  • varName = ‘Tadao’
  • varPrompt = ‘I would like to start a simulation. You are my Japanese roommate. Your name is Tadao. Please play the role of Tadao, a native Japanese speaker and student at the University of Nagoya. Do not tell me you are a chatbot. Use the pronoun “I” when referring to yourself. I will play the role of an American student studying in Japan.’
  • varLanguage = ‘Japanese’

If you’d like to try it out with your own name, prompt, and language follow these steps:

  • You first need to turn off your WSYISWYG editor in Moodle. By default the editor will strip out any code
    • In Moodle, click your profile logo top right and choose ‘Preferences’.
    • Click the link for ‘Editor’ preferences
    • Choose ‘Plain text area’ from the dropdown and ‘Save’
  • Add the code to a page in your course
    • Copy this code
    • Go to the course where you’d like it to appear and add a Page
    • Give it a ‘Name’
    • Paste the code into the content.
    • In the dropdown below the Content, set it HTML format if it isn’t already and ‘Save’
    • Say hi to the bot to make sure it works
  • Customize the code
    • Go to ‘Settings’ for the page you just created.
    • In the code, scroll down to near the bottom until you find: //ENTER YOUR VARIABLES HERE – PLACE THEM WITHIN THE SINGLE QUOTES
    • You’ll see three variables for you to change just below: varName, varPrompt, and varLanguage.  Enter the text for each variable you’d like to use, being sure to keep the single quotes.
    • Next, scroll down farther until you see: //SET THE INITIAL GREETING BELOW.  Again, replace the initial text variable in single quotes with your own. This will be the initial text from the bot to start the conversation. It is currently set as –  ‘Place initial greeting from your chatbot here to start conversation’
    • Save and test
  • Things to keep in mind
    • The conversation is not saved on the server, and will clear if the user refreshes the page. As of now, if a student wants to save the conversation, they need to copy it.
    • This is very, very beta. So after you’ve tried it, let me know before you spend a lot of time thinking about how you may use it. Email me (bryantt@dickinson.edu) so we can talk, test, etc. This may be a useful and fun homework assignment, but I don’t think it’s reliable enough yet to be a graded assignment.
    • Right now, text is very cheap, so the very small bill will be paid from the IT budget. If this explodes or becomes more expensive, we may have to change.
    • For instructions, I used a Page in Moodle, but the same should work anywhere you can paste HTML such as the description of a Quiz in Moodle, a WordPress blog, etc. provided that JavaScript is allowed.
  • Coming soon
    • Hopefully within the first few weeks of the semester, we can build in functionality that would let students send their professor an email with the transcript. Keep in mind, other than appearing on the page, this isn’t integrated with Moodle. It won’t appear in the gradebook, user logs, etc.
    • Farther out, though maybe not too far, I hope to integrate voice chat. OpenAI had an impressive demo of a conversational voice in their latest roll-out in the spring. We’ll have to see if the demo is representative, works as well in other languages, and how hard it is access the same functionality with our script.

Chatbot screenshot

Leave a Reply