Using conditions
You can define a condition in your request handling by using Python. The request will only be sent out if the condition is met. You can add comments to your conditions by using the # character.
The condition can be, for example:
-
language restriction: POST request will only be sent if the conversation's language is either Finnish or English
{ "request": { "method": "POST", "condition": "contact.get_language().lower() in ('en', 'fi')" } }
-
prevent PUT request from being sent if the conversation has been created less than ten minutes ago
{ "request": { "method": "PUT", "condition": "contact.get_seconds_since_created() >= 600" } }
-
send a GET request randomly
{ "request": { "method": "GET", "condition": "random.randrange(1, 10000) % 2 == 0 #Sends the request when a pseudo-random integer from range 1..10000 is an even number" } }
Note: This includes a comment after the # character.
Item | Type | Description | Examples |
---|---|---|---|
contact | object | Real-time contact data | See table Referring to contact and event data in conditional request configuration below. |
event | object | Real-time event data | See table Referring to contact and event data in conditional request configuration below. |
builtins | various | Set of basic functions and types | See Python's built-in functions (3.12) |
datetime | module | Basic date and time types | See Python's datetime
module (3.12)
|
json | module | JSON encoder and decoder | See Python's json module
(3.12)
|
random | module | Generate pseudo-random numbers | See Python's random
module (3.12)
|
re | module | Regular expression operations | See Python's re module
(3.12)
|
time | module | Time access and conversions | See Python's time module
(3.12)
|
Property | Python data type | Syntax | Examples |
---|---|---|---|
Channel type | str | contact.get_channel_type() |
If the conversation uses the chat
channel:
|
Channel subtype | str | None | contact.get_channel_sub_type() |
If the conversation's channel subtype is other than
SMS:
|
Direction | str | contact.get_direction() |
If the conversation is
inbound:
Note: It's recommended to select the direction in
the configuration rather than define it in a condition.
|
ID | str | contact.get_id() | - |
Monitoring / reporting ID | str | contact.get_guid() | - |
Creation timestamp | str | contact.get_created() |
If the conversation was created during certain UTC
hours:
|
Seconds elapsed since the contact was created | float | contact.get_seconds_since_created() |
If the conversation's lifetime (at the time of the triggering event)
is longer or equal to one
minute:
|
Language | str | contact.get_language() |
If the conversation's language is either English or
Finnish:
|
Priority | int | contact.get_priority() |
If the conversation's priority value is less than or equal to
100:
|
Skills | list | None | contact.get_skills() |
If the conversation has no skill
requirements:
If the conversation has at least one skill
requirement:
If the conversation has two or more skill requirements, taking into
account that the conversation's skills may be
None:
If the conversation has one or more skill requirements of level 4 or higher:
If the conversation has a skill requirement named
English:
|
Current queue | dict | None | contact.get_queue() |
If the conversation has no current queue
set:
If the conversation has a current queue
set:
If the conversation's current queue extension address equals
chat.queue.fi@acme.com, taking into account
that the conversation's current queue may be
None:
|
Forwarding queue | dict | None | contact.get_forwarding_queue() |
If the conversation has no forwarding queue
set:
If the conversation has a forwarding queue
set:
If the conversation has been forwarded from queue address chat.queue.fi@acme.com, taking into account that the conversation's forwarding queue may be None:
|
Current agent | dict | None | contact.get_agent() |
If the conversation has no current agent
set:
If the conversation has current agent
set:
If the conversation has a current agent with chat address
agent@acme.com:
|
Preferred agent | dict | None | contact.get_preferred_agent() | See Current agent above. |
Required agents | list | None | contact.get_required_agents() |
If the conversation has no required agents
set:
If the conversation has at least one required agent
set:
If the conversation has two or more required agents set, taking into
account that the conversation's required agents may be
None:
If the conversation has an agent with chat address agent@acme.com set as one of the required agents, taking into account that the conversation's required agent may be None:
|
Transferring agent | dict | None | contact.get_transferring_agent() | See Current agent above. |
Source | str | contact.get_source_address() |
If the conversation has originated from a Finnish phone
number:
|
Destination | str | contact.get_destination_address() |
If the conversation is arriving to queue address chat.queue.en@acme.com or chat.queue.fi@acme.com:
|
External destination | str | contact.get_external_destination_address() |
If the call has been forwarded or transferred to a PSTN number registered to the Uusimaa region in Finland, taking into account that the conversation's external destination address may be None:
|
CAD | dict | None | contact.get_attached_data() |
If the conversation has the same value in key my-string-key as in string my-string-value on root level of CAD, taking into account that CAD could be None:
If the conversation has the value of key my-numeric-value greater than 100, taking into account that the value is expected to be stored in CAD under path record/fields and that either the whole CAD or one/all of the sub-levels of the CAD could be None:
|
Supported for email only | |||
Case ID |
str | None (can be None only for conversations from other channels than email) |
contact.get_case_id() |
If the email conversation has a case ID that is an even number:
|
To addresses | list | None | contact.get_to_addresses() |
If the email conversation has multiple To addresses:
If the email conversation has address email.queue@acme.com in its list of To addresses:
|
Cc addresses | list | None | contact.get_cc_addresses() |
See To addresses. |
Subject | str | None | contact.get_subject() |
If the email conversation has a subject indicating that it is a reply message (in English or Finnish):
|
Body | str | None | contact.get_body() |
If the email conversation either has no body text or body text that is a maximum of 500 characters:
|
Supported only for campaign calls | |||
Outbound campaign ID | str | None | contact.get_campaign_id() | If the campaign call is related to campaign with ID
A2497527E637480F8F698CCAC40EFD4C:
|
Outbound campaign customer ID | str | None | contact.get_campaign_customer_id() | If the campaign call is related to customer with ID
FD39EABEC7804148AB80CC5BE3028E26:
|
Outbound campaign classifier ID | str | None (can be None only when classification is not done by an agent from a call result list) |
contact.get_campaign_classifier_id() | If the campaign call has been classified using classifier with ID
A5EB6A0B8B38EB11AA47027E1B397C3D:
|
Outbound campaign classifier | str | None (can be None only when classification is not done by an agent from a call result list or not defined in IVR configuration) |
contact.get_campaign_classifier() | If the campaign call has been classified using a classifier whose
text value is not Busy or No
Answer:
|
Outbound campaign call result | str | None | contact.get_campaign_call_result() | If the campaign call has been classified using a classifier whose
technical call result value is WRONG_PERSON or
WRONG_NUMBER:
|
Outbound campaign customer result | str | None | contact.get_campaign_result() | If the campaign call's technical customer result value is
CALL or
REDIAL:
|
Outbound campaign dialer type | str | None | contact.get_campaign_dialer_type() | If the campaign call's campaign uses dialer type
QueueDialer:
|
Outbound campaign dialing mode | str | None | contact.get_campaign_dialing_mode() | If the campaign call's campaign uses dialing mode
Preview or
Predictive:
|
Event data | |||
Event type name | str | event.type | If the conversation uses the chat channel and has event
allocated or
rejected:
Note: It's recommended to select the event(s) in the
configuration rather than define them in a condition. |
Event timestamp | float | event.timestamp |
If the event occurs within the specified UTC hour range
(08-16):
If the event occurs on even
minutes:
|
Description | Python data type | Syntax |
---|---|---|
Returns True if the queue is available, False otherwise An available queue:
|
bool | None |
queue.is_available() For example, to check if the queue is available:
|
Returns True if the queue is open according to its service times, False otherwise |
bool | None |
queue.is_open() For example, to check if the queue is closed:
|
Returns the number of contacts in the queue, including contacts accepted by agents | int | None |
queue.get_num_contacts_all() For example, to check if the number is greater than 50:
|
Returns the number of contacts per agent in the queue, including contacts accepted by agents | float | None |
queue.get_num_contacts_all_per_agent() For example, to check if the number is greater than 1:
|
Returns the number of contacts in the queue, excluding contacts accepted by agents | int | None |
queue.get_num_contacts_waiting() For example, to check if the number is greater than or equal to 10:
|
Returns the number of contacts per agent in the queue, excluding contacts accepted by agents | float | None |
queue.get_num_contacts_waiting_per_agent() For example, to check if the number is greater than or equal to 5:
|
Returns the total number of agents serving in the queue, regardless of status | int | None |
queue.get_num_agents_all() For example, to check if the number is equal to 0:
|
Returns the number of agents serving in the queue with Waiting status | int | None |
queue.get_num_agents_waiting() For example, to check if the number is less than 5:
|
Returns the number of agents serving in the queue with Talking status For phone queues only. For other queue types, this is expected to always return 0. |
int | None |
queue.get_num_agents_talking() For example, to check if the number is equal to 0:
|
Returns the number of agents serving in the queue with Not ready status | int | None |
queue.get_num_agents_not_ready() For example, to check if the number is not equal to 0:
|
Returns the number of agents serving in the queue with Paused status An agent is Paused when their profile is of type Absence. |
int | None |
queue.get_num_agents_paused() For example, to check if the number is greater than 5:
|
Returns the maximum current contact waiting time (in seconds) for the queue | int | None |
queue.get_contact_wait_time_max() For example, to check if the number is greater than 600:
|
Returns the average current contact waiting time (in seconds) for the queue | int | None |
queue.get_contact_wait_time_avg() For example, to check if the number is greater than 300:
|
Returns the estimated current contact waiting time (in seconds) for the queue | int | None |
queue.get_contact_wait_time_est() For example, to check if the number is greater than 200:
|