Clone this repository:
git clone https://github.com/inkeep/helpscout-ticket-creation-vercel
Setup dependencies:
pnpm 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
-
Login to HelpScout
-
Open your profile picture then select Your Profile.
-
Click on the My Apps tab.
-
Click on Create My App
-
Provide an App Name, like "Inkeep Create Ticket Flow"
-
Provide any value for Redirection URL, like "https://{mydoamin}.com", it's not used.
-
Copy the App ID and App Secret fields into your env variables
HELPSCOUT_APP_ID="<HELPSCOUT_APP_ID>"
HELPSCOUT_APP_SECRET="<HELPSCOUT_APP_SECRET>"
-
Open Inbox tab on HelpScout
-
On left bottom corner open click on the Gear Icon and select Edit Inbox
-
Copy the ID from the page URL:
https://secure.helpscout.net/settings/inbox/<HELPSCOUT_MAILBOX_ID>/
Add it as an env variable:
HELPSCOUT_MAILBOX_ID="<HELPSCOUT_MAILBOX_ID>"
HelpScout access tokens received via client-credentials (service-to-service authentication) expire after two days. To avoid fetching a new access token on every request, we'll use Vercel's Edge Config to cache the latest access token, which is optimized for scenarios with high read and low write operations.
Create an Edge Config Store instance for your project. See here.
Once created, copy the ID
of the Edge Config Store and add it as an env variable:
EDGE_CONFIG_ID="<EDGE_CONFIG_ID>"
Creating an Edge Config Store will also automatically create an EDGE_CONFIG
env variable in your Vercel project. This is used for reading from the Store using the @vercel/edge-config
SDK.
For local development, you can visit your project's Settings > Environment Variables and copy it.
Set it as an env variable:
EDGE_CONFIG="<EDGE_CONFIG>"
Next, create a Vercel API access token. See here. This is used to write to the Edge Config. Set the scope to the Vercel team you'd like it to apply to.
Add it as env variable:
VER_API_ACCESS_TOKEN="<VER_API_ACCESS_TOKEN>"
Lastly, set the Vercel Team ID for where your project is located. You can find this under Settings under your Team in the Vercel dashboard
VER_TEAM_ID="<VER_TEAM_ID>"
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.
pnpm dev
/api/create-support-ticket
- Create a new conversation/ticket in your inbox.
See the HelpScout Create Conversation 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"
}
}