Client SDK Reference
JavaScript/TypeScript SDK for integrating Helper into your applications
Client SDK Reference
The Helper Client SDK provides a comprehensive JavaScript/TypeScript library for integrating Helper's chat capabilities into your applications. It offers a clean, promise-based API for managing sessions, conversations, and real-time chat interactions.
Installation
bash npm install @helper/client
Setup
Basic Setup
Authenticating Users
If your app supports user authentication, generate an email hash.
- Store the HMAC secret in secure configuration such as environment variables.
- Use the HMAC-SHA256 algorithm on the server to generate a hexadecimal hash of
<email>:<timestamp>
, where<email>
is the logged in user's email address and<timestamp>
is the current time in milliseconds. - Pass the hash to the client constructor as the
emailHash
parameter, along with theemail
andtimestamp
values.
Session Parameters
The client constructor accepts the following parameters:
Parameter | Type | Required | Description |
---|---|---|---|
host | string | ✅ | The base URL of your Helper instance |
email | string | ❌ | The logged in user's email address |
emailHash | string | ❌ | Hashed email for secure authentication |
timestamp | number | ❌ | Timestamp for hash verification |
customerMetadata.name | string | ❌ | The customer's name to show in the Helper UI |
customerMetadata.value | number | ❌ | The customer's value on your platform (e.g. revenue) to be used for sorting |
customerMetadata.links | object | ❌ | Any links (e.g. to internal systems) to show in the Helper UI |
The client automatically handles session creation and token management. As long as you generate the initial
emailHash
, you don't need to manually manage authentication tokens.
API Reference
Client Properties
host
Type: string
(readonly)
The host URL of the Helper instance.
email
Type: string | null
Returns the email address associated with the current session, or null
if no email was provided.
Conversations API
conversations.list()
Retrieves all conversations for the current session.
Returns:
Example:
conversations.unread()
Retrieves the count of unread conversations for the current session.
Returns:
Example:
conversations.get(slug, options?)
Retrieves a specific conversation by its slug.
Parameters:
slug
(string): The unique identifier for the conversationoptions
(object, optional): Additional optionsmarkRead
(boolean, default:true
): Whether to mark the conversation as read
Returns:
Example:
conversations.create(params?)
Creates a new conversation.
Parameters:
Returns:
Example:
conversations.update(slug, params)
Updates an existing conversation.
Parameters:
slug
(string): The conversation identifierparams
(UpdateConversationParams): Update parameters
Returns:
Example:
conversations.listen(conversationSlug, callbacks)
Sets up real-time listeners for conversation events.
Parameters:
conversationSlug
(string): The conversation to listen tocallbacks
(object): Event callback functions
Returns: A cleanup function to stop listening.
Example:
Chat API
chat.handler(options)
Creates a chat handler for use with AI SDK compatible libraries.
Optionally you can pass a tools
object to allow the AI agent to perform actions on the customer's behalf.
Parameters:
Returns: A handler object compatible with AI SDK's useChat
hook.
Example:
chat.message(aiMessage)
Converts an AI SDK compatible message to Helper's message format.
Parameters:
aiMessage
(AIMessageCompat): Message from AI SDK
Returns: A Helper Message
object.
Example:
chat.messages(aiMessages)
Converts an array of AI SDK compatible messages to Helper's message format.
Parameters:
aiMessages
(AIMessageCompat[]): Array of messages from AI SDK
Returns: An array of Helper Message
objects.
Example:
Tools
Tools allow the AI agent to perform actions on behalf of the customer. There are two types:
Client-Side Tools (with execute()
)
Tools with an execute()
function run on the client side:
Server-Side Tools (with url
)
Tools with a url
property trigger HTTP POST requests to your endpoint:
For server-side tools, Helper sends the parameters, customer email and request timestamp (for HMAC verification) as a JSON body
Your endpoint must verify the HMAC signature in the Authorization
header to avoid unauthorized requests. To do this you should:
- Check the
requestTimestamp
is within the last 5 minutes. Note the timestamp is in seconds. - Compute a SHA256 HMAC of the JSON body using your
hmacSecret
from Helper settings. - Ensure the HMAC in the
Authorization
header matches the computed one.
If you are using the @helperai/client
package, you can import verifyHmac
from @helperai/client/auth
to verify the signature.
Your endpoint should then return a JSON object with a success
property and any additional information you want to return to the AI agent.
Sessions API
Session management is done automatically by the client. You shouldn't need to call this unless you want to make
fetch
requests manually.
sessions.create(params)
Creates a new session and returns authentication credentials.
Parameters:
Returns:
Example:
TypeScript Support
The Helper Client SDK is written in TypeScript and provides full type safety. All interfaces and types are exported for your use: