Skip to content

Commit

Permalink
add talk_call stream + other minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-schick committed Jun 29, 2022
1 parent ad9908f commit c15ffe0
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 4 deletions.
1 change: 1 addition & 0 deletions tap_zendesk/schemas/archive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains not implemented stream schemas
39 changes: 39 additions & 0 deletions tap_zendesk/schemas/archive/talk_availabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"type": ["object"],
"properties": {
"agent_id": {
"type": ["integer"]
},
"agent_state": {
"type": [
"string",
"null"
],
"description": "The availability state of the agent",
"enum": [
"online",
"offline",
"away"
]
},
"call_status": {
"type": [
"string",
"null"
],
"description": "The call status of the agent",
"enum": [
"on_call",
"wrap_up",
"null"
]
},
"via": {
"type": [
"string",
"null"
],
"description": "The channel (client/phone) the agent is registered to"
}
}
}
186 changes: 186 additions & 0 deletions tap_zendesk/schemas/talk_calls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{
"type": ["object"],
"properties": {
"agent_id": {
"type": ["integer", "null"],
"description": "The id of the first agent who picked up the call"
},
"call_charge": {
"type": ["string", "null"],
"description": "Total charge for the call. String representation of a decimal number with six decimal places. Example: \"1.230000\". Null if no charge was received from Twilio"
},
"call_group_id": {
"type": ["integer", "null"],
"description": "The id number of the group the call was last placed in before completion."
},
"call_recording_consent": {
"type": ["string"],
"description": "Call recording consent value configured for the phone number",
"enum": ["always", "opt_in", "opt_out", "never"]
},
"call_recording_consent_action": {
"type": ["string", "null"],
"description": "Keypress the caller chose to give their call recording consent option.",
"enum": ["3"]
},
"callback": {
"type": ["boolean"],
"description": "True if the call was initiated by a callback request from the customer"
},
"callback_source": {
"type": ["string", "null"],
"description": "The source of the callback request",
"enum": ["queue", "web widget"]
},
"completion_status": {
"type": ["string"],
"description": "Status of the call",
"enum": ["completed", "abandoned_in_queue", "abandoned_in_ivr", "abandoned_in_voicemail", "abandoned_on_hold", "pending_voicemail"]
},
"consultation_time": {
"type": ["integer"],
"description": "Sum of how long in seconds agents consulted with each other while the customer was on hold"
},
"created_at": {
"type": ["string"],
"description": "When the call object was created",
"format": "date-time"
},
"customer_id": {
"type": ["integer", "null"],
"description": "!!! not documented field !!!"
},
"customer_requested_voicemail": {
"type": ["boolean"],
"description": "The customer requested to be directed to voicemail instead of waiting for an agent to answer"
},
"default_group": {
"type": ["boolean"],
"description": "The call was answered by an agent who is a member of the call's default group, if group routing is used"
},
"direction": {
"type": ["string"],
"description": "Inbound or outbound. The agent or customer who initialized the call"
},
"duration": {
"type": ["integer"],
"description": "Call duration in seconds"
},
"exceeded_queue_time": {
"type": ["boolean"],
"description": "The customer exceeded the maximum queue wait time and did not speak with an agent"
},
"hold_time": {
"type": ["integer"],
"description": "Sum of how long in seconds the customer was placed on hold by an agent(s)"
},
"id": {
"type": ["integer"],
"description": "Call id"
},
"ivr_action": {
"type": ["string", "null"],
"description": "Menu action that was used by the caller in the IVR menu selection",
"enum": [
"null", "menu", "voicemail", "group", "phone_number", "textback", "invalid"
]
},
"ivr_destination_group_name": {
"type": ["string", "null"],
"description": "Name of the group that received the call through IVR routing. null if IVR is disabled"
},
"ivr_hops": {
"type": ["integer", "null"],
"description": "How many menu options the customer went through in IVR before talking to an agent. null if IVR is disabled"
},
"ivr_routed_to": {
"type": ["string", "null"],
"description": "Phone number where call was routed to by IVR. Example: \"+1311123456789\". null if IVR is disabled"
},
"ivr_time_spent": {
"type": ["integer", "null"],
"description": "How long in seconds the customer spent in IVR. Null if IVR is disabled"
},
"minutes_billed": {
"type": ["integer"],
"description": "Minutes billed"
},
"not_recording_time": {
"type": ["integer"],
"description": "How long in seconds spent not recording on the call"
},
"outside_business_hours": {
"type": ["boolean"],
"description": "The call was received outside business hours"
},
"overflowed": {
"type": ["boolean"],
"description": "True if the call overflowed"
},
"overflowed_to": {
"type": ["string", "null"],
"description": "The phone number that the call overflowed to. null if overflowed is false"
},
"phone_number": {
"type": ["string", "null"],
"description": "Talk phone associated with the call. Example: \"+1311123456789\""
},
"phone_number_id": {
"type": ["integer"],
"description": "Talk phone number id"
},
"quality_issues": {
"type": ["array"],
"description": "A summary of the call's quality issues related to the call provided to Zendesk from Twilio. Until the information is made available by Twilio, the array contains \"information_not_available\". If there are no issues, the array contains \"none\". Other possible values: one or more of \"silence\", \"high_jitter\", \"high_packet_loss\", \"high_pdd\", \"high_latency\"",
"items": {
"type": "string",
"enum": [
"information_not_available",
"none",
"silence",
"high_jitter",
"high_packet_loss",
"high_pdd",
"high_latency"
]
}
},
"recording_control_interactions": {
"type": ["integer"],
"description": "The amount of times agents have paused or resumed a recording on the call."
},
"recording_time": {
"type": ["integer"],
"description": "How long in seconds spent recording on the call"
},
"talk_time": {
"type": ["integer"],
"description": "Sum of how long in seconds the customer was in conference with an agent(s). If a call is not accepted by an agent this will be 0"
},
"ticket_id": {
"type": ["integer", "null"],
"description": "The id of the ticket related to the call"
},
"time_to_answer": {
"type": ["integer", "null"],
"description": "How long in seconds the customer waited for an agent to answer after hearing the Available agents greeting"
},
"updated_at": {
"type": ["string"],
"description": "When the call object was last created",
"format": "date-time"
},
"voicemail": {
"type": ["boolean"],
"description": "If true, the call was a voicemail"
},
"wait_time": {
"type": ["integer"],
"description": "How long in seconds the customer was in the call before an agent answered"
},
"wrap_up_time": {
"type": ["integer"],
"description": "Sum of how long in seconds the agent(s) spent in wrap up"
}
}
}
5 changes: 1 addition & 4 deletions tap_zendesk/schemas/talk_phone_numbers.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"type": [
"null",
"object"
],
"type": ["object"],
"properties": {
"capabilities": {
"type": [
Expand Down
23 changes: 23 additions & 0 deletions tap_zendesk/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,28 @@ def sync(self, state): # pylint: disable=unused-argument
for phone_number in self.client.talk.phone_numbers():
yield (self.stream, phone_number)


class TalkCalls(Stream):
name = 'talk_calls'
replication_method = "INCREMENTAL"
replication_key = 'updated_at'

def sync(self, state):
bookmark = self.get_bookmark(state)

if not bookmark:
start_date = self.config.get('start_date')
if start_date:
bookmark = utils.strptime_with_tz(start_date)

LOGGER.info(f'Start date: {bookmark}')

for call in self.client.talk.calls.incremental(start_time=bookmark):
if utils.strptime_with_tz(call.updated_at) >= bookmark:
self.update_bookmark(state, call.updated_at)
yield (self.stream, call)


STREAMS = {
"tickets": Tickets,
"groups": Groups,
Expand All @@ -663,4 +685,5 @@ def sync(self, state): # pylint: disable=unused-argument
"ticket_metrics": TicketMetrics,
"sla_policies": SLAPolicies,
"talk_phone_numbers": TalkPhoneNumbers,
"talk_calls": TalkCalls
}

0 comments on commit c15ffe0

Please sign in to comment.