300-835 · Question #56
Drag and drop the code snippets from the bottom onto the boxes where the code is missing to listen for Call History events using the xAPI Python SDK. Not all options are used.
The options appear to be empty in your message - {} was passed with no content. Without the actual code snippet options, I can't tell you exactly which snippets go where. Please paste the actual code options (the draggable snippets) and ideally the code template with the blank bo
Question
Exhibit
Explanation
The options appear to be empty in your message - {} was passed with no content. Without the actual code snippet options, I can't tell you exactly which snippets go where.
Please paste the actual code options (the draggable snippets) and ideally the code template with the blank boxes, and I'll give you a full, step-by-step explanation.
In the meantime, here is the general framework so you can recognize each piece when you share the options:
Listening for Call History Events - xAPI Python SDK
Overall Goal
The xAPI SDK lets you programmatically interact with Cisco collaboration devices (Webex Room devices, etc.). "Listening for events" means subscribing to the device's event stream so your code runs a callback whenever a matching event fires - in this case, CallHistory events (calls made, received, or missed).
Typical Structure
import xapi
import asyncio
# 1. Connect to the device
async def main():
async with xapi.connect(
host, username=username, password=password
) as x:
# 2. Register an event handler / callback
x.on('Event CallHistoryRecentsResult', on_call_history)
# 3. Keep the event loop alive to receive events
await asyncio.sleep(float('inf'))
# 4. Define the callback
def on_call_history(event):
print(event)
# 5. Run the async entry point
asyncio.run(main())
Why Each Step Matters
| Step | Why necessary |
|---|---|
Connect (xapi.connect) | Opens the WebSocket session to the device - no connection = no events |
Register handler (.on(...)) | Tells the SDK which event to watch and what function to call - skip this and events fire silently |
Keep loop alive (asyncio.sleep) | Without this, the async with block exits immediately and the connection closes |
| Callback function | Processes the event data - this is where your business logic lives |
asyncio.run | Bootstraps the async event loop - required because xAPI SDK is async-first |
Memory Tip
Think C-R-L-H: Connect → Register handler → Loop/listen → Handle event.
Share the actual snippets and template and I'll map each one precisely.
Community Discussion
No community discussion yet for this question.
