Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| vendors:cisco:uc:ucce:finesse:bulk-create-reason-labels [2024/09/30 17:18] – removed - external edit (Unknown date) 127.0.0.1 | vendors:cisco:uc:ucce:finesse:bulk-create-reason-labels [2024/09/30 17:18] (current) – ↷ Page moved from vendors:cisco:uc:finesse:bulk-create-reason-labels to vendors:cisco:uc:ucce:finesse:bulk-create-reason-labels gerardorourke | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Bulk Create Reason Labels on CCE 12.X ===== | ||
| + | -Export Reason Labels from Finesse using the Finesse API - and save XML output as a XML file | ||
| + | -Run Python script below and specify your Finesse XML files as your input file. | ||
| + | |||
| + | <wrap hi>Note - I need to update so any System codes are skipped - but they should fail to be imported in any event!</ | ||
| + | |||
| + | |||
| + | The script will automatically recognize if the Finesse Reason Label XML file is a Not Ready, Logout or Wrap up file.\\ | ||
| + | It will then ask you to proceed and will create the reason labels in CCE. | ||
| + | |||
| + | ===== Finesse API to Export Reason Labels ===== | ||
| + | ====All Reason Codes==== | ||
| + | https:// | ||
| + | https:// | ||
| + | ====All Wrap Ups==== | ||
| + | https:// | ||
| + | |||
| + | |||
| + | ==== Agent Retrieval of Reason Codes ==== | ||
| + | Note - an Agent can also request reason codes - but by asking for ReasonCodes Within Its Team - such as below: | ||
| + | This will be a subset of all reason codes. | ||
| + | < | ||
| + | https:// | ||
| + | </ | ||
| + | ===== CCE-BulkCreateReasonLabels.py Python Script ===== | ||
| + | <file python CCE-BulkCreateReasonLabels.py> | ||
| + | # Copyright 2019 - Gerard O' | ||
| + | |||
| + | # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
| + | # documentation files (the " | ||
| + | # the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
| + | # permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
| + | # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
| + | # Software. | ||
| + | |||
| + | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
| + | # WARRANTIES OF MERCHANTABILITY, | ||
| + | # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| + | # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| + | |||
| + | |||
| + | # Import XML Parser Module | ||
| + | import xml.etree.cElementTree as ET | ||
| + | # import HTTP Module | ||
| + | import requests | ||
| + | |||
| + | # Disable SSL warning | ||
| + | from requests.packages.urllib3.exceptions import InsecureRequestWarning | ||
| + | requests.packages.urllib3.disable_warnings(InsecureRequestWarning) | ||
| + | |||
| + | # Default Variables to use to import XML file and to connect to CCE API | ||
| + | CCEHost = " | ||
| + | user = " | ||
| + | password = " | ||
| + | xmlfile = " | ||
| + | |||
| + | |||
| + | def press_y_to_continue(): | ||
| + | userinput = input(" | ||
| + | if (userinput != " | ||
| + | print(" | ||
| + | exit() | ||
| + | |||
| + | |||
| + | def WrapReasonLoop(): | ||
| + | category = " | ||
| + | code = "" | ||
| + | |||
| + | for elem in tree.findall(" | ||
| + | if (elem.tag == " | ||
| + | label = elem.text | ||
| + | if (elem.tag == " | ||
| + | forAll = elem.text | ||
| + | CreateReasonLabel(category, | ||
| + | |||
| + | |||
| + | def ReasonCodeLoop(): | ||
| + | for elem in tree.findall(" | ||
| + | if (elem.tag == " | ||
| + | category = elem.text | ||
| + | # print(" | ||
| + | if (elem.tag == " | ||
| + | code = elem.text | ||
| + | # print(" | ||
| + | if (elem.tag == " | ||
| + | label = elem.text | ||
| + | # print(" | ||
| + | if (elem.tag == " | ||
| + | forAll = elem.text | ||
| + | # print(" | ||
| + | CreateReasonLabel(category, | ||
| + | |||
| + | |||
| + | def CreateReasonLabel(category, | ||
| + | headers = {' | ||
| + | wrapReasonXML = "< | ||
| + | print(" | ||
| + | try: | ||
| + | response = requests.post(urlReasonLabel, | ||
| + | except Exception as e: | ||
| + | print(type(e)) | ||
| + | print(e) | ||
| + | exit() | ||
| + | |||
| + | if (response.status_code != 201): | ||
| + | print( | ||
| + | " | ||
| + | response.status_code)) | ||
| + | print(" | ||
| + | print(response.text) | ||
| + | if (response.status_code == 400): | ||
| + | press_y_to_continue() | ||
| + | if (response.status_code != 400): | ||
| + | exit() | ||
| + | if (response.status_code == 201): | ||
| + | print(" | ||
| + | |||
| + | |||
| + | # Main Application | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | |||
| + | userinput = input(" | ||
| + | if (userinput != "" | ||
| + | CCEHost = userinput | ||
| + | |||
| + | userinput = input(" | ||
| + | if (userinput != "" | ||
| + | user = userinput | ||
| + | |||
| + | userinput = input(" | ||
| + | if (userinput != "" | ||
| + | password = userinput | ||
| + | |||
| + | userinput = input(" | ||
| + | if (userinput != "" | ||
| + | xmlfile = userinput | ||
| + | |||
| + | urlReasonLabel = " | ||
| + | |||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | |||
| + | # Import Finesse 11.X Wrap Code XML file | ||
| + | # tree = ET.ElementTree(file=" | ||
| + | try: | ||
| + | tree = ET.ElementTree(file=xmlfile) | ||
| + | except Exception as e: | ||
| + | print(type(e)) | ||
| + | print(e) | ||
| + | exit() | ||
| + | |||
| + | root = tree.getroot() | ||
| + | count_wraps = len(tree.findall(" | ||
| + | |||
| + | # If input file is a WrapReason File | ||
| + | if (count_wraps > 0): | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | press_y_to_continue() | ||
| + | WrapReasonLoop() | ||
| + | print(" | ||
| + | exit() | ||
| + | |||
| + | if (root.tag == " | ||
| + | count_reasoncodes = len(tree.findall(" | ||
| + | if (root.attrib.get(' | ||
| + | print(" | ||
| + | if (root.attrib.get(' | ||
| + | print(" | ||
| + | if (root.attrib.get(' | ||
| + | print(" | ||
| + | if ((root.attrib.get(' | ||
| + | root.attrib.get(' | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | press_y_to_continue() | ||
| + | ReasonCodeLoop() | ||
| + | print(" | ||
| + | exit() | ||
| + | print(" | ||
| + | exit() | ||
| + | |||
| + | print(" | ||
| + | exit() | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ===== Other Python Scripts ====== | ||
| + | |||
| + | Create Reason Code from a legacy system to a tech-refresh system (different Ids) | ||
| + | |||
| + | <code python> | ||
| + | import requests # used for http requests | ||
| + | from requests.auth import HTTPBasicAuth | ||
| + | import sys # used for sys.exit | ||
| + | import urllib3 # | ||
| + | import os #check / creating folders | ||
| + | urllib3.disable_warnings() #Surpress cert warnings | ||
| + | import xml.etree.ElementTree as ET | ||
| + | |||
| + | url = ' | ||
| + | |||
| + | tech_refresh_nr_codes = [" | ||
| + | legacy_nr_code = [" | ||
| + | |||
| + | reason_code_id = [] | ||
| + | |||
| + | def get_not_ready(id): | ||
| + | #basic = HTTPBasicAuth(finesseUsername, | ||
| + | #response = requests.get(url, | ||
| + | response = requests.get(url) | ||
| + | responseStatusCode = (response.status_code) | ||
| + | responseText = response.text | ||
| + | if (responseStatusCode == 200): | ||
| + | # | ||
| + | root = ET.fromstring(responseText) | ||
| + | for uri in root.findall(" | ||
| + | reason_code_uri = uri.text | ||
| + | #the component of the uri following the last forward slash. | ||
| + | value = reason_code_uri.split('/' | ||
| + | print (value) | ||
| + | counter = 0 | ||
| + | for l_id,tr_id in zip(legacy_nr_code, | ||
| + | if l_id == value: | ||
| + | print (tr_id) | ||
| + | print (" | ||
| + | reason_code_id.append(tr_id) | ||
| + | else: | ||
| + | print(' | ||
| + | print (len(reason_code_id)) | ||
| + | if len(reason_code_id) > 0: | ||
| + | xml='< | ||
| + | for id in reason_code_id: | ||
| + | xml+='< | ||
| + | xml+='</ | ||
| + | print (xml) | ||
| + | | ||
| + | get_not_ready(5000) | ||
| + | </ | ||