Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Python

    Posted 18 hours ago
    I need a Python code using the API for a queue occupancy alarm. Can someone help me?

    #PlatformAPI

    ------------------------------
    Daniel Bernardi
    Network Designer Specialist-Cloud Applications
    ------------------------------


  • 2.  RE: Python

    Posted 15 hours ago

    I had this lying around from awhile ago. It is incomplete, but may be of some use?

    import requests
    
    region = "mypurecloud.com"
    queue_id = "QUEUE_ID"
    user_id="USER_ID"
    
    # TODO Use Platform API SDK
    url = f"https://api.{region}/api/v2/alerting/rules"
    headers = {}
    
    payload = {
        "name": "Queue Occupancy Alert",
        "type": "ConversationMetrics",
        "enabled": True,
        "notifications": [
            {
                "notificationTypes": ["Sms"],
                "users": [{"id": user_id}]
            }
        ],
        "conditions": {
            "type": "And",
            "predicates": [
                {
                    "metricType": "Instance",
                    "metricValueType": "Observation",
                    "metric": "oWaiting",
                    "comparisonOperator": "Gt",
                    "value": 10,
                    "entity": {
                        "entityType": "Queue",
                        "queue": {"id": queue_id}
                    }
                }
            ]
        }
    }
    
    response = requests.post(url, headers=headers, json=payload)
    print(response.json())


    ------------------------------
    Lucas Woodward
    Winner of Orchestrator of the Year, Developer (2025)

    LinkedIn - https://www.linkedin.com/in/lucas-woodward-the-dev
    Newsletter - https://makingchatbots.com
    ------------------------------