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
If you'd like to add an API route to an existing Next.js project:
- Copy the files under
api/create-support-ticket
into your own API route. - Install deps via
pnpm add @vercel/edge-config zod
- 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
Usually you have a specific subdomain such as https://<your-company-name>.zendesk.com/
API Tokens can only be created from within the Admin Center
If you don't see "Add API token" be sure to enable Token access via the toggle switch.
8. Make sure to copy and store this token. It won't be shown again after you click Save or leave this page.
10. Set the environment variable on your deployed Vercel function ZENDESK_API_TOKEN to the value you have just copied.
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.
npm dev
/api/create-support-ticket
- Create a new ticket in your inbox.
See the Zendesk Tickets API for full customization.
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"
}
}