autodesk-platform-services / aps-webhook-notifier

This sample application demonstrate Webhooks notifications for changes on BIM 360 / Autodesk Docs and Fusion 360 to SMS, Email and chat bot.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get notifications (SMS/Email/Slack) for new folders and files

Node.js npm Platforms License

Viewer OAuth2 Data-Management Webhooks

This sample application demonstrate Webhooks notifications for changes on BIM 360 / Autodesk Docs and Fusion 360 to SMS, Email and chat bot.

Thumbnail

thumbnail

Live version

Running live here and video demonstration here.

Usage: after sign in with your Autodesk account, (1) expand the tree to select a folder. Then (2), select the events to get notification. Finally, (3) enter a mobile phone number, and/or email address, and/or slack channel. Click on Create notification.

Setup

Prerequisites

This samples requires:

  1. APS credentials;
  2. Twilio account;
  3. Postmark account;
  4. Slack account.

Create the following environment variables:

APS

For using this sample, you need an Autodesk developer credentials. Visit the APS Developer Portal, sign up for an account, then create an app. Account creation and APS app creation and set up explained in details Here . For this new app, use http://localhost:3000/api/aps/callback/oauth as Callback URL. Finally take note of the Client ID and Client Secret. For localhost testing:

  • APS_CLIENT_ID and set it to above-mentioned Client ID
  • APS_CLIENT_SECRET and set it to above-mentioned Client Secret
  • APS_CALLBACK_URL and set it to http://localhost:3000/api/aps/callback/oauth

Now you need a local server to receive Webhook notifications, you can use ngrok as described here, then create a env var with the value (e.g. https://abc123.ngrok.io`)

  • APS_WEBHOOK_URL

Twilio

Create a Twilio developer account. Create an phone number. Also, you will need the Account SID and Token. The following env vars are required:

  • TWILIO_ACCOUNT_SID
  • TWILIO_TOKEN
  • TWILIO_FROM_NUMBER

Postmark

Create a Postmark developer account. Specify the FROM email, verify it. Take note of your Account ID. The following env vars are required:

  • POSTMARK_ACCOUNT_ID
  • POSTMARK_FROM_EMAIL

Slack

Create an app for Slack API on your company account to handle Incoming webhooks see more here. At the UI, enter the value in the form of T00000000/B00000000/XXXXXXXXXXXXXXXX

Running locally

Make sure to have NodeJS installed. Clone this project or download it. It's recommended to install GitHub desktop. To clone it via command line, use the following (Terminal on MacOSX/Linux, Git Shell on Windows):

git clone https://github.com/autodesk-platform-services/aps-webhook-notifier.git

Set all all environment variables described on the Setup section using the following:

  • Mac OSX/Linux (Terminal)
export VARIABLE_NAME=value
  • Windows (use Node.js command line from Start menu)
set VARIABLE_NAME=value

or you can set up the environment variables in the .env as below

APS_CLIENT_ID=value
APS_CLIENT_SECRET=value
APS_CALLBACK_URL="http://localhost:3000/api/aps/callback/oauth" # URL your users will be redirected to after logging in with their Autodesk account
APS_WEBHOOK_URL=value # host name for the webhook callback
TWILIO_ACCOUNT_SID=value
TWILIO_TOKEN=value
TWILIO_FROM_NUMER=value
POSTMARK_ACCOUNT_ID=value
POSTMARK_FROM_EMAIL=value

Install the required packaged and run the application:

npm install
npm run dev

Open the browser and go to http://localhost:3000.

Important: do not use npm start locally, this is intended for PRODUCTION only with HTTPS (SSL) secure cookies.

Deployment

A deployment should have the following environment variables defined (e.g. Heroku app settings): thumbnail

Deploy on Heroku

To deploy this application to Heroku, the Callback URL for Forge and Storage must use your .herokuapp.com address. After clicking on the button below, at the Heroku Create New App page, set your Client ID, Secret and Callback URL for Forge and respective storage.

Deploy

Watch this video on how deploy samples to Heroku.

Known issues

BIM 360 Docs Hub names are comming with wrong formating, resulting in a wrong message. This issue is under investigation.

Tips & tricks

For local development/testing, consider use nodemon package, which auto restart your node application after any modification on your code. To install it, use:

sudo npm install -g nodemon

Then, instead of npm run dev, use the following:

npm run nodemon

Which executes nodemon server.js --ignore www/, where the --ignore parameter indicates that the app should not restart if files under www folder are modified.

Troubleshooting

After installing Github desktop for Windows, on the Git Shell, if you see a error setting certificate verify locations error, use the following:

git config --global http.sslverify "false"

License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Written by

Augusto Goncalves @augustomaia, Forge Partner Development

Updated By

About

This sample application demonstrate Webhooks notifications for changes on BIM 360 / Autodesk Docs and Fusion 360 to SMS, Email and chat bot.

License:MIT License


Languages

Language:JavaScript 75.3%Language:HTML 19.4%Language:CSS 5.3%