Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| wiki:committees:trainingbot [2026/08/31 14:34] – created cory | wiki:committees:trainingbot [2026/08/31 15:48] (current) – cory | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== TrainingBot | + | < |
| + | |||
| + | # TrainingBot | ||
| Some of the committees have adopted the TrainingBot system to keep on top of training requests. | Some of the committees have adopted the TrainingBot system to keep on top of training requests. | ||
| Line 7: | Line 9: | ||
| - A Slack bot (TrainingBot) posts to the committee channel whenever someone requests training. | - A Slack bot (TrainingBot) posts to the committee channel whenever someone requests training. | ||
| - The TrainingBot posts a list of all the pending training requests to the committee channel once a week. | - The TrainingBot posts a list of all the pending training requests to the committee channel once a week. | ||
| + | - Trainers view the responses form, and when they have reached out to someone they add something to a specific row which removes them from the reminders list. | ||
| - | === Implementation details: | + | ## Implementation details: |
| - | - Create a google form in your committee' | + | - Create a google form in your committee' |
| - Make sure you collect their name, and their slack or talk handle | - Make sure you collect their name, and their slack or talk handle | ||
| - Set the google form up to save responses to a google sheet that also belongs to your committee' | - Set the google form up to save responses to a google sheet that also belongs to your committee' | ||
| - | - | + | - From the Form, click "App Scripts" |
| + | - Name the created project "< | ||
| + | - Click on the sidebar to add a library, and enter this library ID: `1NX_-nJIfqTDdmuDtLvdI4-t-sXl7V5Lt0-CBHCO54jyGwFBt9_mZ9DEa` | ||
| + | - If you don't have access to the Library, ask in `# | ||
| + | - Customize and add the following code to the main `code.gs` file in the App Script project: | ||
| + | |||
| + | ``` | ||
| + | const TRAINING_TYPE = " | ||
| + | const COMMITTEE_CHANNEL = " | ||
| + | const COMMITTEE_NAME = "3D Printing Committee"; | ||
| + | const FORM_NAME_FIELD = "Slack username"; | ||
| + | |||
| + | function onSubmit(e) { | ||
| + | let form = FormApp.getActiveForm(); | ||
| + | let formResponse = VHSWebhookCode.parseForm(form); | ||
| + | |||
| + | const username = formResponse[FORM_NAME_FIELD]; | ||
| + | const message = `${formResponse[' | ||
| + | |||
| + | VHSWebhookCode.postToSlack(COMMITTEE_CHANNEL, | ||
| + | |||
| + | const dm_message = `The ${COMMITTEE_NAME} has been notified of your training request, and someone should get back to you soon! Remember, we're all volunteers here at VHS, so please be patient!`; | ||
| + | |||
| + | VHSWebhookCode.sendSlackDMToUser(username, | ||
| + | }; | ||
| + | ``` | ||
| + | |||
| + | The most important details to get right are `COMMITTEE_CHANNEL`, | ||
| + | |||
| + | Now add a trigger, so the `onSubmit` script is run when the form is submitted: go to the triggers tab from the sidebar, and add a trigger that runs `onSubmit` when the "On form submit" | ||
| + | |||
| + | The final step is to add the weekly reminders. To do this, go to the form's responses Sheet, and under the " | ||
| + | |||
| + | Name the project something like " | ||
| + | |||
| + | Add a modified version of the following code to the App Script: | ||
| + | |||
| + | ``` | ||
| + | const TRAINING_TYPE = " | ||
| + | const SHEET_NAME = "Form Responses 1"; | ||
| + | const CHANNEL = " | ||
| + | const SHEET_NAME_INDEX = 1; | ||
| + | const SHEET_TRAINED_STATUS_INDEX = 6; | ||
| + | |||
| + | function checkForUnTrained() { | ||
| + | let untrained = VHSWebhookCode.scanSheetForNamesAndTrainers(SHEET_NAME, | ||
| + | |||
| + | let names = untrained.map((item)=> | ||
| + | |||
| + | console.log(names); | ||
| + | |||
| + | const message = `There are ${ names.length } members waiting for ${TRAINING_TYPE} training. If you have some time this week, consider setting up a training session! Training list: ${names.join(', | ||
| + | |||
| + | VHSWebhookCode.postToSlack(CHANNEL, | ||
| + | } | ||
| + | ``` | ||
| + | |||
| + | Important variables: | ||
| + | |||
| + | - `SHEET_NAME` is the name of the sheet - usually "Form Responses 1". | ||
| + | - `SHEET_NAME_INDEX` is the index of the name field, 0 is the first column, 1 is the second, etc. | ||
| + | - `SHEET_TRAINED_STATUS_INDEX` is the index of the field used to track if the member has been contacted. | ||
| + | |||
| + | Then go to the Triggers section, and add a "Time Based" trigger that runs `checkForUnTrained` weekly. | ||
| + | |||
| + | Don't forget to run both the scripts manually - sometimes it'll toss up a permissions dialog that you have to OK before it'll run successfully. | ||
| + | |||
| + | That's it! | ||