Create or Update Livechat Triggers

Post
/api/v1/livechat/triggers

Permission required: view-livechat-manager

See the Livechat Triggers guide for more information.

Header parameters
X-Auth-Token
stringRequired

The authToken of the authenticated user.

ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
X-User-Id
stringRequired

The userId of the authenticated user.

ExamplerbAXPnMktTFbNpwtJ
Body parameters
Example 1
{
  "name": "api-trigger",
  "description": "testing create trigger endpoint",
  "enabled": false,
  "runOnce": true,
  "conditions": [
    {
      "name": "chat-opened-by-visitor",
      "value": 0
    }
  ],
  "actions": [
    {
      "name": "send-message",
      "params": {
        "sender": "queue",
        "msg": "hello world"
      }
    }
  ]
}
Expand All
object
_id
string

If you want to update a trigger, enter the trigger ID.

Example65fa8f42482d68e364
name
string Required

Enter a name for the trigger.

Exampletest-trigger
description
string Required

Enter a description for the trigger.

ExampleTest trigger with the endpoint.
enabled
boolean Required

Whether the trigger is enabled for use or not.

Defaulttrue
runOnce
boolean Required

Whether the trigger will be run only once for each visitor.

Defaultfalse
conditions
Array of object Required

Enter the conditions for the trigger to execute.

object
name
string

The condition that should take place for the trigger to execute. The possible values are:

  • time-on-site: The amount of time a visitor is on the site.
  • page-url: The site URL that a visitor visits.
  • chat-opened-by-visitor: The chat is opened by the visitor.
  • after-guest-registration: The guest is registered to the chat.
value

Enter the value of the page-url (string) or the time-on-site, in seconds (number). Otherwise, you can enter null.

OneOf
number
number
string
string
actions
Array of object Required

The actions that take place once the trigger is executed.

object
name
string

The name of the trigger action that takes place. The possible values are:

  • send-message: A message is sent to the visitor.
  • use-external-service: An external service is used for the trigger action.
params
object

Enter the parameter values for the trigger action.

sender
string

The sender of the trigger action. The possible values are:

  • queue: Impersonate the next available agent in the queue.
  • custom: Use a specific agent or bot.
name
string

Enter the name of the agent or bot that you want to use, if the sender is custom.

msg
string

Enter a message for the visitor, if the action name is send-message.

serviceUrl
string

Enter the external service URL you want to use, if the action name is use-external-service.

Examplehttp://localhost:3000/api/vX
serviceTimeout
number

Enter the service timeout value, in seconds, if the action name is use-external-service.

Example5000
serviceFallbackMessage
string

Enter a message when the service is not accessible, if the action name is use-external-service.

ExampleWere sorry, we cannot complete your request
Responses
200

OK

Success
{
  "success": true
}
object
success
boolean
400

Bad Request

Example 1
{
  "success": false,
  "error": "must have required property 'description' [invalid-params]",
  "errorType": "invalid-params"
}
Example 2
{
  "success": false,
  "error": "must be equal to one of the allowed values [invalid-params]",
  "errorType": "invalid-params"
}
object
success
boolean
error
string
errorType
string
401

Unauthorized

Authorization Error
{
  "status": "error",
  "message": "You must be logged in to do this."
}
object
status
string
message
string
403

Forbidden

Permission Error
{
  "success": false,
  "error": "User does not have the permissions required for this action [error-unauthorized]"
}
Unauthorized
{
  "success": false,
  "error": "unauthorized"
}
object
success
boolean
error
string