Contact Sales

All fields are required

AI-Assisted Customer Support: Automate Zendesk Tickets… | SignalWire
Developers

AI-Assisted Customer Support: Automate Zendesk Tickets with SWAIG

Implement an AI agent that interacts with Zendesk

Director of Support Engineering

Brian West

How to provide 24/7 support without breaking the bank

Global organizations, industries requiring around-the-clock service, or anyone looking to expand their customer support coverage can greatly benefit from this integration of SignalWire AI Agents with Zendesk. This code walkthrough demonstrates how to build an AI agent that is always on duty, answering support calls and handling simple tasks outside regular business hours.

The AI agent will be capable of creating, updating, and closing tickets, adding comments, and authenticating users via phone using a support PIN. For more complex queries, the agent queues the ticket for escalation to human agents during business hours.


About SignalWire AI Gateway (SWAIG)

This guide provides a comprehensive walkthrough for implementing an AI agent that uses the SignalWire AI Gateway (SWAIG) to interact with the Zendesk Support API.

SWAIG functions are serverless, declarative functions defined in SignalWire Markup Language (SWML). In this example, SWAIG functions map to Zendesk API endpoints, performing simple tasks like creating, updating, or closing tickets. They act as connectors between SignalWire's infrastructure and external systems like Zendesk, handling most routine tasks.

Enhancing security with support PINs

In industries like finance, healthcare, or insurance, safeguarding customer data is non-negotiable. This system secures customer interactions using Support PINs, so that only verified users can access or modify sensitive data.

The AI agent prompts callers for their PIN and validates it against Zendesk records before proceeding with any operation. This simple mechanism enhances security and compliance with stringent data protection regulations.

Prerequisites

  • A Zendesk account with admin access

  • A free SignalWire account

  • Python and basic Python knowledge

View the project and clone it to your development environment to get started.

Step 1: Set up Zendesk API access

Create an API token

  1. Log in to Zendesk.

  2. Navigate to Admin Center > Apps and integrations > Zendesk API > Zendesk API Settings.

  3. Enable Token Access.

  4. Click Add API Token.

  5. Enter a description and click Create.

  6. Copy the generated token and store it securely.

Create custom user fields (support PIN)

  1. Navigate to Admin Center > People > Configuration > User Fields.

  2. Click Add Field.

  3. Configure the field:
    • Type: Text (or Numeric if the PIN is digits only)

    • Title: Support PIN

    • Key: support_pin

  4. Save the new custom field.

Step 2: Set up SWML script and SWAIG functions

  1. Navigate to the SWML Scripts pane of the RELAY/SWML tab of your SignalWire Dashboard.

  2. Paste the SWML script into the browser SWML editor.

Step 3: Set up your Python environment

  1. Clone the GitHub repository.

  2. Install the required Python libraries using pip:

pip install -r requirements.txt

Enter your credentials in the .env file.

  • Rename env.example to .env and open it in a text editor.

  • Enter your Zendesk subdomain, email, API token, and HTTP basic auth credentials, following the below pattern:

ZENDESK_SUBDOMAIN=Your Zendesk subdomain
ZENDESK_EMAIL=Your Zendesk account email address
ZENDESK_API_TOKEN=Your Zendesk API token
HTTP_USERNAME=Username for HTTP Basic Authentication
HTTP_PASSWORD=Password for HTTP Basic Authentication


Step 4: Implement support PIN authentication

Generate and assign support PINs

Use a secure method to generate unique PINs for users.

Example in Python:


Assign the PIN to the user during registration or onboarding.

Update the user's profile with the support PIN using the Zendesk API.

API Endpoint: PUT /api/v2/users/{user_id}.json

Python Function:


Step 5: Complete argument mappings

Ensure all SWAIG function arguments map correctly to Zendesk API parameters.

Example: create_ticket Argument Mapping

  • SWAIG Function Arguments:
    • subject

    • comment_body

    • requester_name

    • requester_email

    • priority

  • Zendesk API Payload:


Example: update_ticket Argument Mapping

  • SWAIG Function Arguments:
    • ticket_id

    • status

    • priority

    • comment_body

    • public

  • Zendesk API Payload:


Example: close_ticket Argument Mapping

  • SWAIG Function Arguments:
    • ticket_id

  • Zendesk API Payload:


Example: add_comment Argument Mapping

  • SWAIG Function Arguments:
    • ticket_id

    • comment_body

    • public

  • Zendesk API Payload:


Example: get_ticket Argument Mapping

  • SWAIG Function Arguments:
    • ticket_id

  • Zendesk API Endpoint: GET /api/v2/tickets/{ticket_id}.json

Example: verify_support_pin Argument Mapping

  • SWAIG Function Arguments:
    • caller_phone_number

    • entered_pin

  • Zendesk API Endpoint: GET /api/v2/search.json

Example: get_current_user_tickets Argument Mapping

  • SWAIG Function Arguments:
    • caller_phone_number

    • status

    • priority

  • Zendesk API Endpoint: GET /api/v2/users/{user_id}/tickets/requested.json

Code walkthrough

PIN authentication

SWAIG verifies the caller's support PIN before executing any ticket operations.

Example Workflow:

  1. User Calls Support.

  2. AI Agent Prompts for PIN.

  3. User Enters PIN.

  4. SWAIG Calls the verify_support_pin function.
    • If verification succeeds, proceed.

    • If verification fails, handle accordingly.

  5. Execute Requested SWAIG Function.

SWAIG functions

SWAIG functions are defined by the SWAIG method within the SWML script. Each SWAIG function maps to a Zendesk API endpoint. In the below examples, you’ll see the SWAIG definitions. For more complex logic, view the Python functions.

create_ticket

Opens a new support ticket in Zendesk using the POST /api/v2/tickets.json Zendesk API endpoint:


update_ticket

Updates an existing support ticket in Zendesk using the PUT /api/v2/tickets/{ticket_id}.json Zendesk API endpoint:


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:


add_comment

Adds a comment to an existing support ticket in Zendesk using the PUT /api/v2/tickets/{ticket_id}.json Zendesk API endpoint:


get_ticket

Retrieves information about a specific ticket in Zendesk using the GET /api/v2/tickets/{ticket_id}.json Zendesk API endpoint:


verify_support_pin

Verifies the caller's support PIN against the stored PIN in Zendesk using the GET /api/v2/search.json Zendesk API endpoint:


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:


Recommendations before launching

Begin with a pilot project to test your AI agent’s capabilities in a controlled environment before implementing in a production environment. We recommend that you:

  • Test individual functions with mock data

  • Have actual users test the system

  • Implement error handling to manage and log errors appropriately

  • Use environment variables or a secrets manager

  • Consider encrypting support PINs

  • Adhere to GDPR and other data protection regulations

  • Avoid logging sensitive information

By following this guide, you can implement an AI agent that interacts with Zendesk through SWAIG, providing users with the ability to manage support tickets over the phone securely. The integration of support PIN authentication adds an extra layer of security, so that only authorized users can access and modify their tickets.

SignalWire’s infrastructure is designed to support ultra-low latency, meaning your callers will have a smooth conversational experience even under heavy traffic—whether they’re speaking to a human or an AI agent.

If you’re ready to build the future of communications, join our community of developers on Slack, our forum, or Discord!

Related Articles