Skip to content

Create tickets in Zendesk automatically when inkeep is unable to resolve the answer from your documentation.

Notifications You must be signed in to change notification settings

inkeep/inkeep-zendesk-ticket-creation-vercel

Repository files navigation

Inkeep to Zendesk Create Ticket Example

Getting Started

From Scratch

Clone this repository:

git clone https://github.com/inkeep/inkeep-zendesk-ticket-creation-with-vercel

Setup dependencies:

npm install

Copy the example env file to make a .env.development.local for local development.

cp .env.example .env.development.local

Add to an existing project

If you'd like to add an API route to an existing Next.js project:

  1. Copy the files under api/create-support-ticket into your own API route.
  2. Install deps via pnpm add @vercel/edge-config zod
  3. Follow the rest of these instructions to get the .env variables you need

You will need to provide values for all env variables shown in .env.example:

INKEEP_CHAT_PREVIEW_ROOT="<INKEEP_CHAT_PREVIEW_ROOT>" # instructions below in README
ZENDESK_DOMAIN="<ZENDESK_DOMAIN>" # Your zendesk domain
ZENDESK_EMAIL_ADDRESS="<EMAIL_OF_VALID_USER_TO_SUBMIT_TICKETS" # needs to be a valid user
ZENDESK_API_TOKEN="<ZENDESK_API_TOKEN>" # See below for instructions on how to create an API token

Create Zendesk API Token

How to Generate Zendesk API Token in Inkeep

Login to your Zendesk Dashboard

Usually you have a specific subdomain such as https://<your-company-name>.zendesk.com/

1. Click on the Settings Gear icon (Admin)

Step 1 screenshot

2. Click on Go to Admin Center

API Tokens can only be created from within the Admin Center

Step 2 screenshot

3. Click on Apps and integrations

Step 3 screenshot

4. Click on Zendesk API

Step 4 screenshot

5. Click on Add API token

If you don't see "Add API token" be sure to enable Token access via the toggle switch.

Step 5 screenshot

6. Give the API token a name you will remember such as "Inkeep Ticket Creation"

Step 6 screenshot

7. Click on Copy

Step 7 screenshot

8. Make sure to copy and store this token. It won't be shown again after you click Save or leave this page.

Step 8 screenshot

9. Click on Save

Step 9 screenshot

10. Set the environment variable on your deployed Vercel function ZENDESK_API_TOKEN to the value you have just copied.


Inkeep Preview URL (optional)

If you'd like to attach a link to the Inkeep Dashboard view of the AI-chat for reference, then set the following:

INKEEP_CHAT_PREVIEW_ROOT=https://portal.inkeep.com/<ORG_ALIAS>/projects/<PROJECT_ID>/chat/sandbox

This will be added as an internal-facing note to the supprot conversation.

Run locally

npm dev

API Routes

/api/create-support-ticket - Create a new ticket in your inbox.

See the Zendesk Tickets API for full customization.

Example Request

Note that the request is generated by your client side, please validate that the types and request body align.

There's an example Zod validation and types in api/create-support-ticket/requestSchemaValidation.ts. Validation should be optimistic.

{
  "formDetails": {
    "firstName": "John",
    "email": "j@domain.com",
    "additionalDetails": "Would like to change my password, please."
  },
  "chatSession": {
    "messages": [
      {
        "role": "user",
        "content": "How do I change my password?"
      },
      {
        "role": "assistant",
        "content": "Sorry, I wasn't able to find information about that. Please reach out to support."
      }
    ],
    "chatSessionId": "12345"
  },
  "client": {
    "currentUrl": "https://example.com/help"
  }
}

About

Create tickets in Zendesk automatically when inkeep is unable to resolve the answer from your documentation.

Resources

Stars

Watchers

Forks