Inscrivez-vous maintenant pour un meilleur devis personnalisé!

Keep it Secret, Keep it Safe, with Webex Teams APIs

Sep, 25, 2018 Hi-network.com

 

Use this Script to Help Keep Your Bot (and Sensitive Information) Away from Prying Eyes

There are times -like when you are first developing it, or when it is handling sensitive information -when you want your bot to beonlyavailable ANDonlyrespond to folks within your company. Unfortunately, Webex Teams does not yet have the ability to restrict anyone from adding your bot to a space so we need to make sure you don't respond to everyone.

You can take steps to make sure your bot does not respond to messages within a space where there are folks from other organizations. At runtime I typically use the spark helper membership check function before responding to a message from a room. The code can be found in the CiscoSE GitHub repository. It's kind of like telling your kids to NOT open the door every time someone rings the door bell!

Unfortunately, this is reactive, so why don't we be a bit more proactive and leverage the same great Webex Team's API's with solution that can be automated?

Solution

The basic idea behind the algorithm is as follows:

  1. Use the bot's access token to get a list of rooms it is in.
  2. For each of those rooms, get a list of people and bots in the room. We check to make sure that everyone in the room is in your organization. If not, remove the bot from the room.

Pretty simple, so let's take a look at the code.

First, let's define a function calledcheck_and_delete_membershipand let's pass it the bot's access token and the Webex Team's organization ID. With this helpful information, let's exercise the Webex Team's Membership API a bit to get the party started.

[cc lang="python" width="700

tag-icon Tags chauds: Python Spark CiscoSE Cisco Webex Teams

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.