All plans have 30% OFF For this week

Claim Discount

API Reference: Hooks Endpoint

The Hooks endpoint in AnswerPal allows you to manage and automate actions triggered by specific events (called “hooks”) within the platform. Technically, hooks in AnswerPal are represented as “SpecialTopic” in the database and API. When you work with the Hooks endpoint, you are actually managing AP_TopicActions (for actions) and TopicDocuments (for documents) where the SpecialTopic field matches the hook’s name (for example, PreSpam, OnEscalate, etc.).

  • AP_TopicActions: Associates actions with specific hooks/events by setting SpecialTopic to the event name.
  • TopicDocuments: Associates documents with hooks/events by setting SpecialTopic to the event name.

This unified approach allows you to use the same endpoints and data structures for both topics and hooks/events, simply by specifying the hook name as the SpecialTopic.

Endpoint Overview

Base URL: https://api.answerpal.com/api/hookactions Authentication: Bearer token (JWT) required

Supported HTTP Methods:

  • GET /api/hookactions — List all HookActions (paginated, filter by hookName)
  • GET /api/hookactions/{id} — Get details for a specific HookAction
  • POST /api/hookactions — Create a new HookAction
  • PUT /api/hookactions/{id} — Update an existing HookAction (priority only)
  • DELETE /api/hookactions/{id} — Delete a HookAction
  • POST /api/hookactions/bulk — Bulk create HookActions
  • GET /api/hookactions/wait-seconds — Get total wait seconds for a hook/channel

Note: All API calls for hooks are performed by specifying the hookName parameter, which is internally mapped to the SpecialTopic field. For example, to retrieve or manage actions for the PreSpam hook, you would use hookName=PreSpam in your API requests.

Data Models

HookActionReadDTO (Response)

Returned when you retrieve a HookAction (GET). Contains all properties of the hook-triggered action.
Property Type Required Description Example
hookActionID int Yes Unique identifier for the HookAction. 101
hookName string Yes Name of the hook/event this action is attached to (e.g., OnEscalate, OnPhonePickup). This is the value of the SpecialTopic field in the database. “OnEscalate”
actionID int Yes Reference to the Action definition (see Actions endpoint). 123
actionName string Yes Name of the linked action for clarity. “Auto-Reply”
channelName string? No Name of the channel (if applicable). “Support Email”
priority int Yes Priority for execution (higher runs first). 10

HookActionCreateDTO (Create Request)

Used when creating a new HookAction (POST).
Property Type Required Description Example
hookName string Yes Name of the hook/event to attach this action to. This is stored as SpecialTopic in the backend. “OnEscalate”
actionID int Yes Reference to the Action to execute. 123
channelID int? No Channel ID to restrict to a specific channel. 1
specialChannel string? No Restrict to special channel type (“Email”, “Chat”, “Phone”, “WhatsApp”, “All”). “Email”
priority int Yes Priority for execution (higher runs first). 10

HookActionUpdateDTO (Update Request)

Used when updating an existing HookAction (PUT).
Property Type Required Description Example
priority int Yes New priority value only. 20

PaginatedResult

Returned when listing HookActions.
Property Type Description
items HookActionReadDTO[] List of HookActionReadDTO objects.
totalCount int Total number of HookActions found.
totalPages int Total number of result pages (if paginated).

TopicDocuments for Hooks

To retrieve documents associated with a hook/event, use the TopicDocuments endpoint with the hookName parameter. This is internally mapped to SpecialTopic in the database, so only documents linked to that hook/event will be returned.

Request and Response Examples

List All HookActions for PreSpam

GET /api/hookactions?hookName=PreSpam&pageNumber=1&pageSize=10 Response:
{

"items": [

{

"hookActionID": 201,

"hookName": "PreSpam",

"actionID": 301,

"actionName": "Spam Filter",

"channelName": "Support Email",

"priority": 100

}

],

"totalCount": 1,

"totalPages": 1

}

Create HookAction

POST /api/hookactions
{

"hookName": "OnEscalate",

"actionID": 123,

"channelID": 1,

"priority": 10

}
Response:
{

"hookActionID": 101,

"hookName": "OnEscalate",

"actionID": 123,

"actionName": "Auto-Reply",

"channelName": "Support Email",

"priority": 10

}

Update Priority

PUT /api/hookactions/101
{

"priority": 20

}
Response: 204 No Content

Delete HookAction

DELETE /api/hookactions/101 Response: 204 No Content

Bulk Create HookActions

POST /api/hookactions/bulk
[

{

"hookName": "OnEscalate",

"actionID": 123,

"priority": 10

},

{

"hookName": "OnPhonePickup",

"actionID": 124,

"priority": 15

}

]
Response:
[

{

"hookActionID": 101,

"hookName": "OnEscalate",

"actionID": 123,

"actionName": "Auto-Reply",

"priority": 10

},

{

"hookActionID": 102,

"hookName": "OnPhonePickup",

"actionID": 124,

"actionName": "Notify Rep",

"priority": 15

}

]

Retrieve Documents for OnEscalate Hook

GET /api/topicdocuments?hookName=OnEscalate Response:
[

{

"documentID": 501,

"name": "Escalation Instructions",

"content": "Please provide additional details for escalation...",

"isDataRetrievalProcess": false

}

]

FAQ & Best Practices

A Hook is a named event in AnswerPal’s workflow (like OnEscalate, OnPhonePickup, etc.) that can trigger one or more actions automatically.

Higher priority values execute first when multiple actions are attached to the same hook.

Yes, use the channelID or specialChannel property in the create request.

No, only the priority can be updated after creation. To change other properties, delete and recreate the HookAction.

In AnswerPal, hooks and events are stored as “SpecialTopic” in the database. When you use the Hooks endpoint, you’re actually working with TopicActions and TopicDocuments where the SpecialTopic field matches your hook/event name (e.g., “PreSpam”, “OnEscalate”, etc.). This allows for a unified, flexible approach to managing both topic-based and event-based automation.

Table of Contents

AnswerPal: AI-powered customer service solutions to elevate your support and communication effortlessly.

Contact

For all support, sales, and partnership inquiries, email us at info@answerpal.eu