Not updating the Queue values

Hello Team - I have large number of queues and within each queue, I need to update certain parameters, I have below code, which runs successfully (In the sense it displays the message that queue has been updated,, and doesn't throw any error), but when I check on the queue , the values are still not updated, Could you help me in understanding from the below code, what might be the issue?

import PureCloudPlatformClientV2
from PureCloudPlatformClientV2.rest import ApiException
from PureCloudPlatformClientV2.apis import routing_api, conversations_api
from PureCloudPlatformClientV2.models import Queue, MediaTranscription
from PureCloudPlatformClientV2.configuration import Configuration
from pprint import pprint

apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(
"abcd", "efgh")
authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)

Create an instance of the API class

api_instance = PureCloudPlatformClientV2.RoutingApi(apiclient)

Define the queue ID

queue_id = '1e4a5'

Create a QueueRequest object with the desired properties

body = {
"name" : "Shakti-Test",
"default_scripts" : {"CALL": {"name": "_Inbound_Email"}},
"queue_flow" : {"id": "11ef", "name": "Action", "self_uri": "/api/v2/flows/11ef"},
"enable_transcription" : "True",
"whisper_prompt" : {"id": "ad5fc", "name": "Bruce_Whisper_1", "self_uri": "/api/v2/architect/prompts/ad5fc"}
}

try:
# Update the queue
api_response = api_instance.put_routing_queue(queue_id, body)
print("Queue updated successfully!")
print(api_response)
except ApiException as e:
print("Exception when calling RoutingApi->put_routing_queue: %s\n" % e)

Kindly help.

Warm Regards
Shakti Joshi

Hi @Shakti_Joshi,

The request body for PUT /api/v2/routing/queues/{queueId} is a QueueRequest object. You will need to create a QueueRequest object, add the properties to it and send it to the put_routing_queue method. Something like this:

body = PureCloudPlatformClientV2.QueueRequest()

# Set values on body

try:
    # Update a queue
    api_response = api_instance.put_routing_queue(queue_id, body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling RoutingApi->put_routing_queue: %s\n" % e)

Regards,
Declan

Thanks Declan, this piece of code I have already seen in the python SDK example shown in the Developer portal, and it didn't help, Could you provide an example which you might have run in your lab?

Warm Regards
Shakti Joshi

Based on the example provided above, you should be able to set the values on the QueueRequest object like so:

body = PureCloudPlatformClientV2.QueueRequest()

body.name = "Shakti-Test"
body.enable_transcription = False

# Create reference to flow
queue_flow = PureCloudPlatformClientV2.DomainEntityRef()
queue_flow.id = "1234"
body.queue_flow = queue_flow

# Create reference to prompt
whisper_prompt = PureCloudPlatformClientV2.DomainEntityRef()
whisper_prompt.id = "1234"
body.whisper_prompt = whisper_prompt

# Create scripts
script1 = PureCloudPlatformClientV2.Script()
# set script properties
body.default_scripts = {
    "1234": script1
}

try:
    # Update a queue
    api_response = api_instance.put_routing_queue("1234", body)
    print(api_response)
except ApiException as e:
    print("Exception when calling RoutingApi->put_routing_queue: %s\n" % e)

You will still need to create the scripts needed but that will follow the same pattern as this example

Regards,
Declan

1 Like

Thanks this worked, final code looks something like this:-

apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(
"642f", "rmOONxwk9")
authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)

Create an instance of the API class

api_instance = PureCloudPlatformClientV2.RoutingApi(apiclient)

Define the queue ID

queue_id = '6300'

body = PureCloudPlatformClientV2.QueueRequest()

body.name = "Test"
body.enable_transcription = True

Create reference to flow

queue_flow = PureCloudPlatformClientV2.DomainEntityRef()
queue_flow.id = "4f5"
body.queue_flow = queue_flow

Create reference to prompt

whisper_prompt = PureCloudPlatformClientV2.DomainEntityRef()
whisper_prompt.id = "6ce3"
body.whisper_prompt = whisper_prompt

Create scripts

script1 = Script()

Set script properties (name, etc.) based on the library

script1.id="45ac"

Update queue with default script

body.default_scripts = {
"CALL": script1 # Assuming "CALL" is the communication type for the script
}

logging.debug("Request body: %s", body.to_dict()) # Log the request body

try:
# Update the queue
api_response = api_instance.put_routing_queue(queue_id, body)
print("Queue updated successfully!")
print(api_response)
except ApiException as e:
print("Exception when calling RoutingApi->put_routing_queue: %s\n" % e)

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.