Constructor
new TiledeskClient(options)
Constructor for TiledeskClient object
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | JSON configuration.
Properties
|
Example
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
const tdclient = new TiledeskClient({APIKEY: 'THE_API_KEY', projectId: 'YOUR_PROJECT_ID', token: 'YOUR_AUTH_TOKEN'});
const tdclient = new TiledeskClient({APIKEY: 'THE_API_KEY', projectId: 'YOUR_PROJECT_ID', token: 'YOUR_AUTH_TOKEN', APIURL: 'SELF_HOSTED_INSTANCE_ENDPOINT'});
Methods
addRequestParticipant(requestId, participantId, callback)
Add a participant to the request's participants.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID. |
participantId |
array | the participant (agent or bot) identifier |
callback |
resultCallback | The callback that handles the response. |
agent(requestId, depId, callback)
Moves the Request to an agent on the specific department.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID |
depId |
string | The new department ID |
callback |
resultCallback | The callback that handles the response. |
assign(requestId, email, fullname, options, callback)
Assign an agent to the specified department using the 'assing' method.
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID where applying the assignment |
email |
string | The department ID where applying the assignment |
fullname |
string | The new Lead fullname |
options |
assignOptions | The options. If null default options apply |
callback |
resultCallback | The callback that handles the response. |
changeBot(requestId, botId, callback)
Updates the Request removing the current chatbot (if any) and adding the new one. Then it sends the hidden 'start' message.
Orchestration APIs (Mashup of REST APIs)
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID |
botId |
string | The id of the bot to add in the conversation. |
callback |
resultCallback | The callback that handles the response. |
changeBotAndMessage(requestId, botId, message, callback)
Updates the Request removing the current chatbot (if any) and adding the new one. Then it sends the optional first message.
Orchestration APIs (Mashup of REST APIs)
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID |
botId |
string | The bot ID. |
message |
string | Optional. The first message to send as soon as the new bot is added to the conversation. This is used to trigger the greet message from the chatbot, if any is defined. |
callback |
resultCallback | The callback that handles the response. |
closeRequest(requestId, callback)
Closes the Request
REST API
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID |
callback |
resultCallback | The callback that handles the response. |
createBot(botName, isExternal, botUrl, callback)
Create a bot.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
botName |
string | The bot's name. |
isExternal |
boolean | 'true' if you want an external bot. |
botUrl |
string | The external bot's endpoint url. |
callback |
resultCallback | The callback that handles the response. |
createDepartment(name, routing, groupId, botId, callback)
Create a new department.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The department's name. |
routing |
boolean | (optional) The department routing type. Permitted values: 'assigned', 'pooled' (default). |
groupId |
string | (optional) The group of users assigned to the department. If not provided the request will be routed through all available users |
botId |
string | (optional) The bot assigned to the department, if any. |
callback |
resultCallback | The callback that handles the response. |
createIntent(botId, intent_display_name, question, answer, language, webhook_enabled, callback)
Create an Intent (aka Faq).
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
botId |
string | The botId. Mandatory |
intent_display_name |
string | Intent Display Name |
question |
string | The question |
answer |
string | The answer |
language |
string | The bot language |
webhook_enabled |
boolean | Is fulfillment enabled for this intent? |
callback |
resultCallback | The callback that handles the response. |
deleteBot(botId, callback)
Delete a bot by id.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
botId |
string | The bot ID. |
callback |
resultCallback | The callback that handles the response. |
deleteDepartment(depId, callback)
Delete a department by id.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
depId |
string | The department ID. |
callback |
resultCallback | The callback that handles the response. |
deleteRequestParticipant(requestId, participantId, callback)
Delete a participant from the request's participants.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID. |
participantId |
array | the participant (agent or bot) identifier |
callback |
resultCallback | The callback that handles the response. |
findBotByName(botName, callback)
Get the first bot with the specified name in the project.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
botName |
string | The bot name. |
callback |
resultCallback | The callback that handles the response. |
fireEvent(event, callback)
Fire a new custom event and save it.
With this endpoint you can fire a custom event. You event name should be of the form event.emit.EVENT_NAME to correctly identify your custom event.
You can find the standard Tiledesk events here
REST API
With this endpoint you can fire a custom event. You event name should be of the form event.emit.EVENT_NAME to correctly identify your custom event.
You can find the standard Tiledesk events here
REST API
Parameters:
Name | Type | Description |
---|---|---|
event |
string | |
callback |
resultCallback | The callback that handles the response. |
getAllBots(callback)
Get all the bots defined in the project.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
callback |
resultCallback | The callback that handles the response. |
getAllDepartments(callback)
Get all the deparments defined in the project.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
callback |
resultCallback | The callback that handles the response. |
getAllRequests(queryParams, callback, options)
Queries project's requests.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
queryParams |
queryParams | The query parameters. | |||||||||
callback |
resultCallback | The callback that handles the response. | |||||||||
options |
Object | Optional configuration.
Properties
|
getBot(botId, callback)
Get bot by id.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
botId |
string | The bot ID. |
callback |
resultCallback | The callback that handles the response. |
getDepartment(depId, callback)
Get a department by id.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
depId |
string | The department ID. |
callback |
resultCallback | The callback that handles the response. |
getDepartments(callback)
Get all the visible (aka active) departments defined in the project.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
callback |
resultCallback | The callback that handles the response. |
(async) getIntents(id_faq_kb, intent_display_name, page, limit, text, callback)
Get bot intents, filtered by parameters
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
id_faq_kb |
string | The bot's id. Mandatory. |
intent_display_name |
string | Filter by Intent Display Name. Optional |
page |
number | page number for pagination. Optional |
limit |
number | results per page. Optional |
text |
string | executes a full text search on this parameter. Optional |
callback |
resultCallback | The callback that handles the response. |
(async) getLeadById(leadId, callback)
Gets the Lead.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
leadId |
string | The Lead ID |
callback |
resultCallback | The callback that handles the response. |
(async) getProjectAvailableAgents(callback)
Returns the project's available agents
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
callback |
resultCallback | The callback that handles the response. |
getProjectSettings(callback)
Returns the project's JSON configuration
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
callback |
resultCallback | The callback that handles the response. |
getProjectUser(userId, callback)
Returns a project's User (aka Teammate, is a User invited on a project, with additional properties and a specific project-userId)
Parameters:
Name | Type | Description |
---|---|---|
userId |
string | The Teammate ID. It is the specific ID for this user on this project |
callback |
resultCallback | The callback that handles the response. |
(async) getRequestById(requestId, callback)
Gets a request by ID.
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID. |
callback |
resultCallback | The callback that handles the response. |
getTeam(callback)
Returns all teammates (aka Project Users, Tiledesk Users invited on a specific project are named "Teammates". They have additional properties and a specific project-userId)
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
callback |
resultCallback | The callback that handles the response. |
getWidgetSettings(callback)
Returns the Widget settings for the selected project.
Parameters:
Name | Type | Description |
---|---|---|
callback |
resultCallback | The callback that handles the response. |
moveToAgent(requestId, callback)
Moves the current conversation to an agent following the current request department rules. If no department is connected to the request it will move to the Default Department
REST API
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID |
callback |
resultCallback | The callback that handles the response. |
openNow(callback)
Returns the current opening status based on Opening Hours (aka Operating hours).
Parameters:
Name | Type | Description |
---|---|---|
callback |
resultCallback | The callback that handles the response. REST API |
removeCurrentBot(requestId, callback)
Updates the Request removing the current chatbot (if any).
Orchestration APIs (Mashup of REST APIs)
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID |
callback |
resultCallback | The callback that handles the response. |
replaceBotByName(requestId, botId, callback)
Updates the Request removing the current chatbot (if any) and adding the new one. Then it sends the hidden 'start' message.
Orchestration APIs (Mashup of REST APIs)
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID |
botId |
string | The id of the bot to add in the conversation. |
callback |
resultCallback | The callback that handles the response. |
sendChatMessage(message, callback)
Sends a message to a direct/group conversation.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
message |
chatMessage | The chat21's message JSON object. |
callback |
resultCallback | The callback that handles the response. |
(async) sendEmail(subject, body, to)
Send an email message
Parameters:
Name | Type | Description |
---|---|---|
subject |
string | The message subject |
body |
string | The message body |
to |
string | The recipient's email address. |
sendSupportMessage(requestId, message, callback)
Sends a message to a support conversation.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID. |
message |
chatMessage | The chat21's message JSON object. |
callback |
resultCallback | The callback that handles the response. |
updateBot(botName, isExternal, botUrl, callback)
Update a bot.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
botName |
string | The bot's name. |
isExternal |
boolean | 'true' if you want an external bot. |
botUrl |
string | The external bot's endpoint url. |
callback |
resultCallback | The callback that handles the response. |
updateDepartment(depId, name, routing, groupId, botId, callback)
Update a new department.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
depId |
string | The department's id. |
name |
string | The department's name. |
routing |
boolean | (optional) The department routing type. Permitted values: 'assigned', 'pooled' (default). |
groupId |
string | (optional) The group of users assigned to the department. If not provided the request will be routed through all available users |
botId |
string | (optional) The bot assigned to the department, if any. |
callback |
resultCallback | The callback that handles the response. |
updateLead(leadId, nativeAttributes, attributes, tags, callback)
Update Lead's data
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
leadId |
string | The Lead ID |
nativeAttributes |
string | native attributes: name, email, phone etc. |
attributes |
string | Lead custom attributes |
tags |
string | Lead tags |
callback |
resultCallback | The callback that handles the response. |
updateLeadData(leadId, email, fullname, attributes, callback)
DEPRECATED
Updates a Lead's email and fullname.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
leadId |
string | The Lead ID |
email |
string | Lead email update |
fullname |
string | Lead fullname to update |
attributes |
string | Lead attributes to update |
callback |
resultCallback | The callback that handles the response. |
updateProjectUser(projectUserId, properties, callback)
Updates the Teammate's (projectUser) by ProjectUser's ID. It requires admin role.
Parameters:
Name | Type | Description |
---|---|---|
projectUserId |
string | The teammate ID. |
properties |
Object | The properties to update. Only the provided properties will be updated, the other properties will stay unchanged. role {string} - The teammate role. Permitted values: 'admin', 'agent'. user_available {boolean} - The teammate availability. 'true' for available, 'false' for unavailable. max_served_chat {number} - The number of concurrent chats the teammate can take at once. attributes {Object} - The teammate custom attributes. settings {Object} - The teammate settings. |
callback |
resultCallback | The callback that handles the response. |
updateProjectUserAttributes(projectUserId, attributes, callback)
Only updates the attributes for the specified Teammate. It requires admin role.
Parameters:
Name | Type | Description |
---|---|---|
projectUserId |
string | The teammate ID. |
attributes |
Object | The teammate custom attributes. |
callback |
resultCallback | The callback that handles the response. |
updateProjectUserAvailable(projectUserId, userAvailable, callback)
Only updates the available status for the specified Teammate. It requires admin role.
Parameters:
Name | Type | Description |
---|---|---|
projectUserId |
string | The teammate ID. |
userAvailable |
boolean | The teammate availability. 'true' for available, 'false' for unavailable. |
callback |
resultCallback | The callback that handles the response. |
updateProjectUserCurrentlyLoggedIn(properties, callback)
Updates the authenticated Teammate's (projectUser). The teammate must be invited to the specified project for the update operation taking success.
REST API
REST API
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
properties |
Object | The properties to update. Only the provided properties will be updated, the other properties will stay unchanged.
Properties
|
||||||||||||||||||
callback |
resultCallback | The callback that handles the response. |
updateRequestAttributes(requestId, attributes, callback)
Updates request's 'attributes' property.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID |
attributes |
Object | The Request's custom attributes object. It's a payload that carries custom information attached to this request. |
callback |
resultCallback | The callback that handles the response. |
updateRequestDepartment(requestId, depId, options, callback)
Updates the Request department
REST API
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
requestId |
string | The request ID | ||||||
depId |
string | The new department ID | ||||||
options |
Object | Optional configuration.
Properties
|
||||||
callback |
resultCallback | The callback that handles the response. |
updateRequestParticipants(requestId, participants, callback)
Updates the request's participants.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID. |
participants |
array | the participants (agents or bots) identifiers array |
callback |
resultCallback | The callback that handles the response. |
(async) updateRequestProperties(requestId, properties, callback)
Updates request's properties.
REST API
REST API
Parameters:
Name | Type | Description |
---|---|---|
requestId |
string | The request ID |
properties |
requestProperties | The Request's properties |
callback |
resultCallback | The callback that handles the response. |
(static) anonymousAuthentication(projectId, apikey, options, callback)
Returns an anonymous user token to connect to a specific project's services.
REST API
REST API
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
projectId |
string | The projectId for this anonymous user. | |||||||||
apikey |
string | Your API key. | |||||||||
options |
Object | API call options.
Properties
|
|||||||||
callback |
resultCallback | The callback that handles the response. |
(static) authEmailPassword(projectId, apikey, options, callback)
Returns a Tiledesk token to connect to Tiledesk services.
https://developer.tiledesk.com/apis/rest-api/authentication#authentication-with-email-and-password
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
projectId |
resultCallback | The projectId for this anonymous user. | |||||||||
apikey |
string | Your API key. | |||||||||
options |
Object | API call options.
Properties
|
|||||||||
callback |
resultCallback | The callback that handles the response. |
(static) customAuthentication(token, apikey, options, callback)
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
token |
string | Your custom token. | |||||||||
apikey |
string | Your API key. | |||||||||
options |
Object | API call options.
Properties
|
|||||||||
callback |
resultCallback | The callback that handles the response. |
(static) newRequestId(projectId)
Returns a new request ID for the specified Project.
A request's ID has the format:
support-group-PROJECT_ID-UNIQUE_ID
UNIQUE_ID MUST be unique in your Project. This method always returns an UUID for the UNIQUE_ID component.
A request's ID has the format:
support-group-PROJECT_ID-UNIQUE_ID
UNIQUE_ID MUST be unique in your Project. This method always returns an UUID for the UNIQUE_ID component.
Parameters:
Name | Type | Description |
---|---|---|
projectId |
string | The project ID for the new request. |