300-835 · Question #61
Drag and drop the code snippets from the bottom onto the boxes in the Python script to create an internal event listener for two nodes on the device and send events back to a webhooks server using the
Issue: No Options Provided The Options field in your question is empty ({}), so the actual code snippets that would be dragged into the blanks are missing. Without them, I can't tell you which specific snippet goes where. That said, here is a thorough explanation of the concept a
Question
Explanation
Issue: No Options Provided
The Options field in your question is empty ({}), so the actual code snippets that would be dragged into the blanks are missing. Without them, I can't tell you which specific snippet goes where.
That said, here is a thorough explanation of the concept and reasoning behind this type of question, which will help you answer it correctly once you have the options.
Overall Goal
The task is to write a Python script that:
- Listens for events on two specific xAPI nodes (feedback paths) on a Cisco collaboration device (e.g., Webex Room Kit)
- Forwards those events to an external webhook server via HTTP POST
This is a common pattern in Cisco DevNet automation - the device emits events (button presses, call state changes, etc.) and your script acts as a bridge to an external system.
Why This Approach is Correct
Cisco Room OS devices expose an xAPI that supports both commands and feedback subscriptions. Rather than polling the device repeatedly, you register a listener (subscribe to feedback). When the node changes, the device pushes the event to your script. Your script then forwards it to a webhook. This is event-driven and efficient.
Typical Script Structure and Reasoning
Step 1 - Import libraries
import requests, json
requestssends the HTTP POST to the webhook serverjsonserializes the event payload
Why first: Python needs the libraries available before any code using them runs. Skipping this causes NameError.
Step 2 - Define device credentials and webhook URL
DEVICE_IP = "10.10.20.20"
USERNAME = "admin"
PASSWORD = "password"
WEBHOOK_URL = "https://webhook.site/your-id"
Why: These are the connection parameters. Hard-coded here for simplicity in an exam context. Skipping this means the connection and POST destination are undefined.
Step 3 - Set up xAPI feedback subscription for two nodes
Using xAPI XMLcommand (via HTTP POST to the device):
payload = """
<Command><HttpFeedback><Register command="True">
<FeedbackSlot>1</FeedbackSlot>
<ServerUrl>http://your-listener-address</ServerUrl>
<Expression item="1">/Event/UserInterface/Extensions/Widget/Action</Expression>
<Expression item="2">/Status/Call</Expression>
</Register></HttpFeedback></Command>
"""
Why two nodes: The question specifies exactly two. Each <Expression> registers one xAPI feedback path. The device will HTTP POST to your listener whenever these paths change.
What goes wrong if skipped: Without registering, the device never sends events - your script receives nothing.
Step 4 - Define the event handler / callback
def handle_event(event_data):
response = requests.post(WEBHOOK_URL, json=event_data)
Why: This is the function that runs when an event arrives. It forwards the payload to the external webhook server.
What goes wrong if out of order: If you try to register the listener before defining the callback, you get a NameError at runtime.
Step 5 - Start listening / run the server loop
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080)
(Often a Flask or HTTP server that receives the device's POSTs)
Why: The device sends events to your script via HTTP. Your script must be running a server to receive them. Without this, the events are sent by the device but nothing catches them.
What Goes Wrong if Steps Are Out of Order
| Skip/Reorder | Consequence |
|---|---|
| Register before defining handler | NameError on undefined callback |
| Skip registration | Device never sends events |
| Skip webhook POST | Events received but not forwarded |
| Wrong xAPI node path | Subscription silently receives nothing |
Memory Tip
"Connect → Subscribe → Handle → Forward"
- Connect to the device (credentials/IP)
- Subscribe to two xAPI nodes via XMLcommand
- Handle incoming events with a callback
- Forward events to the webhook via HTTP POST
Please paste the actual code snippet options and I can map exactly which goes in each blank.
Topics
Community Discussion
No community discussion yet for this question.