As companies work to ensure the safety of their workforce returning to the physical office, leveraging current network infrastructure and APIs to aid with contact tracing will be paramount.
We will leverage the new Cisco DNA Center Proximity API and Notification APIs with ChatOps to allow teams within a company to trace a pandemic positive employee, generate contact tracing report and respond quickly to keep their employees safe.
<iframe width="560" height="315" src="https://www.youtube.com/embed/KY6beOWgIV4" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>Below is the overall architecture we will be putting together.
Before we start constructing our application we need to make sure we have all the dependencies configured and setup.
Let's start by setting up our API gateway in AWS. We will leverage it as a receiver for all the Webhooks leveraged in this app.
⚠️ This portion of the application can also be implemented using Flask
Setup three different API Endpoint:
Webex
messages webhookWebex
Adaptive Cards attachment webhookDNA Center
Proximity Event webhookSetup API Gateway
Deploy API to Stage:
Upon successfully creating your instance of Proximity API Gateway from template you will see three endpoints created:
{{AWS-URI}}/bot
- This endpoint will be used as the targetURL
for messages
webhook in Webex{{AWS-URI}}/form
- This endpoint will be used as the targetURL
for attachment
webhook in Webex{{AWS-URI}}/dnac
- This endpoint will be leveraged to receive Cisco DNA Center proximity events⚠️ We will use the above endpoints in our subsequent steps.
Now that we've setup all the endpoints. Each endpoint will receive a webhook event and pass the data to a Lambda function to process it.
let's build out our lambda functions and attach each to our API Gateway
ℹ️ How to deploy a Lambda function
Messages
event Webhook handler:Have a peek at the lambda/bot-msgs
code folder, this is your first lambda function. Create it.
This Lambda function:
{{AWS-URI}}/bot
endpoint via Webex Messages
Webhook.bot_msg_handler()
python function.card.json
to capture user inputOnce deployed, link /bot
POST
Method to Lambda function bot-msgs
in API Gateway
AttachmentActions
event Webhook handler:The second webhook we need to handle is when user "Submits" the Form posted by our bot.
This data needs to be passed to another Lambda function and parsed. have a peek at /lambda/form-submit
code folder. Create it similarly to the step above.
This Lambda function:
{{AWS-URI}}/form
endpoint via Webex AttachmentActions
Webhook.post_response(form_data)
python function/client-proximity
in client_proximity(client_username, days, resolution)
Once deployed, link /form
POST
Method to Lambda function form-submit
in API Gateway
NETWORK-CLIENTS-3-506
event Webhook handler:The final webhook we need to handle is the data coming back from Cisco DNA Center based on the parameter we passed.
This data will be passed to the same Lambda function as our form submission function. simply point API gateway resource
/dnac
to the Lambda function form-submit
⚠️ If you chose to render the Client Proximity Data from DNAC in a nicely formatted PDF file. use the provided code in /Lambda/proximity-report
Now that your infrastructure is in place. You will need to make sure you API Gateway is deployed to stage (see Step 1) and capture the URL to each endpoint.
Create two different webhooks under your bot's Bearer Token
POST
request to /v1/webhooks
⚠️ When creating your Webex Event Webhook make sure you are not using your personal API Token rather your bot's
targetUrl
here should be pointing to API Gateway endpoint created on Step 1
:{ "name": "My Messaging Webhook", "targetUrl": "https://{{API GATEWAY URL}}/bot", "resource": "messages", "event": "created" }
{ "name": "My Messaging Webhook", "targetUrl": "https://{{API GATEWAY URL}}/form", "resource": "attachmentActions", "event": "created" }
Event Destination
- This tells DNAC where to ship off the network events to, in this case to our final API gateway endpoint /dnac
NETWORK-CLIENTS-3-506
which is the Client Proximity Webhook and assign the newly created destinationYou have successfully built an entire application around Cisco DNA Center's Client Proximity API. The one thing to note here is that this API endpoint is not only pandemic related but you can easily use it to cater for your VIP clients on your network and assure an always on connection for their devices. The combination of ChatOps and Network Programmability can be super useful and powerful!
Owner
Contributors
Categories
Products
Catalyst CenterProgramming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community