[ITP: Programming A2Z] Chatbots

Bots Thoughts

  • Bots follow the PUDG model = procedural, uncreative, data-driven, graffitti

    • “unoriginal genius” = remixing pre-existing textual artifacts

    • Interventions in a public space, inherently politically progressive

  • “My bot isn’t me but something I’m responsible for”

    • Need to think through all the misuses and consequences

  • Techniques: matching and substitution

    • AIML (Artificial Intelligence Markup Language)

    • Retrieval model = picks a response from a fixed set based on the input and context

    • Generative model = generates new responses from scratch based on Machine Translation techniques

    • RiveScript = simple language with “Unix-like” approach, takes human input and gives an intelligent response

  • Other considerations

    • Conversation length

    • Open vs. closed domain conversation

Assignment

For the bot assignment, I wanted to create a really simple screaming Discord bot, seasonal for spooky season! All this bot will do is scream at you or scream back whatever you tell it (change text to all uppercase letters). To get this going, I just watched some ✨super exclusive✨ ✨unreleased✨ Coding Train video tutorials and I hacked together the bot by referencing these examples.

I started by creating a node project by making a new directory. In the terminal, I navigated to that directory and typed “npm init” to create the “node_modules” file. The Node Package Manager installs packages and dependencies. To work with Discord, I also typed “npm install discord.js” to install the library. Also “npm install dotenv” to store environment variables.

Then I went to discord.com/developers and logged into my account and created a new application. Then I generated the OAuth2 URL and made sure to select “bot” and “applications.commands”. When I followed that link, my bot was added to the Programming A2Z Discord server! Success!

I then created a .env file to hold onto my secret variables which contain my client ID, server ID and bot token. I followed the tutorial video to use the Discord.js library to login to my bot. The green dot shows it is live!

Success!

Then, I built the scream.js file which handles the slash command. Each command will have its own JavaScript file. I also copied the deploy-commands.js file from Dan’s tutorial which reads and registers all the commands. I also finished up the bot.js file to handle the command interaction. In there, I specified if an interaction occurs, that is a “scream” command, then run the scream.js file.

Tada! Voila! It works!

I was totally inspired by Tres’s arguing MCR bots that I created a second bot named scaredy bot! It is up and running but maybe a future Priyanka will finish this project in which the scream machine screams and scaredy bot gets scared and also screams and the two bots just keep on screaming at each other…

You can find my code at this Github repo.

Questions:

When do I need to run deploy-commands.js? Only have to do once. If you change anything in the execute you don’t need to rerun deploy-commands. If you are changing something in the slashcommandBuilder(), then rerun deploy-commands.

Resources

https://github.com/Programming-from-A-to-Z/Discord-Bot-Examples

https://discord.com/developers/applications

https://discordjs.guide/#before-you-begin

https://www.omc-stepperonline.com/nema-17-bipolar-59ncm-84oz-in-2a-42x48mm-4-wires-w-1m-cable-connector-17hs19-2004s1