arrow-left

All pages
gitbookPowered by GitBook
1 of 9

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Homework

This is a guide to what you should be doing for homework each week. Please reach out to your CFs if you are unsure of what to prioritise between sessions.

  • Complete LinkedIn profile

  • Complete the Express and Dev Tooling workshops

Week of September 16th

Learn how to manage asynchronous tasks and send HTTP requests using JavaScript.

hashtag
Workshops

hashtag
To be completed on Monday

  • . Repo name: Work08_Node_YourName

  • . Repo name: Work09_NodeAndExpress_YourName

hashtag
To be completed on Friday

  • . Repo name: Work10_IntroTesting_YourName

  • . Repo name: Work11_TestLibrary_YourName

  • . Repo name: Work12_UnitTesting_YourName

hashtag
Execute Program

hashtag
Topics

  • Introduction to commonJS modules

  • Introduction to testing

  • Introduction to Express

  • Intro to testing, Build a testing library, Unit testing, Integration testing and TDD workshops

Integration testing workshoparrow-up-right. Repo name: Work13_IntegrationTesting_YourName
  • TDD workshoparrow-up-right. Repo name: Work14_TDD_YourName

  • Elevator pitch workshop

  • Project presentationsarrow-up-right

  • Node & npm introduction workshoparrow-up-right
    Node and Express HTTP Serverarrow-up-right
    Intro to testingarrow-up-right
    Build a testing libraryarrow-up-right
    Unit testing workshoparrow-up-right
    Execute Program Basic Typescriptarrow-up-right

    week02-project02-chatbot

    project

    hashtag
    1. You are going to create a chatbot that you will deploy in a Discord channel

    Discord Preparationsarrow-up-right

    hashtag
    Core user stories:

    1. Project Setup with Libraries: As a back-end developer, I want to set up a new Node.js project in VS Code with the discord.js and openai libraries using require('discord.js') and require('openai') after installing them with npm, so I can start building my bot with all necessary functionalities.

    2. Secure Configuration

    hashtag
    Stretch user stories:

    1. Messaging Users Directly:

      Hint: Utilise the user.send() method in Discord.js to send direct messages to users. Retrieve the user object through events or commands that the bot receives.

    2. Dialogue Boxes and Interactive Responses:

      Hint: Implement Discord's message components like buttons and select menus using

    hashtag
    2. You are going to integrate testing into your Discord chatBot project.

    The following user stories are designed to guide you as you integrate testing into your Discord chatBot project. If there are some which are not appropriate to your project, you do not have to integrate these. You can create your own tests that are relevant to your project.

    hashtag
    Possible user stories:

    As a back-end developer, I want to...

    • verify Discord.js integration by creating a test function that creates a new Discord client

    • ensure that the OpenAI library is correctly integrated by creating a test function that attempts to use the OpenAI API to create a simple chat completion or query

    • test that my bot securely loads API keys from the .env file, confirming that no sensitive information is hard-coded

    hashtag
    Repository naming convention

    Please name your repo following this template: PRO02_Name1_Name2_Name3_Name4

    employability

    hashtag
    Building an online presence

    • Introduce the importance of building an online presence and ‘learning in public’

    learning-outcomes

    hashtag
    JavaScript

    : As a back-end developer, I want to configure my bot securely by using
    require('dotenv/config')
    to load my API keys from a
    .env
    file, ensuring they are not hard-coded into my project, using a
    .gitignore
    file.
  • Bot Initialisation: As a back-end developer, I want to initialise my Discord bot and log in to Discord using the new Discord.Client() constructor and client.login method with my Discord token, to start listening for messages.

  • Message Handling: As a back-end developer, I want to handle incoming messages by setting up a message event listener using client.on('messageCreate', callback) to process messages received in Discord and respond to them with a “hello” message.

  • Optimisation: As a developer, I want the bot to optimise its performance by efficiently handling events, so that it does not consume excessive resources. This may involve writing efficient callback functions for client.on and client.once, ensuring they execute tasks quickly and without unnecessary resource consumption.

  • OpenAI Chat Integration and Response Generation: As a back-end developer, I want to integrate OpenAI into my bot and send chat prompts to the API to generate responses. This would involve using the openai.chat.completions.create() method with my OpenAI API key. I aim to pass conversation history and other necessary parameters to this method to receive context-aware chat completions. This will enable the bot to generate dynamic, intelligent responses based on ongoing conversations, enhancing user interaction and experience.

  • Response Management: As a back-end developer, I want to manage the OpenAI response returned by openai.chat.completions.create() using either fetch or async/await and sending the response back to the Discord channel.

  • Command Processing: As a back-end developer, I want to process commands directed at my bot by using string matching or a command prefix to distinguish between general messages and commands meant for the bot.

  • Error Handling: As a back-end developer, I want to implement error handling in my bot interactions using either .catch or try...catch within my fetch or **** async functions to manage exceptions and provide error messages if something goes wrong.

  • MessageActionRow
    and
    MessageButton
    or
    MessageSelectMenu
    classes from Discord.js. Handle interactions with
    client.on(Events.InteractionCreate, callback)
    .
  • Creating Private Chats (Channels):

    Hint: Use guild.channels.create() to create new private channels and manage access using permission overwrites in Discord.js.

  • Automated Moderation Features:

    Hint: Monitor messages for specific keywords or patterns using client.on(Events.MessageCreate, callback). Implement moderation actions like message.delete() for removing inappropriate content and guildMember.timeout() for muting users.

  • Multimedia Responses (Images, GIFs, Audio Clips):

    Hint: Send multimedia content using message.channel.send() with the files option. For audio, explore Discord.js voice modules for handling voice channels and streaming.

  • ensure that my bot initialises and logs into Discord successfully
  • simulate receiving a message and verify that my bot responds with a "hello" message, testing the message event listener's functionality

  • simulate commands directed at my bot to check if it accurately processes these commands from general messages

  • introduce faults or exceptions in bot interactions to verify that my bot's error handling mechanisms effectively manage and log errors

  • mock the process of sending responses back to the Discord channel, verifying that my bot formats and dispatches messages correctly

  • ensure my bot can send direct messages to users, testing the user.send() method's functionality

  • test my bot's ability to send multimedia responses under specified conditions, ensuring it can handle images, GIFs, and audio clips effectively

  • Discuss the benefits of maintaining an up-to-date LinkedIn profile

    hashtag
    Introduction to CVs and the Elevator pitch

    • Understand the importance of building and maintaining an up-to-date CV

    • Understand the the concept of an ‘elevator pitch’

    • Learn best practices when pitching yourself

  • hashtag
    Node.js

    hashtag
    APIs

    hashtag
    Testing

    schedule

    spikes

    hashtag
    Asynchronous JavaScript

    How does JS handle asynchronous code?

    hashtag
    Questions to consider

  • What's the difference between "synchronous" and "asynchronous" code? Why might synchronous code be called "blocking"?

  • What are the event loop and the call stack?

  • How do callbacks and promises help us?

  • hashtag
    Testing methodologies

    How do different testing methodologies try to improve the way we write tests?

    hashtag
    Questions to consider

    1. What is Test-Driven Development (TDD)? Can it help us write better code?

    2. What is Behavior-Driven Development (BDD)? How do we translate user requirements into automated tests?

    3. What is test coverage? Can this tell us about the quality of our tests?

    resources

    • What is a web server?arrow-up-right General background info on how servers work

    • npm for absolute beginnersarrow-up-right Kevin Powell's video (Just ignore Astro recomendation at the very end)

    • HTTP topic introarrow-up-right

    • A comic explaining what happens when you type a URL into your browser.

    • Describes the HTTP protocol in a lot more detail. May be useful if you like learning exactly how stuff works under-the-hood, but may also be overwhelming.

    • How functions and callbacks work in JavaScript. Based on a workshop from this week's curriculum.

    • Good testing practices so you can be confident your tests are working.

    • A comparison of creating DOM elements manually versus using the <template> element. Useful technique if you're dynamically rendering lots of stuff with JS.

    How DNS Worksarrow-up-right
    HTTP Overview - MDNarrow-up-right
    First-class Functionsarrow-up-right
    What the heck is the event loop anyway? (video)arrow-up-right
    TDD changed my lifearrow-up-right
    Behavior Driven Development and Functional Testingarrow-up-right
    Test Coveragearrow-up-right
    Make Your Test Failarrow-up-right
    The advantages of the template elementarrow-up-right