Shakti_Joshi | 2024-04-29 00:33:59 UTC | #1
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 routingapi, conversationsapi from PureCloudPlatformClientV2.models import Queue, MediaTranscription from PureCloudPlatformClientV2.configuration import Configuration from pprint import pprint
apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken( "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", "defaultscripts" : {"CALL": {"name": "InboundEmail"}}, "queueflow" : {"id": "11ef", "name": "Action", "selfuri": "/api/v2/flows/11ef"}, "enabletranscription" : "True", "whisperprompt" : {"id": "ad5fc", "name": "BruceWhisper1", "selfuri": "/api/v2/architect/prompts/ad5fc"} }
try:
Update the queue
apiresponse = apiinstance.putroutingqueue(queueid, body) print("Queue updated successfully!") print(apiresponse) except ApiException as e: print("Exception when calling RoutingApi->putroutingqueue: %s\n" % e)
Kindly help.
Warm Regards Shakti Joshi
Declan_ginty | 2024-04-29 10:25:42 UTC | #2
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
Shakti_Joshi | 2024-04-29 11:59:00 UTC | #3
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
Declan_ginty | 2024-04-29 14:22:11 UTC | #4
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
Shakti_Joshi | 2024-04-29 18:40:02 UTC | #5
Thanks this worked, final code looks something like this:-
apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken( "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
queueflow = PureCloudPlatformClientV2.DomainEntityRef() queueflow.id = "4f5" body.queueflow = queueflow
Create reference to prompt
whisperprompt = PureCloudPlatformClientV2.DomainEntityRef() whisperprompt.id = "6ce3" body.whisperprompt = whisperprompt
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
apiresponse = apiinstance.putroutingqueue(queueid, body) print("Queue updated successfully!") print(apiresponse) except ApiException as e: print("Exception when calling RoutingApi->putroutingqueue: %s\n" % e)
system | 2024-05-30 18:40:11 UTC | #6
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 25957