The following functions provide Zendesk customer support integration. View the Zendesk API for more details or check out our Zendesk tutorial.
Import
To use this library and its functions, you must use the import line at the beginning of your Base Python code.
import Zendesk
Authenticate
Zendesk.authenticate(url, username, token)
Logs in to your Zendesk account
Credit cost: 1
Parameters
- url:
str
url to Zendesk account. - username:
str
Zendesk account email. - token:
str
Zendesk token.
Return Value
None
Example
- Sample Code:
-
import Zendesk Zendesk.authenticate("https://medium1.zendesk.com", "david@mediumone.com", "12345678")
-
Exceptions
- AssertionError
- url, username, or token not a string
- ZendeskAPIException
- Any API error returned by Zendesk
Get tickets
get_tickets()
Returns all the tickets.
Credit cost: 1
Parameters
None
Return Value
list
all tickets on the authenticated Zendesk account
Example
- Sample Code:
-
import Zendesk Zendesk.authenticate("https://medium1.zendesk.com", "david@mediumone.com", "12345678")
tickets = Zendesk.get_tickets()
-
Exceptions
- ZendeskAuthException
- Not logged in
- ZendeskAPIException
- Any API error returned by Zendesk
Get ticket
Zendesk.get_ticket(ticket_id)
Returns a specific ticket.
Credit cost: 1
Parameters
- ticket_id:
int
the number automatically assigned to a ticket when created
Return Value
dict
info of the specified ticket
Example
- Sample Code:
-
import Zendesk Zendesk.authenticate("https://medium1.zendesk.com", "david@mediumone.com", "12345678")
tickets = Zendesk.get_ticket(123)
-
Exceptions
- AssertionError
- ticket_id not a number
- ZendeskAuthException
- Not logged in
- ZendeskAPIException
- Any API error returned by Zendesk
Search tickets
Zendesk.get_tickets_search(keyword)
Returns a list of all the tickets containing the search keyword.
Credit cost: 1
Parameters
- keyword:
str
word to be searched for within all the tickets
Return Value
list
list of all tickets containing the search keyword
Example
- Sample Code:
-
import Zendesk Zendesk.authenticate("https://medium1.zendesk.com", "david@mediumone.com", "12345678")
tickets = Zendesk.get_tickets_search("website")
-
Exceptions
- ZendeskAuthException
- Not logged in
- ZendeskAPIException
- Any API error returned by Zendesk
Create ticket
Zendesk.create_ticket(subject, comment, requesterID=None, filename=None, contenttype=None, content=None, external=False)
Creates a new ticket.
Credit cost: 1
Parameters
- subject:
str
subject of the ticket - comment:
str
comment that describes the problem, incident, question, or task - requesterID:
str
numeric ID of the user asking for support through the ticket - filename:
str
name of attached file - contenttype:
str
content type of the file - content:
str
attachment contents - external:
bool
set comment to public
Return Value
None
Example
- Sample Code:
-
import Zendesk Zendesk.authenticate("https://medium1.zendesk.com", "david@mediumone.com", "12345678")
new_ticket = Zendesk.create_ticket('lakshans subject', 'lakshans comment')
-
Exceptions
- AssertionError
- requesterID not None and not a number
- subject, comment not a string
- filename, contenttype, content not None and not a string
- ZendeskAuthException
- Not logged in
- ZendeskAPIException
- Any API error returned by Zendesk
Update ticket
Zendesk.update_ticket(ticket_id, comment, filename=None, contenttype=None, content=None, external=False)
Updates an existing ticket.
Credit cost: 1
Parameters:
- ticket_id:
int
number automatically assigned to a ticket when created. - comment:
str
comment that describes the problem, incident, question, or task - filename:
str
name of attached file - contenttype:
str
content type of the file - content:
str
attachment contents - external:
bool
set comment to public
Return Value
None
Example
- Sample Code:
-
import Zendesk Zendesk.authenticate("https://medium1.zendesk.com", "david@mediumone.com", "12345678")
new_ticket = Zendesk.create_ticket('lakshans subject', 'lakshans comment')
Zendesk.update_ticket(new_ticket['ticket_id'], 'lakshans comment with attachment', 'lakshans_attachment.html', 'text/plain', '<html><body>hello</body></html>')
-
Exceptions
- AssertionError
- requesterID not None and not a number
- comment not a string
- filename, contenttype, content not None and not a string
- ZendeskAuthException
- Not logged in
- ZendeskAPIException
- Any API error returned by Zendesk
Delete ticket
Zendesk.delete_ticket(ticket_id)
Deletes an existing ticket.
Credit cost: 1
Parameters:
- ticket_id:
int
number automatically assigned to a ticket when created.
Return Value
None
Example
- Sample Code:
-
import Zendesk Zendesk.authenticate("https://medium1.zendesk.com", "david@mediumone.com", "12345678")
new_ticket = Zendesk.create_ticket('lakshans subject', 'lakshans comment')
Zendesk.delete_ticket(new_ticket['ticket_id'])
-
Exceptions
- AssertionError
- ticket_id not a number
- ZendeskAuthException
- Not logged in
- ZendeskAPIException
- Any API error returned by Zendesk
Get user
Zendesk.get_user(userid)
Gets object containing information for user ID.
Credit cost: 1
Parameters:
- userid:
int
number automatically assigned to a user when created.
Return Value
dict
dict containing user info
Example
- Sample Code:
-
import Zendesk Zendesk.authenticate("https://medium1.zendesk.com", "david@mediumone.com", "12345678")
my_user = Zendesk.get_user(123)
-
Exceptions
- AssertionError
- userid not a number
- ZendeskAuthException
- Not logged in
- ZendeskAPIException
- Any API error returned by Zendesk