Skip to content

Reports the lastActivity value of users in an org, and replies with a .csv to the requesting user.

License

Notifications You must be signed in to change notification settings

wxsd-sales/user-activity-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Activity Bot

This demo report the lastActivity value of users in an org, and replies with a .csv to the requesting user.
Report Bug · Request Feature

About The Project

Walkthrough

  1. To use this application as it exists in production, send a message to useractivityreport@webex.bot in your Webex client.
  2. Send the "login" command to the bot.

3. Follow the link to login with the same Webex account from which you messaged the bot.

4. After logging in, return to your Webex client and send one of the available bot commands: **all, inactive, help**

5. A .csv report will be generated by the bot and sent you

Setup

If you simply want to use this application, you only need to follow the Walkthrough.
Installation is only needed if you wish to host a version of this bot yourself.

Prerequisites & Dependencies:

  • Python3 (v3.8.1)

Installation

  1. Clone the repo

    git clone https://github.com/WXSD-Sales/UserActivityBot.git
  2. Install the required python modules:

     pip install python-dotenv
     pip install pymongo==3.10.1
     pip install pymongo[srv]
     pip install tornado==4.5.2
     pip install requests
     pip install requests-toolbelt
    
  3. The following Environment variables are required for this demo, set with the appropriate values (see the Environment Variables section below for more details). You can copy these into a file called .env in the root directory before updating the appropriate values.

    MY_BOT_ID=<PERSON_ID_OF_BOT>
    MY_BOT_TOKEN=<BOT_ACCESS_TOKEN>
    MY_BOT_PORT=8080
    
    MY_WEBHOOK_SECRET=<SECRET_USED_WHEN_CREATING_BOT_WEBHOOK>
    
    API_URL="https://webexapis.com/v1"
    MY_CLIENT_ID=<WEBEX_OAUTH_CLIENT_ID>
    MY_CLIENT_SECRET=<WEBEX_OAUTH_CLIENT_SECRET>
    
    MY_BASE_URI="https://your.site.com"
    MY_REDIRECT_URI="/oauth"
    MY_SCOPES="spark%3Akms%20spark%3Apeople_read%20spark-admin%3Apeople_read"
    
    MY_MONGO_URI=mongodb+srv://<USER>:<PASSWORD>@<YOUR_CLUSTER_HOSTNAME>/useractivity?retryWrites=true&w=majority
    MY_MONGO_DB=useractivity
    
  4. Create the Webhooks (see below).

  5. Start the server with python 3.8 or above:

    python server.py
    

Environment Variables

MY_BOT_TOKEN
  1. login to the my-apps section of the developer portal
  2. Click "Create a New App"
  3. Select Bot
  4. Fill in the required fields You will be returned a unique bearer token for the bot.
MY_BOT_ID

This is actually the bot's personId (NOT application_id). To get the bot's personId,

  1. click here.
  2. Use the Try It editor on the right side of the page.
  3. toggle off the "Use personal access token" switch.
  4. paste the bot's token from step 1
  5. click Run
    The JSON returned will include an "id" property. This is the bot's personId.
MY_BOT_PORT=8080
API_URL="https://webexapis.com/v1"

These can remain unchanged.

MY_WEBHOOK_SECRET

See the Webhooks section below.

MY_BASE_URI
  1. This will need to be a publicly accessible location where your bot will be exposed. You can use something like ngrok to provide a tunnel from your laptop or desktop to the world.
  2. You will use this value again when you create your webhooks, and will use it + /oauth as the redirect_uri when you create the integration for MY_CLIENT_ID and MY_CLIENT_SECRET.
MY_REDIRECT_URI="/oauth"
MY_SCOPES="spark%3Akms%20spark%3Apeople_read%20spark-admin%3Apeople_read"

These can remain unchanged.

MY_CLIENT_ID
MY_CLIENT_SECRET
  1. login to the my-apps section of the developer portal
  2. Click "Create a New App"
  3. Select Integration
  4. Fill in the required fields.
    a. Your redirect_uri value when creating this integration will need to be the MY_BASE_URI + MY_REDIRECT_URI values
    b. For example, if you were to use the values given in the examples from the Installation step, your redirect_uri would be:
    https://1234.eu.ngrok.io/auth
    You will be returned a unique clientId and clientSecret when the application is created.
MY_MONGO_URL

You will need a MongoDB instance to store data. You can setup a free cluster using MongoDB Atlas. Notice the url in the example wraps the string in quotation marks ". Be aware of any special characters when setting the environment variables.

MY_MONGO_DB=useractivity

This can remain unchanged. Remember to update the DB in the MY_MONGO_URL string to match this value.

Webhooks

This application requires 2 webhooks. To create them through the developer portal click here.
1.Use the Try It Editor on the right side of the page
2.Untoggle the "Use my personal access token" switch
3.Paste the bot's token in that field.
4.Enter any name
5.targetUrl: Enter your BASE_URI
6.resource: messages
7.event: created
8.secret: Enter your MY_WEBHOOK_SECRET value (which can be anything).

License

All contents are licensed under the MIT license. Please see license for details.

Disclaimer

Everything included is for demo and Proof of Concept purposes only. Use of the site is solely at your own risk. This site may contain links to third party content, which we do not warrant, endorse, or assume liability for. These demos are for Cisco Webex usecases, but are not Official Cisco Webex Branded demos.

Contact

Please contact us at wxsd@external.cisco.com

About

Reports the lastActivity value of users in an org, and replies with a .csv to the requesting user.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published