Giter VIP home page Giter VIP logo

deno-triage-rotation's Introduction

Triage Rotation

This automation allows users to create, manage, and delete rotation or on-call assignments. This app uses datastores to store rotations on a per-channel basis.

deno-triage-rotation

Guide Outline:


Included Workflows

  • Manage rotation: Create, manage, or delete an existing rotation. This workflow is triggered by a shortcut.
  • Advance rotation: Updates the rotation to the latest, notifies users. This workflow is triggered by a schedule.

Setup

Before getting started, first make sure you have a development workspace where you have permission to install apps. Please note that the features in this project require that the workspace be part of a Slack paid plan.

Install the Slack CLI

To use this template, you need to install and configure the Slack CLI. Step-by-step instructions can be found in our Quickstart Guide.

Clone the Template

Start by cloning this repository:

# Clone this project onto your machine
$ slack create my-app -t slack-samples/deno-triage-rotation

# Change into the project directory
$ cd my-app

Running Your Project Locally

While building your app, you can see your changes appear in your workspace in real-time with slack run. You'll know an app is the development version if the name has the string (local) appended.

# Run app locally
$ slack run

Connected, awaiting events

To stop running locally, press <CTRL> + C to end the process.

Creating Triggers

Triggers are what cause workflows to run. These triggers can be invoked by a user, or automatically as a response to an event within Slack.

When you run or deploy your project for the first time, the CLI will prompt you to create a trigger if one is found in the triggers/ directory. For any subsequent triggers added to the application, each must be manually added using the trigger create command.

When creating triggers, you must select the workspace and environment that you'd like to create the trigger in. Each workspace can have a local development version (denoted by (local)), as well as a deployed version. Triggers created in a local environment will only be available to use when running the application locally.

Link Triggers

A link trigger is a type of trigger that generates a Shortcut URL which, when posted in a channel or added as a bookmark, becomes a link. When clicked, the link trigger will run the associated workflow.

Link triggers are unique to each installed version of your app. This means that Shortcut URLs will be different across each workspace, as well as between locally run and deployed apps.

With link triggers, after selecting a workspace and environment, the output provided will include a Shortcut URL. Copy and paste this URL into a channel as a message, or add it as a bookmark in a channel of the workspace you selected. Interacting with this link will run the associated workflow.

Note: triggers won't run the workflow unless the app is either running locally or deployed!

Manual Trigger Creation

To manually create a trigger, use the following command:

$ slack trigger create --trigger-def triggers/manage_rotation.ts

Workflow Usage

Add your app to the same channel where the link trigger was shared. You can do this by @mentioning the app directly in a message in the channel.

Manage Rotation

With your app running locally (slack run), click the link trigger that you shared in your Slack workspace. The workflow's first step, an input form, will appear where you can complete the required fields to create a rotation for the channel where you triggered the worklow.

If a rotation belonging to the channel already exists, the form will show details about the rotation and allow you to edit those fields.

After you submit the form, the next step in the workflow creates a rotation and creates a scheduled trigger for workflow #2: Advance Rotation.

To check whether your rotation has been created, just trigger the workflow from the channel again and look at the existing rotation details. You can also delete an existing rotation from this form.

Advance Rotation

This workflow is triggered by a scheduled trigger created in a step in the earlier workflow. This workflow notifies the current rotation assignee in the channel and then advances the rotation.

πŸ’‘ This app comes set up with a .env file and the ability to turn on a debugMode to give you a bit more control on when Advance Rotation (see, workflows/advance_rotation.ts) is triggered. This is helpful for debugging.

Datastores

For storing data related to your app, datastores offer secure storage on Slack infrastructure. For an example of a datastore, see datastores/rotations.ts. The use of a datastore requires the datastore:write/datastore:read scopes to be present in your manifest.

Testing

Test filenames should be suffixed with _test.

Run all tests with deno test:

$ deno test

Deploying Your App

Once development is complete, deploy the app to Slack infrastructure using slack deploy:

$ slack deploy

When deploying for the first time, you'll be prompted to create a new link trigger for the deployed version of your app. When that trigger is invoked, the workflow should run just as it did when developing locally (but without requiring your server to be running).

Viewing Activity Logs

Activity logs of your application can be viewed live and as they occur with the following command:

$ slack activity --tail

Project Structure

.slack/

Contains apps.dev.json and apps.json, which include installation details for development and deployed apps.

datastores/

Datastores securely store data for your application on Slack infrastructure. Required scopes to use datastores include datastore:write and datastore:read.

functions/

Functions are reusable building blocks of automation that accept inputs, perform calculations, and provide outputs. Functions can be used independently or as steps in workflows.

triggers/

Triggers determine when workflows are run. A trigger file describes the scenario in which a workflow should be run, such as a user pressing a button or when a specific event occurs.

workflows/

A workflow is a set of steps (functions) that are executed in order.

Workflows can be configured to run without user input or they can collect input by beginning with a form before continuing to the next step.

manifest.ts

The app manifest contains the app's configuration. This file defines attributes like app name and description.

slack.json

Used by the CLI to interact with the project's SDK dependencies. It contains script hooks that are executed by the CLI and implemented by the SDK.

Resources

To learn more about developing automations on Slack, visit the following:

deno-triage-rotation's People

Contributors

cchensh avatar filmaj avatar github-actions[bot] avatar hello-ashleyintech avatar misscoded avatar srajiang avatar vegeris avatar williambergamin avatar zimeg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deno-triage-rotation's Issues

Manifest validation error when deploying

Having issues deploying/running locally when using only the template with no modifications, with the following error:

🚫 Error: The provided manifest file does not validate against schema. Consult the additional errors field to locate specific issues (invalid_manifest)

Error Details:

1: Missing value for parameter `interactivity` (invalid_trigger_inputs)
Source: /workflows/advance_rotation/steps/0


The above errors were returned by the following Slack API method: /api/apps.manifest.validate

`channel_not_found` during 'Update the channel topic'

After successfully setting up/managing the rotation, when the configured time arrives, the channel to have its topic updated is not found:

2023-10-02 15:36:01 [info] [Fn0105] (Trace=Tr0603K0JU3S) Function 'Update the channel topic' (Slack function) started
2023-10-02 15:36:02 [error] [Fn0105] (Trace=Tr0603K0JU3S) Function 'Update the channel topic' (%!!(MISSING)s(<nil>) function) failed
	channel_not_found
2023-10-02 15:36:02 [error] [Wf05UWRDCCLU] (Trace=Tr0603K0JU3S) Workflow step 'Update the channel topic' failed
2023-10-02 15:36:02 [error] [Wf05UWRDCCLU] (Trace=Tr0603K0JU3S) Workflow 'Advance Rotation' failed
	channel_not_found
2023-10-02 15:36:03 [error] [Fn0603BZUV24] (Trace=Tr0603K0JU3S) Function 'Advance Rotation' (%!!(MISSING)s(<nil>) function) failed
	channel_not_found

Unable to deploy

Hello, I'm unable to deploy the latest version of this app; I was able to successfully run it locally however.

~/code/RotationManager via β¬’ v16.20.0 via πŸ¦• v1.35.0 using ☁️  REDACTED took 56.5s
➜ slack deploy
? Choose a deployed environment REDACTED

πŸ“š App Manifest
   Updated app manifest for "RotationManager" in REDACTED

🏠 Workspace Install
   Installed "RotationManager" app to REDACTED
   Updated app icon: assets/icon.png
   Finished in 2.9s

⚑ Listing triggers installed to the app...

πŸ”— Shortcut trigger:

   Manage rotation REDACTED (shortcut)
   Created: 2023-07-21 12:04:56 -05:00 (13 minutes ago)
   Collaborators:
     REDACTED
   Can be found and used by:
     everyone
   https://slack.com/shortcuts/REDACTED


β Ή Packaging app for deploymenterror: npm specifiers have not yet been implemented for this subcommand (https://github.com/denoland/deno/issues/15960). Found: npm:@slack/[email protected]
Error bundling function file: open_form
error: Uncaught Error: Error bundling function file: open_form
throw new Error(`Error bundling function file: ${fnId}`);
            ^
at createFunctionFile (https://deno.land/x/[email protected]/build.ts:82:13)
at eventLoopTick (ext:core/01_core.js:183:11)
at async validateAndCreateFunctions (https://deno.land/x/[email protected]/build.ts:39:5)
at async https://deno.land/x/[email protected]/build.ts:127:3
Check /Users/gaahrdner/.slack/logs/slack-debug-20230721.log for full error logs

⠸ Packaging app for deployment🚫 Deploy error: error packaging project: Command for 'BuildProject' returned an error: exit status 1 (sdk_hook_invocation_failed)

Suggestion:

Run `slack doctor` to check that your system dependencies are up-to-date.

β Έ Packaging app for deployment%

Here are the results from slack doctor:

➜ slack doctor

SYSTEM

    βœ” Operating System (the kernel and drivers)
        Version: darwin (amd64)

    βœ” Deno (a JavaScript runtime)
        Version: v1.35.0
        Recommendation: We suggest using the latest version of Deno

    βœ” Git (a version control system)
        Version: git version 2.41.0


SLACK

    βœ” CLI (this tool for building Slack apps)
        Version: 2.5.1

    βœ” Configurations (any adjustments to settings)
        System ID: REDACTED
        Last updated: 2023-07-21 11:49:39 -05:00
        Experiments: None

    βœ” Credentials (your Slack authentication)
        Team domain: REDACTED
        Team ID: REDACTED
        User ID: REDACTED
        Last updated: 2023-07-21 11:49:56 -05:00
        Authorization level: Workspace
        Token status: Valid


PROJECT

    βœ” Configurations (your project's CLI settings)
        Project ID: REDACTED

    βœ” Dependencies (requisites for development)
        deno_slack_hooks: 1.1.0
        deno_slack_sdk: 2.1.4
        deno_slack_api: 2.1.1

Errors: 0

πŸ’Œ We would love to know how things are going
   Survey your development experience with slack feedback

Fails to create a rotation

Here are the logs when running with slack run:

2023-09-21 12:43:37 [info] [Wf05SYNCFQSK] (Trace=Tr05TAAZCNG5) Workflow step 'Opens a rotation form' completed
2023-09-21 12:43:38 [info] [Wf05SYNCFQSK] (Trace=Tr05TAAZCNG5) Workflow step 3 of 4 started
2023-09-21 12:43:38 [info] [Fn05TD5T5LH1] (Trace=Tr05TAAZCNG5) Function 'Create rotation' (app function) started
There was an error scheduling the trigger invalid_start_before_now undefined
2023-09-21 12:43:39 [info] [Datastore:rotations] (Trace=Tr05TAAZCNG5) Datastore get succeeded with 'id: C02ARJE6XNU'
2023-09-21 12:43:39 [error] [Fn05TD5T5LH1] (Trace=Tr05TAAZCNG5) Function 'Create rotation' (%!!(MISSING)s(<nil>) function) failed
	invalid_start_before_now
2023-09-21 12:43:40 [error] [Wf05SYNCFQSK] (Trace=Tr05TAAZCNG5) Workflow step 'Create rotation' failed
2023-09-21 12:43:40 [error] [Wf05SYNCFQSK] (Trace=Tr05TAAZCNG5) Workflow 'Manage Rotation' failed
	invalid_start_before_now
2023-09-21 12:43:41 [error] [Fn05TD8P3QQJ] (Trace=Tr05TAAZCNG5) Function 'Manage Rotation' (%!!(MISSING)s(<nil>) function) failed
	invalid_start_before_now

Seems like this error handling code is being triggered.

Error deploying

Screenshot 2023-02-28 at 11 53 07 AM

cloned this project and tried to use slack deploy and received the error in above screenshot. all system dependencies are up to date. Am i doing something wrong?

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.