{"id":26289995,"url":"https://github.com/slack-samples/deno-simple-survey","last_synced_at":"2025-05-07T22:44:10.253Z","repository":{"id":114488865,"uuid":"592528573","full_name":"slack-samples/deno-simple-survey","owner":"slack-samples","description":"Request and collect feedback on messages using reacjis","archived":false,"fork":false,"pushed_at":"2025-01-16T18:55:58.000Z","size":431,"stargazers_count":20,"open_issues_count":7,"forks_count":7,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-05-07T22:44:05.115Z","etag":null,"topics":["next-gen"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slack-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-23T23:11:48.000Z","updated_at":"2025-02-19T11:40:09.000Z","dependencies_parsed_at":"2023-09-28T21:03:17.749Z","dependency_job_id":"8c158440-1527-4ccc-901a-508266c05f43","html_url":"https://github.com/slack-samples/deno-simple-survey","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"slack-samples/deno-starter-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-samples%2Fdeno-simple-survey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-samples%2Fdeno-simple-survey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-samples%2Fdeno-simple-survey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-samples%2Fdeno-simple-survey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slack-samples","download_url":"https://codeload.github.com/slack-samples/deno-simple-survey/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252967974,"owners_count":21833245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["next-gen"],"created_at":"2025-03-14T23:17:35.509Z","updated_at":"2025-05-07T22:44:10.231Z","avatar_url":"https://github.com/slack-samples.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Survey\n\nThis automation demonstrates workflows for requesting and collecting feedback on\nmessages and storing responses in a Google Sheet.\n\nhttps://user-images.githubusercontent.com/18134219/215910112-68c08e0f-597d-4813-bce0-aae174289948.mp4\n\n**Guide Outline**:\n\n- [Included Workflows](#included-workflows)\n- [Setup](#setup)\n  - [Install the Slack CLI](#install-the-slack-cli)\n  - [Clone the Sample App](#clone-the-sample-app)\n  - [Prepare Google Services](#prepare-google-services)\n- [Running Your Project Locally](#running-your-project-locally)\n- [Creating Triggers](#creating-triggers)\n- [Datastores](#datastores)\n- [Testing](#testing)\n- [Deploying Your App](#deploying-your-app)\n- [Viewing Activity Logs](#viewing-activity-logs)\n- [Project Structure](#project-structure)\n- [Resources](#resources)\n\n---\n\n## Included Workflows\n\n- **Prompt survey creation**: Ask if a user wants to create a survey when a\n  :clipboard: reaction is added to a message\n- **Create a survey**: Respond to the reacted message with a feedback form and\n  make a new spreadsheet to store responses\n- **Respond to a survey**: Open the feedback form and store responses in the\n  spreadsheet\n- **Remove a survey**: Delete messages with survey related link triggers\n- **Event configurator**: Update the channels to survey and surveying users for\n  reaction events\n- **Maintenance job**: A daily run workflow that ensures bot user membership in\n  channels specified for event reaction triggers. Recommended for\n  production-grade operations\n\n## Setup\n\nBefore getting started, first make sure you have a development workspace where\nyou have permission to install apps. **Please note that the features in this\nproject require that the workspace be part of\n[a Slack paid plan](https://slack.com/pricing).**\n\n### Install the Slack CLI\n\nTo use this sample, you need to install and configure the Slack CLI.\nStep-by-step instructions can be found in our\n[Quickstart Guide](https://api.slack.com/automation/quickstart).\n\n### Clone the Sample App\n\nStart by cloning this repository:\n\n```zsh\n# Clone this project onto your machine\n$ slack create my-app -t slack-samples/deno-simple-survey\n\n# Change into the project directory\n$ cd my-app\n```\n\n### Prepare Google Services\n\nWith [external authentication](https://api.slack.com/automation/external-auth)\nyou can programmatically interact with Google services and APIs from your app,\nas though you're the authorized user.\n\nThe client credentials needed for these interactions can be collected from a\nGoogle Cloud project with OAuth enabled and with access to the appropriate\nservices.\n\n#### Create a Google Cloud Project\n\nBegin by creating a new project from\n[the Google Cloud resource manager](https://console.cloud.google.com/cloud-resource-manager),\nthen\n[enabling the Google Sheets API](https://console.cloud.google.com/apis/library/sheets.googleapis.com)\nfor this project.\n\nNext,\n[create an OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent)\nfor your app. The \"User Type\" and other required app information can be\nconfigured as you wish. No additional scopes need to be added here, and you can\nadd test users for development if you want (especially useful if one Google\naccount owns the Google Cloud project but you want to test the authentication\nflow using a different Google account).\n\nClient credentials can be collected by\n[creating an OAuth client ID](https://console.cloud.google.com/apis/credentials/oauthclient)\nwith an application type of \"Web application\". Under the \"Authorized redirect\nURIs\" section, add `https://oauth2.slack.com/external/auth/callback` then click\n\"Create\".\n\nYou'll use these newly created client credentials in the next steps.\n\n#### Set the Client ID\n\nStart by renaming the `.env.example` file at the top level of your project to\n`.env`, being sure not to commit this file to version control. This file will\nstore sensitive, app-specific variables that are determined by the environment\nbeing used.\n\nFrom your new Google project's dashboard, copy the **Client ID** and paste it as\nthe value for `GOOGLE_CLIENT_ID` in the `.env` file. This value will be used in\n`external_auth/google_provider.ts` – the custom OAuth2 provider definition for\nthis Google project.\n\nOnce complete, use `slack run` or `slack deploy` to update your local or hosted\napp!\n\n\u003e Note: Unlike environment variables used at runtime, this variable is only used\n\u003e when generating your app manifest. Therefore, you do **not** need to use the\n\u003e `slack env add` command to set this value for\n\u003e [deployed apps](#deploying-your-app).\n\n#### Validate Your App\n\nAt this point you should be able to build and start your project. Go ahead and\nexecute the following command to see if your app works properly.\n\nWhen prompted:\n\n- install the app to your workspace\n- create the `triggers/configurator.ts` [trigger](#creating-triggers).\n\n```zsh\n# Run app locally\n$ slack run\n\nConnected, awaiting events\n```\n\nNote: Ignore warnings at this stage!\n\nOnce complete, press `\u003cCTRL\u003e + C` to end the process. You will need to create\nadditional secrets before using your application.\n\n#### Save the Client Secret\n\nWith your client secret ready, run the following command, replacing\n`GOOGLE_CLIENT_SECRET` with your own secret:\n\n```sh\n$ slack external-auth add-secret --provider google --secret GOOGLE_CLIENT_SECRET\n```\n\nWhen prompted to select an app, choose the `(local)` app only if you're running\nthe app locally.\n\n#### Initiate the OAuth2 Flow\n\nWith your Google project created and the Client ID and secret set, you're ready\nto initiate the OAuth flow!\n\nIf all the right values are in place, the following command will prompt you to\nchoose an app, select a provider (hint: choose the `google` one), then pick the\nGoogle account you want to authenticate with:\n\n```sh\n$ slack external-auth add\n```\n\n\u003e :unlock: Spreadsheets generated as part of the **Create a survey** workflow\n\u003e will be created from the account you authenticate with! To limit the users\n\u003e that can create surveys, an **Event configurator** workflow is used.\n\nOnce you've successfully connected your account, you're almost ready to create\nsurveys at the press of a reaction!\n\nTo complete the connection process, you need to let your app know what\nauthenticated account you'll be using for specific workflows.\n\nFor this specific app, only the `CreateSurvey` workflow requires a configured\nexternal Google account, so we can set that up with our freshly authed account.\nTo do so, run:\n\n```sh\nslack external-auth select-auth\n```\n\nSelect the workspace and app environment for your app, then select the\n`#/workflows/create_survey` workflow to give it access to your Google account.\nThen, select the same provider and the external account that you authenticated\nwith above.\n\nAt last - you're all set to survey! :sparkles:\n\n## Running Your Project Locally\n\nWhile building your app, you can see your changes appear in your workspace in\nreal-time with `slack run`. You'll know an app is the development version if the\nname has the string `(local)` appended.\n\n```zsh\n# Run app locally\n$ slack run\n\nConnected, awaiting events\n```\n\nTo stop running locally, press `\u003cCTRL\u003e + C` to end the process.\n\n## Creating Triggers\n\n[Triggers](https://api.slack.com/automation/triggers) are what cause workflows\nto run. These triggers can be invoked by a user, or automatically as a response\nto an event within Slack.\n\nWhen you `run` or `deploy` your project for the first time, the CLI will prompt\nyou to create a trigger if one is found in the `triggers/` directory. For any\nsubsequent triggers added to the application, each must be\n[manually added using the `trigger create` command](#manual-trigger-creation).\n\nWhen creating triggers, you must select the workspace and environment that you'd\nlike to create the trigger in. Each workspace can have a local development\nversion (denoted by `(local)`), as well as a deployed version. _Triggers created\nin a local environment will only be available to use when running the\napplication locally._\n\n### Link Triggers\n\nA [link trigger](https://api.slack.com/automation/triggers/link) is a type of\ntrigger that generates a **Shortcut URL** which, when posted in a channel or\nadded as a bookmark, becomes a link. When clicked, the link trigger will run the\nassociated workflow.\n\nLink triggers are _unique to each installed version of your app_. This means\nthat Shortcut URLs will be different across each workspace, as well as between\n[locally run](#running-your-project-locally) and\n[deployed apps](#deploying-your-app).\n\nWith link triggers, after selecting a workspace and environment, the output\nprovided will include a Shortcut URL. Copy and paste this URL into a channel as\na message, or add it as a bookmark in a channel of the workspace you selected.\nInteracting with this link will run the associated workflow.\n\n**Note: triggers won't run the workflow unless the app is either running locally\nor deployed!**\n\n### Manual Trigger Creation\n\nTo manually create a trigger, use the following command:\n\n```zsh\n$ slack trigger create --trigger-def triggers/configurator.ts\n```\n\n### Using the Configurator Trigger\n\nWith the configurator link trigger (`triggers/configurator.ts`) you can\nconfigure the channel list and surveying users, as shown below:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/18134219/215911063-e3ab2892-1644-4f63-9383-f37be2954172.gif\" width=\"600\"\u003e\n\nOnce the app is added to the channel being surveyed, configured users that add a\n`:clipboard:` reaction to a message will begin the survey process with a prompt\nto create a new survey.\n\n## Datastores\n\nFor storing data related to your app, datastores offer secure storage on Slack\ninfrastructure. For an example of a datastore, see\n`datastores/survey_datastore.ts`. The use of a datastore requires the\n`datastore:write`/`datastore:read` scopes to be present in your manifest.\n\n## Testing\n\nTest filenames should be suffixed with `_test`.\n\nRun all tests with `deno test`:\n\n```zsh\n$ deno test\n```\n\n## Deploying Your App\n\nOnce development is complete, deploy the app to Slack infrastructure using\n`slack deploy`:\n\n```zsh\n$ slack deploy\n```\n\nWhen deploying for the first time, you'll be prompted to\n[create a new link trigger](#creating-triggers) for the deployed version of your\napp. When that trigger is invoked, the workflow should run just as it did when\ndeveloping locally (but without requiring your server to be running).\n\n### Production Maintenance Job\n\nFor production, we recommend enabling the included `maintenance_job.ts`\nworkflow.\n\nThe app's bot user must be a member of a channel in order to listen for events\nthere. When you add a new channel in the configuration modal, the bot user\nautomatically joins the channel. **However, anyone can remove the bot user from\nthe channel at any time.**\n\nTo enable a job that will re-add the bot user to channel, run the following\ncommand that generates a scheduled trigger to run daily:\n\n```zsh\n$ slack trigger create --trigger-def triggers/daily_maintenance_job.ts\n```\n\n## Viewing Activity Logs\n\nActivity logs of your application can be viewed live and as they occur with the\nfollowing command:\n\n```zsh\n$ slack activity --tail\n```\n\n## Project Structure\n\n### `.slack/`\n\nContains `apps.dev.json` and `apps.json`, which include installation details for\ndevelopment and deployed apps.\n\n### `datastores/`\n\n[Datastores](https://api.slack.com/automation/datastores) securely store data\nfor your application on Slack infrastructure. Required scopes to use datastores\ninclude `datastore:write` and `datastore:read`.\n\n### `external_auth/`\n\n[External authentication](https://api.slack.com/automation/external-auth)\nenables connections to external services using OAuth2. Once connected, you can\nperform actions as the authorized user on these services using custom functions.\n\n### `functions/`\n\n[Functions](https://api.slack.com/automation/functions) are reusable building\nblocks of automation that accept inputs, perform calculations, and provide\noutputs. Functions can be used independently or as steps in workflows.\n\n### `triggers/`\n\n[Triggers](https://api.slack.com/automation/triggers) determine when workflows\nare run. A trigger file describes the scenario in which a workflow should be\nrun, such as a user pressing a button or when a specific event occurs.\n\n### `workflows/`\n\nA [workflow](https://api.slack.com/automation/workflows) is a set of steps\n(functions) that are executed in order.\n\nWorkflows can be configured to run without user input or they can collect input\nby beginning with a [form](https://api.slack.com/automation/forms) before\ncontinuing to the next step.\n\n### `manifest.ts`\n\nThe [app manifest](https://api.slack.com/automation/manifest) contains the app's\nconfiguration. This file defines attributes like app name and description.\n\n### `slack.json`\n\nUsed by the CLI to interact with the project's SDK dependencies. It contains\nscript hooks that are executed by the CLI and implemented by the SDK.\n\n## Resources\n\nTo learn more about developing automations on Slack, visit the following:\n\n- [Automation Overview](https://api.slack.com/automation)\n- [CLI Quick Reference](https://api.slack.com/automation/cli/quick-reference)\n- [Samples and Templates](https://api.slack.com/automation/samples)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslack-samples%2Fdeno-simple-survey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslack-samples%2Fdeno-simple-survey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslack-samples%2Fdeno-simple-survey/lists"}