image: ./preview.png LIVEWire Implementation Guide⚡️ Integrate SignalWire AI Gateway (SWAIG) with Zendesk Support API
GitHub Repository
View the project and clone it to your development environment. ##### create_ticket Opens a new support ticket in Zendesk using the POST /api/v2/tickets.json Zendesk API endpoint.
json { name: create_ticket, parameters: { type: object, properties: { subject: { type: string, }, comment_body: { type: string, }, requester_name: { type: string, }, requester_email: { type: string, }, priority: { type: string, enum: [low, normal, high, urgent], nullable: true } }, required: [subject, comment_body, requester_name, requester_email] } } ##### update_ticket Updates an existing support ticket in Zendesk using the PUT /api/v2/tickets/{ticket_id}.json Zendesk API endpoint.
json { name: update_ticket, parameters: { type: object, properties: { type: integer, }, status: { type: string, enum: [new, open, pending, hold, solved, closed], nullable: true }, priority: { type: string, enum: [low, normal, high, urgent], nullable: true }, comment_body: { type: string, nullable: true }, public: { type: boolean, default: true, nullable: true } }, required: [ticket_id] } } ##### close_ticket Closes a support ticket in Zendesk by updating its status to closed using the PUT /api/v2/tickets/{ticket_id}.json Zendesk API endpoint.
json { name: close_ticket, parameters: { type: object, properties: { type: integer, } }, required: [ticket_id] } } ##### add_comment Adds a comment to an existing support ticket in Zendesk using the PUT /api/v2/tickets/{ticket_id}.json Zendesk API endpoint.
json { name: add_comment, parameters: { type: object, properties: { type: integer, }, public: { type: boolean, default: true, nullable: true } }, required: [ticket_id] } } ##### get_ticket Retrieves information about a specific ticket in Zendesk using the GET /api/v2/tickets/{ticket_id}.json Zendesk API endpoint.
json { name: get_ticket, parameters: { type: object, properties: { type: integer, } }, required: [ticket_id] } } ##### verify_support_pin Verifies the callers support PIN against the stored PIN in Zendesk using the GET /api/v2/search.json Zendesk API endpoint.
json { name: verify_support_pin, parameters: { type: object, properties: { caller_phone_number: { type: string, }, entered_pin: { type: integer, } }, required: [caller_phone_number, entered_pin] } } ##### get_current_user_tickets Retrieves ticket numbers for the authenticated user using the GET /api/v2/users/{user_id}/tickets/requested.json Zendesk API endpoint.
json { name: get_current_user_tickets, parameters: { type: object, properties: { caller_phone_number: { type: string, }, status: { type: string, enum: [new, open, pending, hold, solved, closed], nullable: true }, priority: { type: string, enum: [low, normal, high, urgent], nullable: true } }, required: [caller_phone_number] } } ##### create_ticket Creates a new support ticket in Zendesk using the POST /api/v2/tickets.json Zendesk API endpoint.
python import os import requests from requests.auth import HTTPBasicAuth # Retrieve environment variables ZENDESK_SUBDOMAIN = os.getenv(ZENDESK_SUBDOMAIN) ZENDESK_EMAIL = os.getenv(ZENDESK_EMAIL) ZENDESK_API_TOKEN = os.getenv(ZENDESK_API_TOKEN) def create_ticket( subject, comment_body, requester_name=None, requester_email=None, priority=None, ): url = fhttps://{ZENDESK_SUBDOMAIN}.zendesk.com/api/v2/tickets.json ticket_data = { ticket: { subject: subject, comment: { body: comment_body } } } if requester_name or requester_email: ticket_data[ticket][requester] = {} if requester_name: ticket_data[ticket][requester][name] = requester_name if requester_email: ticket_data[ticket][requester][email] = requester_email if priority: ticket_data[ticket][priority] = priority response = requests.post( url, json=ticket_data, auth=HTTPBasicAuth(f{ZENDESK_EMAIL}/token, ZENDESK_API_TOKEN) ) return response.json() ##### update_ticket Updates an existing support ticket in Zendesk using the PUT /api/v2/tickets/{ticket_id}.json Zendesk API endpoint.
python def update_ticket( ticket_id, status=None, priority=None, comment_body=None, public=True, ): url = fhttps://{ZENDESK_SUBDOMAIN}.zendesk.com/api/v2/tickets/{ticket_id}.json ticket_data = {ticket: {}} if status: ticket_data[ticket][status] = status if priority: ticket_data[ticket][priority] = priority if comment_body: ticket_data[ticket][comment] = { body: comment_body, public: public } response = requests.put( url, json=ticket_data, auth=HTTPBasicAuth(f{ZENDESK_EMAIL}/token, ZENDESK_API_TOKEN) ) return response.json() ##### close_ticket Closes a support ticket in Zendesk by using update_ticket to set the status to closed.
python def close_ticket(ticket_id, comment_body=None, public=True): return update_ticket( ticket_id, status=closed, comment_body=comment_body, public=public ) ##### add_comment Adds a comment to an existing support ticket by using update_ticket.
python def add_comment(ticket_id, comment_body, public=True): return update_ticket( ticket_id, comment_body=comment_body, public=public ) ##### get_ticket Retrieves information about a specific ticket in Zendesk using the GET /api/v2/tickets/{ticket_id}.json Zendesk API endpoint.
python def get_ticket(ticket_id): url = fhttps://{ZENDESK_SUBDOMAIN}.zendesk.com/api/v2/tickets/{ticket_id}.json response = requests.get( url, auth=HTTPBasicAuth(f{ZENDESK_EMAIL}/token, ZENDESK_API_TOKEN) ) return response.json() ##### verify_support_pin Verifies the callers support PIN against the stored PIN in Zendesk using the GET /api/v2/search.json Zendesk API endpoint.
python def verify_support_pin(caller_phone_number, entered_pin): user = find_user_by_phone(caller_phone_number) if user: stored_pin = user.get(user_fields, {}).get(support_pin) if stored_pin == entered_pin: return True return False def find_user_by_phone(caller_phone_number): url = fhttps://{ZENDESK_SUBDOMAIN}.zendesk.com/api/v2/search.json params = { query: ftype:user phone:{caller_phone_number} } response = requests.get( url, params=params, auth=HTTPBasicAuth(f{ZENDESK_EMAIL}/token, ZENDESK_API_TOKEN) ) results = response.json().get(results, []) return results[0] if results else None ##### get_current_user_tickets Retrieves ticket numbers for the authenticated user using the GET /api/v2/users/{user_id}/tickets/requested.json Zendesk API endpoint.
python def get_current_user_tickets(caller_phone_number, status=None, priority=None): user = find_user_by_phone(caller_phone_number) if user: user_id = user[id] tickets = list_user_tickets(user_id, status=status, priority=priority) if tickets: ticket_numbers = [ticket[id] for ticket in tickets.get(tickets, [])] return { ticket_numbers: ticket_numbers, tickets: tickets.get(tickets, []) } else: return { message: No tickets found for your account. } else: return { message: User not found. }
Integrate SignalWire AI with Zendesk Support API
## Introduction The AI Agent **creates**, **retrieves**, **updates**, and **closes tickets**, **adds comments**, and **authenticates users** via phone using a support PIN. This empowers users with the ability to securely manage support tickets in a phone call with conversational AI. ### Architecture Overview - **AI Agent**: Interfaces with users via phone calls. - **SignalWire AI Gateway (SWAIG)**: Handles AI Agent functions and maps them to Zendesk API endpoints. - **Zendesk Support API**: Manages support tickets and user data.