Skip to content

ObjectIsAdvantag/smartsheet-to-webex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smartsheet to Webex

a Node.js webhook that posts messages to Webex as new rows are filled in a SmartSheet.

To run this code, you will need to:

  1. create a SmartSheet, add a form to it, and pick your Smartsheet info (sheet id and access token)
  2. launch the app after entering the required environment variables (check below for an example on Heroku)

UPDATE: the webhook creation and validation by the SmartSheet API are now directly handled from the webhook app, check register.js for details.

All set! please reach to your Smartsheet's form and enter a guess. You'll see your message poping up in your Webex Messaging client. Update the template to reflect the structure of your smartsheet.

Quick start on Glitch

Click Remix on Glitch

Then open the .env file and paste your bot's token, space id, as well as your smartsheet token and sheet id.

You app is all set: the webhook got automatically created from glitch's PROJECT_DOMAIN env variable.

Your app healthcheck is accessible at your application public url.

Go to your smartsheet and start entering new values, then customize the mustache template for your smartsheet columns.

Launch the SmartSheet to Webex app

For Mac, Linux and bash users, open a terminal and type:

git clone https://github.com/CiscoDevNet/smartsheet-to-webex
cd smartsheet-to-webex
npm install
DEBUG=s2wt*,register*,challenge* SMARTSHEET_TOKEN="ka5XXXXXXXXXXXXXXXX" SMARTSHEET_ID="627552342630404" BOT_TOKEN="MmQ5ZTBYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" SPACE_ID="Y2lzY29zZZZZZZZZZZZZZZZZZZZZZZZZ" PUBLIC_URL="https://e4a1e175.ngrok.io" node webhook.js

For Windows users, open a command shell and type:

git clone https://github.com/CiscoDevNet/smartsheet-to-webex
cd smartsheet-to-webex
npm install
set DEBUG=webhook*
set BOT_TOKEN=XXXXXXXXX
set SPACE_ID=YYYYYYYYYYY
...
node webhook.js

And here is an example of environment variables on Heroku:

Heroku env variables

Done, your webhook is live

Let's hit your app's healthcheck! From the command line, type:

curl -X GET http://localhost:8080

To manually register your app as a Smartsheet Webhook

Note: this step is now optional as the registration is automatically performed at launch.

Create a Smartsheet API token from your smartsheet account:

  • login
  • click your avatar, pick "Apps and Integrations..."
  • among your Personal Settings, select "API Access"
  • click the "Generate new access token" button

Now, let's list your smartsheets and look for the identifier of the smartsheet you want to monitor. From the terminal, run the command below:

curl -X GET https://api.smartsheet.com/2.0/sheets \
  -H 'Authorization: Bearer qq0w5090qq0w5090qq0w5090' 

Almost there, create a SmartSheet webhook on the command line by typing:

curl -X POST https://api.smartsheet.com/2.0/webhooks \
  -H 'Authorization: Bearer qq0w5090qq0w5090qq0w5090' \
  -H 'Content-Type: application/json' \
  -d '{ 
    "callbackUrl": "https://e6174831.ngrok.io",
    "events": ["*.*"],
    "name": "From Postman",
    "scope": "sheet",
    "scopeObjectId" : "6275510532630404",
    "version": "1"
}'

Finally, let's validate the newly created webhook above by updating it (as per the Smartsheet specs). Please replace with the webhook id below:

curl -X PUT https://api.smartsheet.com/2.0/webhooks/5481972073031556 \
  -H 'Authorization: Bearer qq0w5090qq0w5090qq0w5090' \
  -H 'Content-Type: application/json' \
  -d '{ "enabled": true }'

That's it, create a new row entry, and check it shows up in the console. Note: update the provided sample with your own custom logic!

Releases

No releases published

Packages

No packages published