Custom AI Chatbot

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. Students can simulate a conversation on any topic with ChatGPT playing a specified role . In the code, you can set the name the bot will use for the simulated conversation with the student, the  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. This one is setup for student interested in discussing Nagoya where one of our partner programs is located and/or practicing their Japanese. 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. Limit your responses to one or two sentences. Usual informal forms as is custom among students in Japanese. Use simple vocabulary comprehensible to a foreigner. Try to use vocabulary from the Genki I and Genki II textbooks. 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 a beta version. So after you’ve tried it, speaking with Todd Bryant (bryantt@dickinson.edu) before using it in a course.
    • 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.

AI Chatbot screenshot


Posted

in

by

Tags: