GithubHelp home page GithubHelp logo

ignition-it / airwatch-engine Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 2.05 MB

Slack bot to control AirWatch via API. Current function includes changing the enrollment user on any computer.

Home Page: https://www.ignitionit.net

License: Apache License 2.0

JavaScript 100.00%
slack enrollment-user airwatch-engine control-airwatch

airwatch-engine's Introduction

Ignition AirWatch-Engine

Slack bot to control AirWatch via API. Current function includes changing the enrollment user on any computer.

app_home

select_client

select_device_and_user

confirmation

SETUP:

  1. Make a copy of this Google Sheet with the GAS project attached: https://docs.google.com/spreadsheets/d/1DkIUSqdDM5fnHMG7zd7hO0EVUcaw6z9AzpL0RRHeKtw/edit?usp=sharing

  2. Open the Script Editor (Tools > Script Editor) and deploy the project as a web app (Publish > Deploy as web app...)

    • Project version: New
    • Execute the app as: Me
    • Who has access to the app: Anyone, even anonymous

deploy_as_web_app

set_web_app_options

  1. Copy the web app URL and paste it into the //URL comment at the top of 1. Handler.gs for later use

copy_web_app_url

  1. Navigate to File > Project properties > Script properties and set scriptSecret to a random password. Replace TOKEN in the //URL comment with this password

open_project_properties

script_secret

  1. Go to https://api.slack.com/apps and create a new app. Set an app name, description, color, and icon (use airwatch_square.png in the Images folder if you'd like)

create_slack_app

set_slack_app_icon

  1. Add users:read and users:write to the Bot Token Scopes (OAuth & Permissions > Scopes > Bot Token Scopes > Add an OAuth Scope)

set_bot_token_scopes

  1. Navigate to App Home and set Always Show My Bot as Online to ON, Home Tab to ON, and Messages Tab to OFF

turn_on_app_home

  1. Navigate to Interactive Components and turn on Interactivity

  2. Copy your Web App URL from Step 3. and set the app= to slack and the type= to interaction, then paste the link into the Request URL box

interactivity_request_url

  1. Under Select Menus, paste the same URL into the Options Load URL but change type= to menu. Click Save Changes

select_menus_url

  1. Navigate to Event Subscriptions and set Enable Events to ON

  2. In the Request URL box, paste the same link as Steps 9. and 10. but change the type= to event. Slack will then verify that your script succesfully returns the challenge token (see "//Slack one-time URL verification" section, around line 160 of 1. Handler.gs)

events_request_url

  1. Open the Subscribe to bot events section and add app_home_opened. Click Save Changes

subscribe_to_bot_events

  1. Navigate to Install App and click Install App to Workspace

  2. Copy the Bot User OAuth Access Token. Go back to the Script Editor and add it to Script Properties under slackBotToken

bot_user_oauth_token

slack_bot_token

  1. Publish your web app as a new version to save changes (Publish > Deploy as web app...): Set Project version: to New and click Update

  2. In Slack, open your new App (search for your app in the quick switcher). After a moment, the App Home tab should load with the AirWatch logo and the Change Enrollment User button

app_home

  1. Create an API admin service account: In the AirWatch console, navigate to Accounts > Administrators > List View and click Add > Add Admin. Set name, password, etc. Make sure to assign to a permissions role that allows for read/write API access to any OGs you'd like the Slack App to be able to access.

  2. In the Script Editor, navigate to Script properties and add API admin service account username as airWatchUsername and password as airWatchPassword

  3. Navigate to Settings > System > Advanced > API > REST API and add an Admin API key

  4. Add the AirWatch API key in Script properties as airWatchTenantCode

  5. Add your AirWatch tenant URL (e.g. "ds000.awmdm.com") in Script properties as airWatchTenant

project_properties_example

  1. Go back to your app in Slack and click the Change Enrollment User button!

Notes:

To turn on logging, set var logging = true; in 99. Logger.gs. I have various log() functions scattered around the code currently. Due to the speed limitations of writing logs to Google Sheets, having too many logging entries can slow the script down to the point where it extends past the strict time limitations Slack has on it's API response requirements. Comment out any log() entries you don't need.

Created by Ella for Ignition, Inc., a California corporation https://www.ignitionit.net

airwatch-engine's People

Contributors

queerdo avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.