Skip to content

Commit 4f5e577

Browse files
committed
AC-1162: Add new canned responses methods to ConfigurationApiV37
1 parent e081e75 commit 4f5e577

File tree

2 files changed

+124
-2
lines changed

2 files changed

+124
-2
lines changed

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ All notable changes to this project will be documented in this file.
88
- New method `delete_event` in customer-api v3.6.
99
- New methods in configuration-api v3.6 for greetings: `create_greeting`, `delete_greeting`, `get_greeting`, `update_greeting`, `list_greetings`.
1010
- New methods in agent-api v3.6: `send_thinking_indicator`, `send_message_preview`.
11+
- New methods in configuration-api v3.7 for canned responses: `create_canned_response`, `update_canned_response`, `list_canned_responses`, `delete_canned_response`.
1112

1213
### Changed
13-
- Config now points to v3.6 as stable and 3.7 as dev-preview version.
14+
- Config now points to v3.6 as a stable and 3.7 as a dev-preview version.
1415
- Improved websocket response collection + extended logging in the websocket client.
1516

1617
### Bugfixes

livechat/configuration/api/v37.py

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
class ConfigurationApiV37(HttpClient):
1515
''' Configuration API client class in version 3.7. '''
16+
1617
def __init__(self,
1718
token: Union[AccessToken, str],
1819
base_url: str,
@@ -1865,7 +1866,6 @@ def batch_update_bots(self,
18651866
json=payload,
18661867
headers=headers)
18671868

1868-
18691869
# Greetings
18701870

18711871
def create_greeting(self,
@@ -2029,3 +2029,124 @@ def update_greeting(self,
20292029
return self.session.post(f'{self.api_url}/update_greeting',
20302030
json=payload,
20312031
headers=headers)
2032+
2033+
2034+
# Canned responses
2035+
2036+
def create_canned_response(self,
2037+
text: str = None,
2038+
tags: list[str] = None,
2039+
group_id: int = None,
2040+
is_private: bool = None,
2041+
payload: dict = None,
2042+
headers: dict = None) -> httpx.Response:
2043+
''' Creates a new canned response.
2044+
2045+
Args:
2046+
text (str): Canned response text content (max 2000 characters).
2047+
tags (list[str]): Array of tags (max 20 tags, each max 50 characters).
2048+
group_id (int): ID of the group the canned response belongs to.
2049+
is_private (bool): Whether the canned response is private (default: `false`).
2050+
payload (dict): Custom payload to be used as request's data.
2051+
It overrides all other parameters provided for the method.
2052+
headers (dict): Custom headers to be used with session headers.
2053+
They will be merged with session-level values that are set,
2054+
however, these method-level parameters will not be persisted across requests.
2055+
2056+
Returns:
2057+
httpx.Response: The Response object from `httpx` library,
2058+
which contains a server's response to an HTTP request.
2059+
'''
2060+
if payload is None:
2061+
payload = prepare_payload(locals())
2062+
return self.session.post(f'{self.api_url}/create_canned_response',
2063+
json=payload,
2064+
headers=headers)
2065+
2066+
def update_canned_response(self,
2067+
id: int = None,
2068+
text: str = None,
2069+
tags: list[str] = None,
2070+
group_id: int = None,
2071+
is_private: bool = None,
2072+
payload: dict = None,
2073+
headers: dict = None) -> httpx.Response:
2074+
''' Updates an existing canned response. All parameters are optional -
2075+
only provided parameters will be updated.
2076+
2077+
Args:
2078+
id (int): ID of the canned response to update.
2079+
text (str): New canned response text (max 2000 characters).
2080+
tags (list[str]): Array of tags (max 20 tags, each max 50 characters).
2081+
group_id (int): New group ID for the canned response.
2082+
is_private (bool): Whether the canned response is private.
2083+
payload (dict): Custom payload to be used as request's data.
2084+
It overrides all other parameters provided for the method.
2085+
headers (dict): Custom headers to be used with session headers.
2086+
They will be merged with session-level values that are set,
2087+
however, these method-level parameters will not be persisted across requests.
2088+
2089+
Returns:
2090+
httpx.Response: The Response object from `httpx` library,
2091+
which contains a server's response to an HTTP request.
2092+
'''
2093+
if payload is None:
2094+
payload = prepare_payload(locals())
2095+
return self.session.post(f'{self.api_url}/update_canned_response',
2096+
json=payload,
2097+
headers=headers)
2098+
2099+
def list_canned_responses(self,
2100+
group_ids: list[int] = None,
2101+
include_private: bool = None,
2102+
limit: int = None,
2103+
page_id: str = None,
2104+
payload: dict = None,
2105+
headers: dict = None) -> httpx.Response:
2106+
''' Returns a paginated list of canned responses.
2107+
2108+
Args:
2109+
group_ids (list[int]): Filter by specific group IDs
2110+
(if not provided, uses user's accessible groups).
2111+
include_private (bool): Include private canned responses (default: `false`).
2112+
limit (int): Number of results per page (1-100, default: 100).
2113+
page_id (str): Page ID for pagination.
2114+
payload (dict): Custom payload to be used as request's data.
2115+
It overrides all other parameters provided for the method.
2116+
headers (dict): Custom headers to be used with session headers.
2117+
They will be merged with session-level values that are set,
2118+
however, these method-level parameters will not be persisted across requests.
2119+
2120+
Returns:
2121+
httpx.Response: The Response object from `httpx` library,
2122+
which contains a server's response to an HTTP request.
2123+
'''
2124+
if payload is None:
2125+
payload = prepare_payload(locals())
2126+
return self.session.post(f'{self.api_url}/list_canned_responses',
2127+
json=payload,
2128+
headers=headers)
2129+
2130+
def delete_canned_response(self,
2131+
id: int = None,
2132+
payload: dict = None,
2133+
headers: dict = None) -> httpx.Response:
2134+
''' Deletes an existing canned response.
2135+
2136+
Args:
2137+
id (int): ID of the canned response to delete.
2138+
payload (dict): Custom payload to be used as request's data.
2139+
It overrides all other parameters provided for the method.
2140+
headers (dict): Custom headers to be used with session headers.
2141+
They will be merged with session-level values that are set,
2142+
however, these method-level parameters will not be persisted across requests.
2143+
2144+
Returns:
2145+
httpx.Response: The Response object from `httpx` library,
2146+
which contains a server's response to an HTTP request.
2147+
'''
2148+
if payload is None:
2149+
payload = prepare_payload(locals())
2150+
return self.session.post(f'{self.api_url}/delete_canned_response',
2151+
json=payload,
2152+
headers=headers)

0 commit comments

Comments
 (0)