Zendesk

Create an OAuth client in Zendesk:

Smart Assistant connects to the Zendesk API using an OAuth client (Zendesk is retiring API tokens). You will create one OAuth client for this integration and share its Client ID and Client secret with us.

  1. Log in to Zendesk Admin Center:
    • Go to: https://<your_subdomain>.zendesk.com/admin.
    • Replace <your_subdomain> with the subdomain of your Zendesk account.
    • Important: everything Smart Assistant does through this client (creating tickets, adding comments) is attributed to the Zendesk user who creates the client. We recommend creating it from a dedicated administrator account (e.g. "Smart Assistant") rather than a personal one.
  2. Navigate to OAuth clients:
    • In the Admin Center, go to: Apps and Integrations → APIs → OAuth clients.
  3. Create the client:
    • Click the Add OAuth client button.
    • Fill in the required fields: Name (e.g., "Smart Assistant"), Description and Company.
    • Keep the suggested Identifier or choose your own (it must be unique). This is the Client ID.
    • Set the Client kind to Confidential.
    • Leave Redirect URLs empty; they are not needed.
    • In Allowed scopes, select exactly: read, tickets:write and users:write.
    • Leave Expire tokens enabled (Zendesk does not allow turning it off).
    • Click Save.
    Zendesk OAuth client form
  4. Copy the credentials:
    • Copy the Identifier (this is the Client ID).
    • Copy the Secret (this is the Client secret).
    • Important: copy the secret immediately. It will only be displayed once.
Configure a Webhook in Zendesk:
  1. Log in to Zendesk Admin Center:
    • Go to: https://<your_subdomain>.zendesk.com/admin.
    • Replace <your_subdomain> with the subdomain of your Zendesk account.
  2. Navigate to Webhooks:
    • In the Admin Center, go to: Apps and Integrations → Webhooks → Create Webhook.
  3. Create a New Webhook:
    • Click the Create Webhook button.
    • Select the "Trigger or Automation" one
    • Zendesk webhook_type
  4. Enter Webhook Details:
    • Name: Provide a meaningful name for the webhook, such as "Zendesk Assistant Webhook".
    • Endpoint URL: Enter the URL https://smart-assistant.usizy.com/zendesk_webhook/<ecommerce_slug>.
    • Ecommerce slug: Ecommerce slug is provided by usizy.
    • Request Method: Choose POST.
    • Request Format: Choose JSON.
    • If your endpoint requires authentication, configure it under Authentication (And share the needed credentials with the Usizy team).
  5. Save the Webhook:
    • If the test is successful, click Save to activate the webhook.
Share webhook secret:

A webhook secret is needed for security reasons.

  1. Go to the webhook you just created
    • In the Admin Center, navigate to Apps and Integrations → Webhooks → Your webhook
    • In the bottom, click reveal secret.

  2. Zendesk webhook_secret
Set up Webhook triggers:

There are 3 triggers needed to ensure correct functionality:

  • to notify new comments
  • to notify new tickets
  • to notify ticket closing
  1. Navigate to Triggers:
    • In the Admin Center, go to: Objects and Rules → Business Rules → Triggers.
  2. Create the first trigger:
    • Click the Add Trigger button.
  3. Define Trigger Conditions:
    • Name: Provide a name like "Notify Assistant on new comment".
    • Conditions: Specify when the webhook should be triggered. In this case, the webhook must notify when there's a new comment on a ticket. These rules should be added to ensure correct behaviour:

    • Zendesk triggers
  4. Trigger Actions:
    • Select Notify Active Webhook and choose the webhook you just created.
    • Set the following action on webhook trigger:

    • Zendesk action
      Here is the JSON data that should be placed for the action:

            
      "id": "{{ticket.id}}",
      "comment": "{{ticket.latest_public_comment}}",
      "support_name": "{{ticket.assignee.first_name}}",
      "agent_id": "{{ticket.assignee.id}}",
      "latest_public_comment_author_id": "{{ticket.latest_public_comment.author.id}}",
      "requester_id": "{{ticket.requester.id}}",
      "requester_external_id": "{{ticket.requester.external_id}}",
      "requester_email": "{{ticket.requester.email}}",
      "requester_language": "{{ticket.requester.language}}",
      "attachments": [
          {% for attachment in ticket.latest_public_comment.attachments %}
          {
            "file_name": "{{attachment}}",
            "url": "{{attachment.url}}"
          }{% unless forloop.last %},{% endunless -%}
          {% endfor %}
        ]
      }
            
          
  5. Add the second trigger:
    • Click the Add Trigger button.
  6. Define Trigger Conditions:
    • Name: Provide a name like "Notify new ticket".
    • Conditions: Specify when the webhook should be triggered. In this case, the webhook must notify when a ticket is created:

    • Zendesk triggers
  7. Trigger Actions:
    • Select Notify Active Webhook and choose the webhook you just created.
    • Create the action with the same logic as the first trigger.
    • Here is the JSON data that should be placed for the action

            
      {
      "id": "{{ticket.id}}",
      "ticket_status": "{{ticket.status}}",
      "via": "{{ticket.via}}",
      "requester_external_id": "{{ticket.requester.external_id}}",
      "requester_email": "{{ticket.requester.email}}",
      "requester_language": "{{ticket.requester.language}}"
      }
            
          
  8. Add the third trigger:
    • Click the Add Trigger button.
  9. Define Trigger Conditions:
    • Name: Provide a name like "Notify closed ticket".
    • Conditions: Specify when the webhook should be triggered. In this case, the webhook must notify when a ticket is closed/resolved:

    • Zendesk triggers
  10. Trigger Actions:
    • Select Notify Active Webhook and choose the webhook you just created.
    • Create the action with the same logic as the first trigger.
    • Here is the JSON data that should be placed for the action

            
      {
      "id": "{{ticket.id}}",
      "comment": "{{ticket.latest_public_comment}}",
      "support_name": "{{ticket.assignee.first_name}}",
      "agent_id": "{{ticket.assignee.id}}",
      "ticket_status": "closed",
      "via": "{{ticket.via}}",
      "requester_external_id": "{{ticket.requester.external_id}}",
      "requester_email": "{{ticket.requester.email}}",
      "requester_language": "{{ticket.requester.language}}"
      }
            
          
Conversations API
  1. Log in to Zendesk Admin Center:
    • Go to: https://<your_subdomain>.zendesk.com/admin.
    • Replace <your_subdomain> with the subdomain of your Zendesk account.
  2. Navigate to Conversations API:
    • In the Admin Center, go to: Apps and Integrations → APIs → Conversations API
  3. Create API key:
    • Click "Create API Key" button.
    • Provide a name like "Smart Assistant".
    • Copy the values for App ID, Key ID and Secret key.
      Important: Copy the Secret key immediately. It will only be displayed once.
Conversations WebHook
  1. Log in to Zendesk Admin Center:
    • Go to: https://<your_subdomain>.zendesk.com/admin.
    • Replace <your_subdomain> with the subdomain of your Zendesk account.
  2. Navigate to API Settings:
    • In the Admin Center, go to: Apps and Integrations → Integrations → Conversations integrations.
  3. Create integration:
    • Click "Create integration" button.
    • Provide a name like "Smart Assistant".
    • Enter the webhook URL https://smart-assistant.usizy.com/zendesk_messaging_webhook/<ecommerce_slug>
    • Mark "Include full user" and "Include full source" checkboxes.
    • On Webhook subscriptions check "Conversation message" and "Switchboard release control".
    • Copy Webhook ID and Shared Secret.
    Zendesk Conversations Webhook