{"id":21343649,"url":"https://github.com/catalystcode/bot-notifications","last_synced_at":"2025-07-12T15:31:23.876Z","repository":{"id":73516903,"uuid":"95100161","full_name":"CatalystCode/bot-notifications","owner":"CatalystCode","description":"This project implements a framework called 'notifications' which enables bot authors to implement a notifications capability, with minimal changes to the actual bot.","archived":false,"fork":false,"pushed_at":"2017-07-02T09:16:20.000Z","size":180,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-12T10:47:09.866Z","etag":null,"topics":[],"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/CatalystCode.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":"2017-06-22T09:43:52.000Z","updated_at":"2023-08-29T10:36:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"f552b73f-4083-4b72-a35c-f597b7e02ba3","html_url":"https://github.com/CatalystCode/bot-notifications","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"6909765d0e520b5127445b5f5e856571d8a7bc98"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatalystCode%2Fbot-notifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatalystCode%2Fbot-notifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatalystCode%2Fbot-notifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatalystCode%2Fbot-notifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CatalystCode","download_url":"https://codeload.github.com/CatalystCode/bot-notifications/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225824673,"owners_count":17529906,"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":[],"created_at":"2024-11-22T01:14:25.718Z","updated_at":"2024-11-22T01:14:26.286Z","avatar_url":"https://github.com/CatalystCode.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bot-Notifications\n\nA common request from companies and organizations considering bots is the ability to be able to notify users on news (e.g. new available features).\n\nThis project implements a framework called **notifications** which enables bot authors to implement a notifications capability, with minimal changes to the actual bot.\n\nIt also includes a very simple implementation that illustrates the core concepts with minimal configuration.\n\nThis project is written in TypeScript.\n\n[Source Code](https://github.com/CatalystCode/bot-notifications)\n\nSee [example folder](https://github.com/CatalystCode/bot-notifications/example) for a full bot example.\n\nThis project was developed on top of the [Handoff](https://github.com/CatalystCode/bot-handoff) project.\n\n## Preview\nAdministrator queueing a message:\n[![Preview](/docs/queue-admin.jpg)](/docs/queue-admin.jpg)\n\nUser receives the message on login:\n[![Preview](/docs/queue-user.jpg)](/docs/queue-user.jpg)\n\n## Basic Usage\n\n```javascript\n// Imports\nconst express = require('express');\nconst builder = require('botbuilder');\nconst notifications = require('botbuilder-notifications');\n\n// Setup Express Server (N.B: If you are already using restify for your bot, you will need replace it with an express server)\nconst app = express();\napp.listen(process.env.port || process.env.PORT || 3978, '::', () =\u003e {\n    console.log('Server Up');\n});\n\n// Replace this functions with custom login/verification for agents\nconst isAgent = (session) =\u003e session.message.user.name.startsWith(\"Admin\");\n\n/**\n    bot: builder.UniversalBot\n    app: express ( e.g. const app = express(); )\n    isAgent: function to determine when agent is talking to the bot\n    options: { }\n        - mongodbProvider and directlineSecret are required (both can be left out of setup options if provided in environment variables.)\n**/\nnotifications.setup(bot, app, isAgent, {\n    mongodbProvider: process.env.MONGODB_PROVIDER,\n    directlineSecret: process.env.MICROSOFT_DIRECTLINE_SECRET\n});\n\n```\n\nIf you want the sample `/webchat` endpoint to work (endpoint for the example admin), you will need to include this [`public` folder](https://github.com/CatalystCode/bot-broadcasting/example/public) in the root directory of your project, or replace with your own.\n\n## This sample\n\nThis sample includes:\n\n* A rudimentary echo bot\n* A simple WebChat-based front end for use by both Customers and Admins\n* rudimentary admin recognition via the userid entered by users\n* middleware which allows Customers and Admins to enter commands through WebChat that are interpreted and turned into Notifier method calls\n\n## How to use this code\n1) Install the npm module \n2) Setup your bot as shown in the 'basic usage' part above\n\n## How to build and run this sample project\n\n0. Clone this repo\n1. If you haven't already, [Register your bot](https://dev.botframework.com/bots/new) with the Bot Framework. Copy the App ID and App Password.\n2. If you haven't already, add a Direct Line (not WebChat) channel and copy one of the secret keys (not the same as the app id/secret)\n3. `npm install`\n4. `npm run build` (or `npm run watch` if you wish to compiled on changes to the code)\n\n### Run in the cloud\n\n1. Deploy your bot to the cloud\n2. Aim your bot registration at your bot's endpoint (probably `https://your_domain/api/messages`)\n3. Aim at least two browser instances at `https://your_domain/webchat?s=direct_line_secret_key`\n\n### ... or run locally\n\n1. Create an ngrok public endpoint [see here for details](https://github.com/Microsoft-DXEIP/Tokyo-Hack-Docs#1-with-your-app-still-running-on-localhost-bind-the-localhost-deployment-with-ngrok-we-will-need-this-url-for-registering-our-bot)\n2. Update your bot registration to reference that endpoint (probably `https://something.ngrok.io/api/messages`)\n![Reference bot to ngrok endpoint](/docs/referenceBotToNgrok.jpg)\n3. Run your bot on Mac (remember to restart if you change your code):  \n    Set your environment variables and run your code:  \n    `appId=app_id appPassword=app_password node dist/app.js`   \n4. Run your bot on Windows with PowerShell (remember to restart if you change your code):   \n    Set your environment variables  \n          `$env:appId = \"app_id\"`  \n          `$env:appPassword = \"app_password\"`  \n        Run your code:  \n          `node .\\dist\\app.js` or `npm run start` \n\n5. Aim at least two browser instances at `http://localhost:3978/webchat?s=direct_line_secret_key`\n\n### Set up your customer(s) \u0026 admins(s), and go\n\n1. Make one or more instances an agent by giving it a user id starting with the word `Admin`\n2. Make one or more instances a customer by giving it a user id *not* starting with the word `Admin`\n3. The customer bot is a simple echo bot.\n4. As an admin, type you have two options, either write `queue MSG` to schedule `MSG` to be presented whenever a new chat is started, or `broadcast MSG` to force push this message into the current active chat\n\nGood luck!\n\nRequired environment variables:\n```\n\"appId\" : \"\",\n\"appPassword\" : \"\",\n\"MICROSOFT_DIRECTLINE_SECRET\" : \"\",\n\"MONGODB_PROVIDER\" : \"\"      \n```\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatalystcode%2Fbot-notifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatalystcode%2Fbot-notifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatalystcode%2Fbot-notifications/lists"}