Giter VIP home page Giter VIP logo

knowbot's Introduction

KnowBot

Discord bot to provide progressively intelligent assistance to Elixir/Phoenix learners participating in the DockYard Academy.

Vision

Ultimately, KnowBot should be able to "listen in" on conversations in DockYard Academy text channels and provide answers to the questions being asked in the conversations. This involves natural language processing (NLP) functionality that is beyond the scope of an initial release (MVP -- or "MVB" in this case).

MVB (Minimal Viable Bot) Functionality

Initial functionality is basic: Help (how to use the bot), FAQ (initially, a list of what KnowBot knows), and asking a question, along with rudimentary administration (some sort of curation of KnowBot's knowledge).

Brook's Feature List (2/13/2023)

High Priority

  1. FAQ "/faq"
  2. Track questions /question
  3. Automatic Suggestions /question -> autoreply
  • links to documentation
  • common bugs
  • debugging steps and suggestions

Low Priority

  1. Quick Answers /answer
  2. Track Answers
  • can we store any message that's a reply to a /question?

Tentative Roadmap

V1 (03/01/2023): MVB (Minimum Viable Bot)

Time-boxed to create as much value for Academy participants and staff as possible as a "V1."

NOTE: Updated 2/18/2023 in response to 2/13 discussion with @BrooklinJazz, DockYard Academy mastermind.

  • Implement "/" to invoke commands (ubiquitous expectation of Discord users).
    • See issue # 28
  • Help /H (or /help or /HELP): How to use the bot. - DONE.
  • FAQ /faq (or /FAQ) - Growing list of topics already answered/pre-curated in anticipation of most frequently needed information. This will evolve constantly.
  • Ask a question /q (or /Q): THE core functionality.
    • Initial Scope: Use the word immediately prior to the question mark as the answer lookup key. Examples:
      • "/q how do I sort?" ==> KnowBot shows information about sort(ing)
      • "/q how do I use Enum? ==> KnowBot shows information about Enum (the most common functions)
      • "/q Define the universe ==> KnowBot kicks the user from the guild (kidding ...)
  • Database: Persist data in Postgres rather than data structure embedded in code and/or the file system.

V2 (04/01/2023): Cluetrain

Features will be prioritized by balancing the need for pain-relief from paying down technical debt against the urgency and value of user suggestions by Academy members and instructors. Anticipated feature sets (obviously a guess at this point):

  • Academy Staff Notifications: Ping a list of Academy teachers/mentors/TAs
  • Attendance: If possible, track attendance in voice sessions.
  • Auto-pairing: See "queue bot" issue/story.
  • More robust question parsing ... edging toward NLP
  • Curation: Make it easier for Academy instructors to refine and select content for the growing library of answers (and questions).

V3 (04/01/2023): Bring on the (AI) monkeys?

The "next level" of refinement could be to use machine learning (or maybe ChatGPT?) to automate the curation of the Q & A library.

Alternatively, we could keep this curation process manual, perhaps encouraging Academy students to engage in the curation process to reinforce their understanding of the material.

Background Material about Bots/Discord Bots

A growing list of advice about making the most effective bots:

knowbot's People

Contributors

gumptionware avatar

Watchers

Brooklin Myers avatar  avatar Kostas Georgiou avatar

knowbot's Issues

Implement initial data model (QandA)

As the data structures storing the core value of this app, Questions and Answers are each a DB table.

To start, we will assume that a given question can be asked by one person (guild member). Each question can be answered by multiple people, so Question has_many Answers, and each Answer belongs_to a Question.

OR: Will it make more sense to associate an answer to multiple questions? (If so, we would use the many-to-many/join table logic to be used below.)

Question (table)
id (DB default): unique row identifier
content (text): English phrase or sentence (the question)
asker: (ID of) Who asked - NOTE: In the first iteration, I made this a string field to store the Discord User ID
keyword: (ID of) selected Keyword - NOTE: via the question_keyword join table
tag: (ID of) selected tag - NOTE: via the question_tag join table

Answer (table)
id (DB default): unique row identifier
content (text}: Sentence(s) with the answer
answerer: (for each answer, ID of) Who answered - NOTE: In the first iteration, I made this a string field to store the Discord User ID
keyword: (ID of) selected Keyword - NOTE: via the answer_keyword join table
tag: (ID of) selected tag - NOTE: via the answer_tag join table

Keyword (table) Keywords associated with questions and answers. Associated with each via association tables 'keyword_question' and 'keyword_answer' respectively.
Fields:
id (DB default): unique row identifier
name (string): the keyword (case_insensitive, no spaces or punctuation[?])

KeywordQuestion (table) Associations between keywords and questions
keyword: (id of) keyword
question: (id of) question

KeywordAnswer (table) Associations between keywords and answers
keyword: (id of) keyword
answer: (id of) answer

Tag (table) Tags associated with questions and answers. Associated with each via association tables 'tag_question' and 'tag_answer' respectively.
Fields:
id (DB default): unique row identifier
name (string): the tag (case_insensitive, no spaces or punctuation[?])

TagQuestion (table) Associations between tags and questions
tag: (id of) tag
question: (id of) question

TagAnswer (table) Associations between tags and answers
tag: (id of) tag
answer: (id of) answer

Later

Member (table) Guild members either asking or answering questions
NOTE: May not be needed if Discord API exposes guild member data (ID, name, role(?)
id (DB default): unique row identifier
look up other from Discord API(?)

Implementation Guidance

  • Model after Academy lesson on many-to-many

To Ponder

Search against ... all words in all text fields (content) --regardless of where?

Create Reame.md

Updated boilerplate Readme.md content with real content about this app.

Implement GetUserDetails

Need to get details about the user via the Discord API (using the Nostrum package).

NOTE, re: guild (server) IDs:

  • Our (KnowBot test) Server ID = 1043297600343908353
  • DY Academy Server ID: = 959208801385455676

TO-DO: Get the ID of each server in which this bot is authorized ... seems clunky, but worry about that later,
Via Nostrum:

Nostrum API Commands

Goal: Get a current user's details (nickname, ID, etc.)

  • Initial thought: get the (guild) member information:

get_guild_member(guild_id, user_id) returns the Nostrum.Struct.Guild.Member, which has the info we want:

@type t() :: %Nostrum.Struct.Guild.Member{
  communication_disabled_until:  communication_disabled_until(),
  deaf: deaf(),
  joined_at: joined_at(),
  mute: mute(),
  nick: nick(),
  premium_since: premium_since(),
  roles: roles(),
  user: user()
}

Since get_guild_member requires the user's ID, we need:
get_current_user!() to return the user_id

Candidate code flow:

@guild_id: # A constant; see Servier ID list above
get_current_user()
|> current_user_info = get_guild_member(@guild_id)
  • BUT ... maybe just the User struct will be enough (via that initial get_user():
@type t() :: %Nostrum.Struct.User{
  avatar: avatar(),
  bot: bot(),
  discriminator: discriminator(),
  email: email(),
  id: id(),
  mfa_enabled: mfa_enabled(),
  public_flags: public_flags(),
  username: username(),
  verified: verified()
}

[EDITED] Ask a question; have it recorded to the DB

ORIGINAL:

As a student, I can ask a question and get feedback so that I can unblock myself without waiting for a response.

JH: The wrinkle: When we don't have the answer, try to point the student to our FAQs (first), and the closest match (?) to the HexDocs content on that topic

THIS IS JUST THE FIRST STEP of #8

  1. Capture the question and write it to the DB (THIS TICKET)
  2. See Issue #8 for additional steps

Add User authentication to web app (for instructors, mentors and teaching assistants)

Add standard user authentication so "administrators" of content and settings can be authenticated and authorized for these activities. Activities this will cover include:

  • Initially: Adding/updating answers to questions asked by Academy students.
  • Later: Configuring "settings" (TBD) to "tune" what question/answer combinations are shown in the list of "FAQ's"
  • More as we dream it up (TBD)

Feature: Rubber Ducking (ask for help ==> "You asked about ..." )

References:

Duckie.me
Rubber Duck Debigging
Wikipedia

BREAK THIS DOWN:

  • How to even invoke the bot (basics)
  • more basics ...

JEFF IS CONFUSED

I get the general idea of rubber-ducking, re: explain your problem to a thing that can't talk back ... and in the process of breaking down the problem and explaining it, the light bulb can come on. I view this a analogous to what I call "The Stack Overflow Syndrome" - because SO is so unfriendly to poorly-worded questions, I have answered my own question in the process of really thinking about the question enough to avoid getting slapped for that question not measuring up to SO standards.

So I support this general idea. What I'm not grokking is what this would mean in terms of the behavior of our bot.

I played a bit with Duckie.me--and RubberDuckDebugging.com, and I just became annoyed. I can see this feature becoming valuable as a kind of Socratic mentor, but that level of functionality seems way more advanced than will be feasible in the MVP.

This makes me think I'm missing the basic idea of this.

@BrooklinJazz ... please clarify. Thanks!

FAQ command (V1) - !FAQ (or !faq)

Start out as a comment that just spits out map with keyword/short descriptions, with link to Hexdocs articles (AND to a killer articles elsewhere).

/Help command (V 1.0)

/H (or /help or /HELP): Get help on using KnowBot.

Basic description of what this does, (growing) list of commands, etc.

Implement slash (/) commands to replace "!" command syntax

This will be an "Admin" function because we will only execute this logic when linking KnowBot to a new guild.

Logic Outline

  1. Figure out if our commands are already present:

IEX> Nostrum.Api.get_global_application_commands (Global commands)

IEX> Nostrum.Api.get_guildl_application_commands(<guild_id>) (Guild level commands)

  1. If NOT already present, execute create_command logic:

NOTE: We show the create_guild_application_command syntax instead of the create_global_application_command syntax, which may not be the best practice once the initial development is completed.

  • The create_guild... syntax is intended for quick feedback during development and debugging.
  • Using the create_global... syntax is probably better as the "go-to" in the published admin functionality.
  1. Confirm the list of commands by repeating the applicable flavor of step 1 above.

To-Do (maybe sub-tickets)

  • /Help (... /h, /help, /?)
  • /FAQ
  • /Q ( ... /q, /question ... /ask /ASK ...)
  • /Answer
  • Expose a button in Discord .... click the button to answer that question.

[EDITING...] !q/!Q (question) command - store questions ... and find answers (evolved to be smarter and smarter) - MULTIPLE TICKETS

EDITS:

  1. If this were originally a single user story, it should have really been an epic -- a list of multiple stories
  2. Replaced "/ with "!" (in this and other issues) to reflect that we are starting with the "!" prefix bot input

The basic idea here is to be an INPUT mechanism for KnowBot administration.

[New:] This "epic" can be broken down into the following stories:

Example

!Q How do regular expressions work?

  • What's implied here (and with all questions) is " ... in Elixir and/or Phoenix"

If KnowBot cannot immediately answer that question, it could record who asked the question (so we can get back to that person) and trigger some sort of event (or set a flag) to alert KnowBot administrators that there is an open question to be answered.

However ...

  • Thinking about this practically, If I were a student and KnowBot couldn't answer my question, I would immediately ping someone else for an answer.
  • This inspires the idea for a /A syntax, which might be more useful for an Academy instructor or TA to use when answering a question. Prefixing that answer with /A could result in that answer being added to the list of answered questions, so the next time someone asks that question (via KnowBot), the answer is readily available.

Add "Answer a question" logic (V1)

This first "hack" will use the web app ("Admin Dashboard")'s standard Phoenix UI to create Answers.

That is already working via OOTB scaffolding, but we need to add the association(s) between questions and answers.

Most pragmatically: When answering a question, the teacher/mentor/assistant ("admin user") needs to be able to see the list of unanswered questions ... ya know ... so they know what question they want to answer.

So ... that implies a user story like this:

"As a KnowBot instructor, mentor or teaching assistant, I need to see the list of unanswered questions, select a question to answer, and create/read/update/delete answers, with all these actions retaining the relationship between the answer I am acting on and the question(s) it answers.

V1 Design/Implementation Steps

We will keep it simple in this first iteration. From the list of questions WITHOUT answers, a question to answer will be selected. The ID of that question will be associated with the answer being created.

  • Create a "questions_answers" association table and add many-to-many logic to Question and Answer schemas
  • Add association pre-loading logic where needed (figure this out...)
  • Modify the Questions listing (index) page to show only questions without associated answers
  • Add "Answer" to the available actions (links) on the Questions listing page
  • "Carry" the ID of that question to the "create an answer" logic to populate an association between the answer being created and the question being answered.
  • After saving the answer, also add a row to the QuestionsAnswers table with the ID of the selected question and the ID of the answer just created.

Stretch Goal: Modify the Answer detail (show) page to show questions that might also be answered by the content of this answer.

Deploy to Fly.io

Use the rocking Deployment content from DYA ... AND create custom domain name ... either:

  • dya.knowbot.fyi , or
  • dya.knowbot.knowware.io

Feature: Ping list of mentors/teacher(s)

Need to clarify what the "triggers" would be for this
[EDIT:]

  • Initially, we are recording questions in the database, so we need to "ping" the list (of instructors, mentors, teaching assistants, ec.) whenever a new question is entered

  • Later, we probably want to repeat that ping if the question has not been answered within a time period

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.