Skip to content

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

License

Notifications You must be signed in to change notification settings

Ignition-IT/AirWatch-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published