Friday, March 29, 2024
HomeHealthThe way to Create and Automate a Webex Area

The way to Create and Automate a Webex Area

[ad_1]

Earlier than my profession in info expertise, I used to be an educator. I started instructing inner-city children in a summer season camp, the place I realized, practiced and taught many helpful classes, together with the significance of getting enjoyable and in maintaining a optimistic each day routine. Later, I taught for the federal government and was impressed by way of expertise to avoid wasting lives (each authorities and civilian). This was a catalyst for main me again to laptop expertise (I used to be a programmer and technophile as a baby). Lastly, after incomes a Grasp’s in Training and whereas instructing aboard, I realized the way to make the most of Info and Communications Expertise (ICT) in a each day routine, with a view to switch information to college students. Basically utilizing a few of the very applied sciences which serve to distract them, to show them. And, to supply them the instruments to show themselves.

Each day, incremental presentation of related and difficult info is environment friendly, enjoyable and offers a basis for studying, communication and confidence which extends past the partitions of classroom and company workplace alike.

Goal

This venture describes the way to create a Webex bot which posts to a Webex house you’ve got created. Adaptive Playing cards will probably be used to design the message the bot will put up. Information of Python is critical with a view to program the bot, message, and house particulars. GitHub Secrets and techniques, Actions, and Workflows will probably be utilized to automate precisely what and when the bot posts.

Word of the Day

A card much like the above is posted on an everyday schedule to the ‘Phrase of the Day’ Webex room. A random phrase is chosen every time from lots of of probably the most cutting-edge and fascinating phrases related to growth, coding, networking, cloud computing and the sociology of expertise. The phrase is in inexperienced font. A multi-word/sentence definition is supplied under that. Under the definition is a button with inexperienced font that’s clickable and can take the consumer to the supply and/or extra info on the phrase of the day.

Create the Webex Room

Click on on the + signal on the prime of Webex and choose ‘Create a Area’. Then identify it and click on ‘Create’. Now the room is created and it’s best to see it seem within the rooms column on the left of Webex. Now, we want the Room ID of the brand new room. We will get it by utilizing the Webex for Builders interactive Rooms API name. Ensure you’re logged in and choose to make use of your private entry token. Within the ‘sortBy’ subject, sort ‘lastactivity’. Click on the ‘Run’ button and a listing of the newest rooms you’ve interacted with needs to be returned.

The room you simply created will probably be on prime. Save the id of the room. Later, we are going to use that as the worth of our ‘teams_room’ variable. It can save you the opposite values someplace as effectively. It’s good follow to maintain notes when creating issues; you by no means know if you’ll want them.

Craft the Template of the Message to Be Posted to Your Webex Room

I desire utilizing Adaptive Playing cards when posting to Webex areas. Should you’re ranging from scratch, you’ll positively want the Buttons and Playing cards Designer discovered on Webex for Builders. Mess around with it utilizing ‘Preview mode’ till it seems to be proper after which copy the code with ‘Copy card payload’. Put it aside someplace.

WoD

Subsequent we need to create a message to put up within the Webex house that can include the cardboard we simply created. You may check this out with the interactive Create a Message on the Webex for Builders web page below the ‘Attempt it’ tab. Don’t overlook to stick your Adaptive Card code you saved into the ‘attachments’ subject, in addition to the roomID you saved from the earlier API name. Click on ‘Run’ to create the message. If you get it working, click on the ‘Instance’ tab and duplicate the code. You’ll use this to construct your request.

Constructing the App in Python

Okay, we’ve our Webex Room and the core of the message, based mostly on the adaptive card. Now, let’s write some Python code that can make all the pieces come collectively and run. I take advantage of the Visible Studio Code IDE.

Create a digital setting and begin constructing your code within it.

I take advantage of Python and the requests library to do all of the work for this app. You may see that the code is fairly easy -> https://github.com/xanderstevenson/word-of-the-day-bot/blob/essential/chatops.py. The principle substances are the adaptive card we created, some if/else statements and a easy requests perform for posting to a Webex room. I import ‘return_word’ perform from a file in the identical listing referred to as ‘phrases’. That is additionally a Python module and principally picks a random time period from a listing to put up with the cardboard to the Webex room every time the chatops.py module is run.

Create a Bot to Publish the Message to the Webex Area

Thus far you’ve got your Webex Room and you’ve got Python code to put up messages to your room. However who will put up the messages? That’s the place the bot is available in.

Go to Webex for Builders / My Apps and ‘Create a New App’ (You’ll have to be logged in to do that). Select ‘Create a Bot’. Observe all of the steps and create the bot. You’ll then get a Bot Entry Token. Save this because the TEAMS_ACCESS_TOKEN variable within the ‘~/.bashrc’ file with the road export TEAMS_ACCESS_TOKEN=””. Use the command ‘supply ~/.bashrc’ to load the variable into the setting. You may test this labored with the command ‘echo $TEAMS_ACCESS_TOKEN’. In my essential module, chatops.py, you’ll see the road ‘access_token = os.environ.get(“TEAMS_ACCESS_TOKEN”). This units it up so the bot is the one doing the posting within the Webex house. Cool, proper?

Operating the App out of your Native Console (for debugging)

Now I can run the command ‘python chatops.py’ or ‘python3 chatops.py’ to run the app regionally (because the Python verrsion is 3.8.10). Each time I run this command, a brand new random phrase of the day will seem within the Webex house. I solely use this for testing functions.

(venv) alexstev@ALEXSTEV-M-FCUD wod % python chatops.py
your message was efficiently posted to Webex Groups

Operating the App on Schedule (Utilizing GitHub Workflows and Actions)

To be able to run the app on a schedule, we use GitHub workflows. To be able to try this, you’ll must create a GitHub repo named ‘.github’ and create a listing in it referred to as ‘.github/workflows’. In order that structrure will appear to be this: ‘.github/.github/workflows/’.

Subsequent, you need to create a workflow file within the workflows listing. It should include a reputation, a set off, a job, and fundamental steps (together with checkout and run). To be taught extra about what all this implies, try this tutorial: How To Construct Your First GitHub Actions Workflow. I even have a ‘workflow templates’ listing within the ‘.github’ repo that accommodates the workflow as a template, in addition to a properties.json file describing all the pieces.

That is what mine seems to be like –> https://github.com/xanderstevenson/.github/blob/default-branch/.github/workflows/wod-workflow.yml

It’s solely 29 traces of code! Automation all day!

WoD

One key element in my workflow is that this line ‘TEAMS_ACCESS_TOKEN: ${{ secrets and techniques.TEAMS_ACCESS_TOKEN }}’. I retailer that within the repo you’re studying now below Settings -> Secrets and techniques -> Actions.

Now we need to join the Workflow we created with the repo and the code we need to run. In my word-of-the-day-bot GitHub repo, I click on on the Actions tab and click on on ‘New workflow’ and discover my workflow listed amongst all of the beneficial and prebuilt workflows in a piece titled ‘By Alexander Stevenson’. Should you’ve already carried out this, you’ll be able to return a step to Actions and click on ‘Choose workflow’ to choose the workflow you need.

If all the pieces is setup accurately, the code will run utterly and the Webex house will obtain a brand new message. If not, you’ll get an e-mail to the deal with related along with your GitHub account. You can even click on on the ‘Actions’ tab in your code repo and also you’ll see an in depth description of why your code failed.

Phrase Selection and Sources

For this venture, phrases have been chosen that are related to fashionable and future applied sciences. I additionally intentionally selected phrases which have cross-functional use in community and software program growth. Moreover, I selected a mixture of phrases which will probably be of curiosity to a variety of IT professionals, i.e., engineers, managers, human assets personnel, testers, programmers, builders, cybersecurity, and many others..

I used a wide range of assets to search out probably the most cutting-edge phrases however with out getting too deep or technical. Neither did I select phrases which might be too frequent or easy. Final however not least, I attempted to compile a listing of phrases that can make anybody who makes use of them sound good. Properly, not likely. Truly, humor is a typical theme. Attempting too onerous to sound good often has the other impact.

Sources (not all-inclusive)

Rework Wikipedia Article to MP3 Recordsdata

By clicking on the ‘Be taught Extra’ button on every Phrase of the Day message, customers are taken to a webpage which is able to present a good deeper definition. The overwhelming majority of the time, this will probably be a Wikipedia article. Personally, I plan on studying your complete article in order that I can really grok every time period.

A colleague of ours at Cisco, John Capobianco, has developed a bundle referred to as wikitrola, which is able to remodel any Wikipedia web page into an MP3 file.

In case you have neither the time, persistence, nor need to learn the Wikipedia article, simply use wikitrola and you may hearken to it whereas multitasking or stress-free.

Codebase Updates

I had created an empty init.py file within the root listing out of behavior. Earlier than Python 3.3 this was carried out to to make Python deal with the directories as containing packages and facilitate importing between modules. From Python 3.3+ Implicit Namespace Packages are supported which permits the creation of a bundle with out an init.py file. This nonetheless solely applies to empty init.py information. So empty init.py information are not essential and might be omitted.

Anybody with a Cisco area account and Webex can be a part of the Phrase of the Day.


We’d love to listen to what you assume. Ask a query or go away a remark under.
And keep linked with Cisco DevNet on social!

LinkedIn | Twitter @CiscoDevNet | Fb | YouTube Channel

 

Share:



[ad_2]

RELATED ARTICLES

Most Popular

Recent Comments