Hello @Declan_ginty ... Can you please help here?
I made this script to create a queue and then update the canned response, hope it helps.
import os
import sys
import uuid
import PureCloudPlatformClientV2
from PureCloudPlatformClientV2.rest import ApiException
CLIENT_ID = os.environ['GENESYSCLOUD_OAUTHCLIENT_ID']
CLIENT_SECRET = os.environ['GENESYSCLOUD_OAUTHCLIENT_SECRET']
apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(CLIENT_ID, CLIENT_SECRET)
api_instance = PureCloudPlatformClientV2.RoutingApi(apiclient)
# Create Queue with no canned response
queueCreate = PureCloudPlatformClientV2.CreateQueueRequest()
queueCreate.name = "Test queue " + str(uuid.uuid4())
cannedResponse = canned_response_libraries = PureCloudPlatformClientV2.CannedResponseLibraries()
cannedResponse.library_ids = ["id1", "id2"]
cannedResponse.mode = "SelectedOnly"
queueCreate.canned_response_libraries = cannedResponse
global queue
try:
queue = api_instance.post_routing_queues(queueCreate)
print(queue)
except ApiException as e:
print("Exception when calling RoutingApi->post_routing_queue: %s\n" % e)
sys.exit()
# Update Queue with no canned response
queueUpdate = PureCloudPlatformClientV2.QueueRequest()
queueUpdate.name = "New queue name"
queueUpdate.canned_response_libraries = None
try:
queue = api_instance.put_routing_queue(queue.id, queueUpdate)
print(queue)
except ApiException as e:
print("Exception when calling RoutingApi->post_routing_queue: %s\n" % e)
sys.exit()
# Delete queue
try:
print("Deleting queue ", queue.id)
api_instance.delete_routing_queue(queue.id)
print("Deleted queue ", queue.id)
except ApiException as e:
print("Exception when calling RoutingApi->delete_routing_queue: %s\n" % e)
I will need more context and the error messages you are getting to be able to assist further.
Regards,
Declan
Hello @Declan_ginty --- I appreciate your response, and here is the Python code, I have added output for raw body and request body and I don't see canned Response to be part of it, for that matter, I don't see "CannedResponse" to be part of either "Raw Body", "Request Body" or finally in the Successful message. So the question would be is this API, even doing what its suppose to do, as the Request body doesn't have canned_response reference, However if you would closely see, it does have Queue Name reference:-
queueUpdate.name = "TACS_Email" ---- You see this in the request
queueUpdate.canned_response_libraries = None ---- But you don't see this going in the request.
apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token("HANDLE CLIENT CREDENTIALS AS SECRETS","HANDLE CLIENT CREDENTIALS AS SECRETS")
"""Create an instance of the API class"""
api_instance = PureCloudPlatformClientV2.RoutingApi(apiclient)
canned_response_libraries = PureCloudPlatformClientV2.CannedResponseLibraries
"""Define the queue ID"""
queue_id = 'bd77dcbc-01b5-4e0e-80c1-515a820ba4d1'
queueUpdate = PureCloudPlatformClientV2.QueueRequest()
print("Raw Body",queueUpdate)
queueUpdate.name = "TACS_Email"
queueUpdate.canned_response_libraries = None
print("Request body: %s", queueUpdate)
try:
#Update the queue
api_response = api_instance.put_routing_queue(queue_id,queueUpdate)
print("Queue updated successfully!")
print(api_response)
except ApiException as e:
print("Exception when calling RoutingApi->put_routing_queue: %s\n" % e)
Log output:-
Raw Body {'acw_settings': None,
'agent_owned_routing': None,
'auto_answer_only': None,
'bullseye': None,
'calling_party_name': None,
'calling_party_number': None,
'conditional_group_routing': None,
'created_by': None,
'date_created': None,
'date_modified': None,
'default_scripts': None,
'description': None,
'direct_routing': None,
'division': None,
'email_in_queue_flow': None,
'enable_audio_monitoring': None,
'enable_manual_assignment': None,
'enable_transcription': None,
'id': None,
'joined_member_count': None,
'media_settings': None,
'member_count': None,
'member_groups': None,
'message_in_queue_flow': None,
'modified_by': None,
'name': None,
'on_hold_prompt': None,
'outbound_email_address': None,
'outbound_messaging_addresses': None,
'peer_id': None,
'queue_flow': None,
'routing_rules': None,
'scoring_method': None,
'self_uri': None,
'skill_evaluation_method': None,
'suppress_in_queue_call_recording': None,
'user_member_count': None,
'whisper_prompt': None}
Request body: %s {'acw_settings': None,
'agent_owned_routing': None,
'auto_answer_only': None,
'bullseye': None,
'calling_party_name': None,
'calling_party_number': None,
'conditional_group_routing': None,
'created_by': None,
'date_created': None,
'date_modified': None,
'default_scripts': None,
'description': None,
'direct_routing': None,
'division': None,
'email_in_queue_flow': None,
'enable_audio_monitoring': None,
'enable_manual_assignment': None,
'enable_transcription': None,
'id': None,
'joined_member_count': None,
'media_settings': None,
'member_count': None,
'member_groups': None,
'message_in_queue_flow': None,
'modified_by': None,
'name': 'TACS_Email',
'on_hold_prompt': None,
'outbound_email_address': None,
'outbound_messaging_addresses': None,
'peer_id': None,
'queue_flow': None,
'routing_rules': None,
'scoring_method': None,
'self_uri': None,
'skill_evaluation_method': None,
'suppress_in_queue_call_recording': None,
'user_member_count': None,
'whisper_prompt': None}
Queue updated successfully!
{'acw_settings': {'timeout_ms': None, 'wrapup_prompt': 'OPTIONAL'},
'agent_owned_routing': None,
'auto_answer_only': False,
'bullseye': None,
'calling_party_name': None,
'calling_party_number': None,
'conditional_group_routing': None,
'created_by': 'a09e7345-64d2-455c-8113-b2828b28fffd',
'date_created': datetime.datetime(2023, 11, 13, 17, 43, 36, 214000, tzinfo=tzutc()),
'date_modified': datetime.datetime(2024, 10, 10, 15, 5, 18, 585000, tzinfo=tzutc()),
'default_scripts': {},
'description': None,
'direct_routing': None,
'division': {'id': 'fc3c4e64-cb11-4b5a-a22a-6ee776387903',
'name': 'Home',
'self_uri': '/api/v2/authorization/divisions/fc3c4e64-cb11-4b5a-a22a-6ee776387903'},
'email_in_queue_flow': None,
'enable_audio_monitoring': None,
'enable_manual_assignment': None,
'enable_transcription': None,
'id': 'bd77dcbc-01b5-4e0e-80c1-515a820ba4d1',
'joined_member_count': 2,
'media_settings': {'call': {'alerting_timeout_seconds': 8,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None},
'callback': {'alerting_timeout_seconds': 30,
'auto_answer_alert_tone_seconds': None,
'auto_dial_delay_seconds': 300,
'auto_end_delay_seconds': 300,
'enable_auto_answer': None,
'enable_auto_dial_and_end': False,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None},
'chat': {'alerting_timeout_seconds': 30,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None},
'email': {'alerting_timeout_seconds': 300,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 86400000,
'percentage': 0.8},
'sub_type_settings': None},
'message': {'alerting_timeout_seconds': 30,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None}},
'member_count': 3,
'member_groups': None,
'message_in_queue_flow': None,
'modified_by': 'a067522f-642f-4d4b-90e2-ddb422c37011',
'name': 'TACS_Email',
'on_hold_prompt': None,
'outbound_email_address': None,
'outbound_messaging_addresses': None,
'peer_id': None,
'queue_flow': None,
'routing_rules': None,
'scoring_method': 'TimestampAndPriority',
'self_uri': '/api/v2/routing/queues/bd77dcbc-01b5-4e0e-80c1-515a820ba4d1',
'skill_evaluation_method': 'ALL',
'suppress_in_queue_call_recording': False,
'user_member_count': 3,
'whisper_prompt': None}
@Shakti_Joshi Please be sure to handle OAuth client credentials with the same level of security that you would use for any password. I have removed the values from your post above, but you will still need to regenerate the client secret immediately and follow your company's policies for a potential security breach.
This really looks like you are using an outdated version of the python sdk as it's the only explanation I can think of as to why canned_response_libraries is not showing up since it's definitely part of the api request body. I know you verified you installed the latest version but it's possible your code is pulling from outdated local copy of the sdk somewhere else.
I had a similar problem that was due to my IDE (Pycharm) having an outdated version of the sdk installed thus the version my project was using was outdated.
Regards,
Declan
Thanks Tim, I have regenerated the client secret. I usually take extra care of removing the client secret , but I missed this time.
That may be possible, I am also using pycharm IDE, how did you fix it finally? Just curious to know.
I had to go into the project settings and look at the python interpreter I was using. It should list the packages and their versions being used.
Thanks @Declan_ginty - It was indeed pointing to 196.0.0
and I have updated it to 212.0.0
Now we do see an improvement and could see the "canned response" in the request body, and also in the response body set as none, but when I check the queue in Genesys Cloud UI, it still show assigned as "All Libraries"
api_instance = PureCloudPlatformClientV2.RoutingApi(apiclient)
#canned_response_libraries = PureCloudPlatformClientV2.CannedResponseLibraries
"""Define the queue ID"""
queue_id = 0ba4d1'
queueUpdate = PureCloudPlatformClientV2.QueueRequest()
print("Raw Body",queueUpdate)
queueUpdate.name = "Test_Email"
queueUpdate.canned_response_libraries = None
print("Request body: %s", queueUpdate)
try:
#Update the queue
api_response = api_instance.put_routing_queue(queue_id,queueUpdate)
print("Queue updated successfully!")
print(api_response)
except ApiException as e:
print("Exception when calling RoutingApi->put_routing_queue: %s\n" % e)
Here are the logs:-
Raw Body {'acw_settings': None,
'agent_owned_routing': None,
'auto_answer_only': None,
'bullseye': None,
'calling_party_name': None,
'calling_party_number': None,
'canned_response_libraries': None,
'conditional_group_routing': None,
'created_by': None,
'date_created': None,
'date_modified': None,
'default_scripts': None,
'description': None,
'direct_routing': None,
'division': None,
'email_in_queue_flow': None,
'enable_audio_monitoring': None,
'enable_manual_assignment': None,
'enable_transcription': None,
'id': None,
'joined_member_count': None,
'media_settings': None,
'member_count': None,
'member_groups': None,
'message_in_queue_flow': None,
'modified_by': None,
'name': None,
'on_hold_prompt': None,
'outbound_email_address': None,
'outbound_messaging_addresses': None,
'peer_id': None,
'queue_flow': None,
'routing_rules': None,
'scoring_method': None,
'self_uri': None,
'skill_evaluation_method': None,
'suppress_in_queue_call_recording': None,
'user_member_count': None,
'whisper_prompt': None}
Request body: %s {'acw_settings': None,
'agent_owned_routing': None,
'auto_answer_only': None,
'bullseye': None,
'calling_party_name': None,
'calling_party_number': None,
'canned_response_libraries': None,
'conditional_group_routing': None,
'created_by': None,
'date_created': None,
'date_modified': None,
'default_scripts': None,
'description': None,
'direct_routing': None,
'division': None,
'email_in_queue_flow': None,
'enable_audio_monitoring': None,
'enable_manual_assignment': None,
'enable_transcription': None,
'id': None,
'joined_member_count': None,
'media_settings': None,
'member_count': None,
'member_groups': None,
'message_in_queue_flow': None,
'modified_by': None,
'name': 'Test_Email',
'on_hold_prompt': None,
'outbound_email_address': None,
'outbound_messaging_addresses': None,
'peer_id': None,
'queue_flow': None,
'routing_rules': None,
'scoring_method': None,
'self_uri': None,
'skill_evaluation_method': None,
'suppress_in_queue_call_recording': None,
'user_member_count': None,
'whisper_prompt': None}
Queue updated successfully!
{'acw_settings': {'timeout_ms': None, 'wrapup_prompt': 'OPTIONAL'},
'agent_owned_routing': None,
'auto_answer_only': False,
'bullseye': None,
'calling_party_name': None,
'calling_party_number': None,
'canned_response_libraries': None,
'conditional_group_routing': None,
'created_by': 'a09e7345-64d2-455c-8113-b2828b28fffd',
'date_created': datetime.datetime(2023, 11, 13, 17, 43, 36, 214000, tzinfo=tzutc()),
'date_modified': datetime.datetime(2024, 10, 10, 16, 38, 48, 758000, tzinfo=tzutc()),
'default_scripts': {},
'description': None,
'direct_routing': None,
'division': {'id': '387903',
'name': 'Home',
'self_uri': '/api/v2/authorization/divisions/387903'},
'email_in_queue_flow': None,
'enable_audio_monitoring': None,
'enable_manual_assignment': None,
'enable_transcription': None,
'id': 0ba4d1',
'joined_member_count': 2,
'media_settings': {'call': {'alerting_timeout_seconds': 8,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None},
'callback': {'alerting_timeout_seconds': 30,
'auto_answer_alert_tone_seconds': None,
'auto_dial_delay_seconds': 300,
'auto_end_delay_seconds': 300,
'enable_auto_answer': None,
'enable_auto_dial_and_end': False,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None},
'chat': {'alerting_timeout_seconds': 30,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None},
'email': {'alerting_timeout_seconds': 300,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 86400000,
'percentage': 0.8},
'sub_type_settings': None},
'message': {'alerting_timeout_seconds': 30,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None}},
'member_count': 3,
'member_groups': None,
'message_in_queue_flow': None,
'modified_by': '22c37011',
'name': 'Test_Email',
'on_hold_prompt': None,
'outbound_email_address': None,
'outbound_messaging_addresses': None,
'peer_id': None,
'queue_flow': None,
'routing_rules': None,
'scoring_method': 'TimestampAndPriority',
'self_uri': '/api/v2/routing/queues/0ba4d1',
'skill_evaluation_method': 'ALL',
'suppress_in_queue_call_recording': False,
'user_member_count': 3,
'whisper_prompt': None}
Process finished with exit code 0
Thanks @vpirat , It might be but I am not sure as @Declan_ginty said in his earlier post that he was able to use python sdk to achieve the task.
Unless you guys think it's a similar issue , even at your end.
@Declan_ginty , Can you kindly confirm, if you are able to update the canned response using python sdk, if not then what are the next steps?, if yes, then should I create a support case, or what else can be done to find out why its not updating ?
Warm Regards
Shakti Joshi
Hi @Shakti_Joshi,
I believe the image shown above of the canned response field after update is correct. I checked some other queues that do not have the canned response field set and see the same thing so I believe the queue is being updated correctly and removing the canned response field. If you want to be sure that the queue is updated correctly I would suggest making an api request after the update and checking if canned_response_libraries
is set.
Regards,
Declan
Hello @Declan_ginty .... I ran the update query and then ran a get queue, and in the get queue details , I could see that the queue was last updated today, and it does show that "canned response" is set to "none", but in UI it still shows its set to "All":-
Below is the get response query:-
'acw_settings': {'timeout_ms': None, 'wrapup_prompt': 'OPTIONAL'},
'agent_owned_routing': None,
'auto_answer_only': False,
'bullseye': None,
'calling_party_name': None,
'calling_party_number': None,
'canned_response_libraries': None,
'conditional_group_routing': None,
'created_by': '455c',
'date_created': datetime.datetime(2023, 11, 13, 17, 43, 36, 214000, tzinfo=tzutc()),
'date_modified': datetime.datetime(2024, 10, 14, 11, 34, 32, 583000, tzinfo=tzutc()),
'default_scripts': {},
'description': None,
'direct_routing': None,
'division': {'id': '4b5a',
'name': 'Home',
'self_uri': '/api/v2/authorization/divisions/4b5a'},
'email_in_queue_flow': None,
'enable_audio_monitoring': None,
'enable_manual_assignment': None,
'enable_transcription': None,
'id': '80c1',
'joined_member_count': 3,
'media_settings': {'call': {'alerting_timeout_seconds': 8,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None},
'callback': {'alerting_timeout_seconds': 30,
'auto_answer_alert_tone_seconds': None,
'auto_dial_delay_seconds': 300,
'auto_end_delay_seconds': 300,
'enable_auto_answer': None,
'enable_auto_dial_and_end': False,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None},
'chat': {'alerting_timeout_seconds': 30,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None},
'email': {'alerting_timeout_seconds': 300,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 86400000,
'percentage': 0.8},
'sub_type_settings': None},
'message': {'alerting_timeout_seconds': 30,
'auto_answer_alert_tone_seconds': None,
'enable_auto_answer': None,
'manual_answer_alert_tone_seconds': None,
'service_level': {'duration_ms': 20000,
'percentage': 0.8},
'sub_type_settings': None}},
'member_count': 3,
'member_groups': None,
'message_in_queue_flow': None,
'modified_by': '4d4b',
'name': 'TEST_Email',
'on_hold_prompt': None,
'outbound_email_address': None,
'outbound_messaging_addresses': None,
'peer_id': None,
'queue_flow': None,
'routing_rules': None,
'scoring_method': 'TimestampAndPriority',
'self_uri': '/api/v2/routing/queues/80c1',
'skill_evaluation_method': 'ALL',
'suppress_in_queue_call_recording': False,
'user_member_count': 3,
'whisper_prompt': None}
Below is the screenshot showing its still showing "All Libraries"
@Shakti_Joshi I believe this is what the UI will say when there is no canned response set on the queue. If you believe this is wrong please open a ticket with care.
@Declan_ginty ... Care is asking to post it in Developer forum, at this moment its becoming frustrating and annoying, can I get some help here please.
@Shakti_Joshi I looked at the case and you only stated that your app doesn't work and didn't ask any questions. There wasn't any information on steps you've already taken to troubleshoot and about 90% of your message in the original case was a trace dump from your app. Based on the information provided to Care, their response is appropriate since it appears you're just implying you need help making the request. This forum would be an appropriate place for that request.
I would recommend explaining to them specifically where the issue is and asking them for assistance looking into why the value is not updating. Demonstrating that this is not a SDK issue by reproducing the same result using API Explorer is also helpful to show it's an API issue. You'll need to provide the correlation ID from the response for Care to be able to look at any logging or engage any dev teams.
Thanks @tim.smith and @Declan_ginty @vpirat _ I was able to make the code work, here is the final piece of the code for your reference:-
@tim.smith - actually when you asked me to look at API, without even firing the response and just while creating the request, I saw this , which caught my attention, which showed me that my request was not correct, and then I went to one of my old post in this forum (How to add Wrapup code using Python SDK)
PUT /api/v2/routing/queues/bd77dcbc-01b5-4e0e-80c1-515a820ba4d1 HTTP/1.1
Host: api.mypurecloud.com
Authorization: Bearer *******************
Content-Type: application/json
{"defaultScripts":{"":{}},"name":"TACS_Email","cannedResponseLibraries":{"mode":"None"}}
I was able to make it work finally. Here is the final piece of the code, now I just have to exapnd this logic to update multiple queues
"""Create an instance of the API class"""
api_instance = PureCloudPlatformClientV2.RoutingApi(apiclient)
#canned_response_libraries = PureCloudPlatformClientV2.CannedResponseLibraries
"""Define the queue ID"""
queue_id = 'bd77dcbc'
queueUpdate = PureCloudPlatformClientV2.QueueRequest()
print("Raw Body",queueUpdate)
queueUpdate.name = "Test_Email"
queueUpdate.canned_response_libraries={
* "mode": "None"*
- }*
print("Request body: %s", queueUpdate)
try:
#Update the queue
api_response = api_instance.put_routing_queue(queue_id,queueUpdate)
print("Queue updated successfully!")
print(api_response)
except ApiException as e:
print("Exception when calling RoutingApi->put_routing_queue: %s\n" % e)
Thanks again for your patience and help.
Warm Regards
Shakti Joshi
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.