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.
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" } }
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)
|
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:
Note: For emails, the system converts the saved
CAD values to string. This means you cannot later refer to the
values inside a JSON object or an array. To use an individual CAD
value either in a further condition or as a data placeholder in
another event-driven JSON configuration, place it directly under the
save configuration.
|
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:
|
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:
|