loader
Table of Contents

SETUP AND USAGE

The Web API supplies a collection of HTTP methods that underpin the majority of smartai Support functionality. To start using the Web API follow the tutorial below.

USAGE

Make a POST call to the file include/api.php of your smartai Support installation. You can use the following code to make the calls:

PHP

function support_board_api($query) {
    $ch = curl_init('YOUR-DOMAIN/supportboard/include/api.php');
    $parameters = [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_USERAGENT => 'Support Board',
            CURLOPT_POST => true,
            CURLOPT_CONNECTTIMEOUT => 5,
            CURLOPT_POSTFIELDS => http_build_query(array_merge(['token' => 'YOUR-TOKEN'], $query))
    ];
    curl_setopt_array($ch, $parameters); 
    $response = curl_exec($ch);
    curl_close($ch);
    return json_decode($response, true);
}

JQUERY

$.post('YOUR-DOMAIN/supportboard/include/api.php', {
    function: 'METHOD-NAME',
    token: 'YOUR-TOKEN'
}, function (response) {
    response = JSON.parse(response);
    if (response.success) {
    }
});

Usage example: support_board_api([‘function’ => ‘get-user’, ‘user_id’ => 123]).

The variable $response will contains the JSON response. You can add new arguments in the query array: [‘token’ => ”, ‘function’ => ”, ‘argument-name’ => ‘value’, …].

Replace the following strings with the correct values:

  • Replace YOUR-DOMAIN with the URL of your website. The full URL must point to the file include/api.php of your smartai Support installation. It should looks like this: https://YOUR-DOMAIN.com/supportboard/include/api.php.
    If you’re using the WordPress version enter https://YOUR-DOMAIN.com/wp-content/plugins/supportboard/supportboard/include/api.php.
    If you’re using the SAAS or Reseller version enter https://YOUR-DOMAIN/script/include/api.php.
    If you’re using the cloud version enter https://cloud.smartai.support/script/include/api.php.
  • Replace YOUR-TOKEN with the token of an admin user. You can get the token from the Users area by opening the profile box of an admin user. Only admin tokens are supported and only the admins can view the tokens. If you’re using the cloud version you have to use the token from Account > Installation > API token. Warning! This token must be kept always secret.
  • Replace METHOD-NAME with the name of the API function you want to use. Get them from the methods list below.
Information #
  • Some functions are protected for security reasons, enter the code $GLOBALS[‘SB_FORCE_ADMIN’] = true before calling the function to execute it correctly. Enter the code $GLOBALS[‘SB_FORCE_ADMIN’] = false immedidately after the function call for security reasons.
  • Some functions require the user details of the active user, use the code $GLOBALS[‘SB_LOGIN’] = [‘id’ => ”, ‘first_name’ => ”, ‘last_name’ => ”, ’email’ => ”, ‘user_type’ => ”, ‘department’ => ”]; to set the active user.
  • Postman example: 
WEBAPI #

get-user

Returns the user details of a user.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-user.
user_id  RequiredThe ID of the user.
extraSet it to true to get the additional user details. Default: false.

Response

{
    "success": true,
    "response": {
        "id": "123456",
        "first_name": "John",
        "last_name": "Doe",
        "email": "johon@example.com",
        "profile_image": "https://smartai.support/user.svg",
        "user_type": "visitor",
        "creation_time": "2023-10-12 14:28:57",
        "last_activity": "2023-10-12 14:28:57",
        "department": null,
        "token": "a521773c5a566a251c3fb00e93162b20ff955b12",
        "password": "",
        "details": [
            {
                "slug": "location",
                "name": "Location",
                "value": "New York, United States"
            },
            {
                "slug": "country_code",
                "name": "Country code",
                "value": "America/New_York"
            }
            ...
        ]
    }
}

Returns {“success”:true, “response”:false} if the user is not found.


get_user_by

Searches for a user with the specified user details and returns it.

by  RequiredThe user detail name. Accepted values: email, first_name, last_name, phone, [extra] (replace [extra] with any user additional detail name).
valueThe value of the field.

Response

{
    "id": "881",
    "first_name": "Don",
    "last_name": "John",
    "email": "example@example.com",
    "user_type": "visitor",
    "department": null
 }

Returns {“success”:true, “response”:false} if the user is not found.


get_user_extra

Returns the additional details of a user.

token  RequiredYour admin secret token.
function  RequiredEnter get-user-extra.
user_id  RequiredThe ID of the user.
slugThe slug of the setting to retrieve. If this argument is not set, all user details are returned. Default: false.
defaultThe default value to return if the user details are not found. Default: false.

Response

{
    "success": true,
    "response": [
        {
            "slug": "browser",
            "name": "Browser",
            "value": "Chrome"
        },
        {
            "slug": "current_url",
            "name": "Current URL",
            "value": "https://smartai.support/"
        },
        {
            "slug": "os",
            "name": "OS",
            "value": "Windows 10"
        },
        {
            "slug": "phone",
            "name": "Phone",
            "value": "3203057977"
        }
        ...
    ]
}

Returns {“success”:true, “response”:[]} if the user is not found.


get_user_language

Returns the active language code used by the user. By default, it’s the user browser language.

Arguments

user_id Required            The ID of the user from whom you want to get the language.

Response

The language code. Examples: es, it. Returns false if the language code is en or not found.


get_users

Returns the user details of all the users.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-users.
sortingSet the order of the returned values. Enter [“column”, “order”] and replace column with one of the following values: first_name, last_name, email, profile_image, user_type, creation_time, last_activity, department. Replace order with ASC or DESC.
user_typesArray in JSON format of user types to include in the return value. Array syntax: [“”, “”, “”, …]. Accepted values: visitor, lead, user, agent, admin. Default: all.
searchThe string to search.
paginationInteger from 1 to N to limit the results number. Enter 0 to get the first 100 results, 1 for the results from 101 to 200, etc.
extraSet it to true to include all users extra details as well. Set it as an array of user extra detail slugs to include only a subset of extra details. Default: false.
user_idsArray of IDs. If set, returns only the users with ID included in the given array of IDs. Array syntax: [“”, “”, “”, …]. Default: false.

Arguments

{
    "success": true,
    "response": [
        {
            "id": "880",
            "first_name": "User",
            "last_name": "#29938",
            "email": null,
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "visitor",
            "creation_time": "2020-05-13 08:58:18",
            "last_activity": "2020-05-13 09:07:39",
            "department": null,
            "token": "6d969f64f5ed6263714b9b39f3d3700b66f16820"
        },
        {
            "id": "879",
            "first_name": "User",
            "last_name": "#86773",
            "email": null,
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "visitor",
            "creation_time": "2020-05-13 08:38:41",
            "last_activity": "2020-05-13 08:58:12",
            "department": null,
            "token": "2e5064670707d06b661d04353f4a462ec927f19a"
        }
        ...
    ]
}

get-new-users

Returns the users created after the given date/ID.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-new-users.
datetime  RequiredUser ID or date and time in the following format: YYYY-MM-DD HH:MM:SS. E.g. 2020-05-13 13:35:59. You can remove the time and leave only the date. The dates stored in the database are in UTC+0.

Response

{
    "success": true,
    "response": [
        {
            "id": "880",
            "first_name": "User",
            "last_name": "#29938",
            "email": null,
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "visitor",
            "creation_time": "2020-05-13 08:58:18",
            "last_activity": "2020-05-13 09:07:39",
            "department": null,
            "token": "6d969f64f5ed6263714b9b39f3d3700b66f16820"
        },
        {
            "id": "879",
            "first_name": "User",
            "last_name": "#86773",
            "email": null,
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "visitor",
            "creation_time": "2020-05-13 08:38:41",
            "last_activity": "2020-05-13 08:58:12",
            "department": null,
            "token": "2e5064670707d06b661d04353f4a462ec927f19a"
        }
        ...
    ]
}

get-online-users
Returns the online users including Agents.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-online-users.
exclude_idArray of users IDs in JSON format to exclude from the returned values. Array syntax: [123, 123, 123, …]
sortingThe name of the database table used for sorting. Default: creation_time.
agentsSet it to true to return only agents and admins. Default: false.

Response

{
    "success": true,
    "response": [
        {
            "id": "881",
            "first_name": "Don",
            "last_name": "John",
            "email": null,
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "visitor",
            "creation_time": "2020-05-13 09:18:59",
            "last_activity": "2020-05-13 09:32:34",
            "department": null,
            "token": "e435a5c67f4276cdb9c6fc19b7c015990ffc3268"
        },
        {
            "id": "880",
            "first_name": "User",
            "last_name": "#29938",
            "email": null,
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "visitor",
            "creation_time": "2020-05-13 08:58:18",
            "last_activity": "2020-05-13 09:32:28",
            "department": null,
            "token": "6d969f64f5ed6263714b9b39f3d3700b66f16820"
        }
        ...
    ]
}

get-users-with-details
Returns an array with the user IDs and details of the users who have the requested details.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-users-with-details.
details  RequiredArray of user details. E.g. [ “email”, “phone” ].
user_idsArray, or comma-separated string of user IDs. If this argument is set only the users which have their ID included are returned. Set it to all or false to search all users, set it to agents to search only agents and admins. Default: false.

Response

{
    "email": [
        {
            "id": 4561,
            "value": "albert@example.com"
        },
        {
            "id": 98436,
            "value": "jessica@example.com"
        },
        ...
    ],
    "phone": [
        {
            "id": 12563,
            "value": "+4462367136"
        },
        {
            "id": 778956,
            "value": "+4462999345"
        },
        ...
    ],
    ...
} 

get-agent
Returns the details of an agent or admin.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-agent.
agent_id  RequiredThe agent ID.

Response

{
   "success": true,
   "response": {
       "id": "123456",
       "first_name": "John",
       "last_name": "Doe",
       "email": "johon@example.com",
       "profile_image": "https://smartai.support/user.svg",
       "user_type": "agent",
       "creation_time": "2020-05-12 14:28:57",
       "last_activity": "2020-05-12 14:28:57",
       "department": null,
       "token": "a521773c5a566a251c3fb00e93162b20ff955b12",
       "password": "",
       "details": [
           {
               "slug": "location",
               "name": "Location",
               "value": "New York, United States"
           },
           {
               "slug": "country_code",
               "name": "Country code",
               "value": "America/New_York"
           }
           ...
       ]
   }
     

get-agents-ids
Returns an array with the IDs of Agents.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-agents-ids.
adminsSet it to false to exclude the admins. Default: true;

Response

[
    881,
    153,
    ...
]

get-user-from-conversation
Returns the user ID and email of the user, or last agent, of the given conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-user-from-conversation.
conversation_id  RequiredThe conversation ID.
agentSet it to true to get the last agent who replied to the conversation. Default: false.

Response

{
  "id": "123456",
  "email": "email@example.com"
}

agents-online
Checks if at least one agent or admin is online.

Response

{
    "success": true,
    "response": true
}

Return true if there are agents or admin online, or false if all Agents are offline.

search-users
Returns the users matching the search.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter search-users.
search  RequiredThe string to search. The additional user details are supported too.

Response

{
    "success": true,
    "response": [
        {
            "id": "881",
            "first_name": "Don",
            "last_name": "John",
            "email": null,
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "visitor",
            "creation_time": "2020-05-13 09:18:59",
            "last_activity": "2020-05-13 09:32:34",
            "department": null,
            "token": "e435a5c67f4276cdb9c6fc19b7c015990ffc3268"
        },
        {
            "id": "880",
            "first_name": "User",
            "last_name": "#29938",
            "email": null,
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "visitor",
            "creation_time": "2020-05-13 08:58:18",
            "last_activity": "2020-05-13 09:32:28",
            "department": null,
            "token": "6d969f64f5ed6263714b9b39f3d3700b66f16820"
        }
        ...
    ]
}

Returns {“success”:true, “response”:[]} if no users are found.

add-user
Create a new user.

Arguments

token required Your admin secret token.
function required Enter add-user.
first name The first name of the user. Default: User
last name The last name of the user. Default: #RANDOM-NUMBER
email The profile picture of the user. Default
profile image The profile picture of the user. Default
passwordThe password of the user. Default: empty.
user_typeThe user type of the user. Accepted values: visitor, lead, user, agent, admin. Default: visitor if the email is not provided, otherwise user.
extraArray of additional user details in JSON format. Any detail is accepted. Built-in details (IDs): phone, city, language, country, birthday, company, facebook, twitter, linkedin, website, ip, country_code, browser, currency, location, os, time_zone, current_url.
Array syntax: {“ID”: [“value”, “Name”], “ID”: [“value”, “Name”], …}

Response

{
    "success": true,
    "response": 123456
}

Other possible responses: ID of the new user on success, otherwise duplicate-email, invalid-user-type, MySQL error message

update-user
Updates the details of an existing user.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter update-user.
user_id  RequiredThe ID of the user to update.
first_nameThe first name of the user.
last_nameThe last name of the user.
emailThe email of the user. Enter NULL to delete the email.
profile_imageThe profile picture of the user.
passwordThe password of the user.
user_typeThe user type of the user. Accepted values: visitor, lead, user, agent, admin.
settings_extraArray of additional user details in JSON format.   Array syntax:  {“ID”: [“value”, “Name”], “ID”: [“value”, “Name”], …}

Response

{
    "success": true,
    "response": true
}

Other possible responses: duplicate-email, invalid-user-type, MySQL error message.

delete-user
Deletes a user and all linked conversations and messages.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter delete-user.
user_id  RequiredThe ID of the user to delete.

Response

{
    "success": true,
    "response": true
}

delete-users
Deletes multiple users and all linked conversations and messages.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter delete-users.
user_ids  RequiredArray of IDs of the users to delete. Array syntax: [123, 123, 123, …]

Response

{
    "success": true,
    "response": true
}

is-online
Checks if a user is online.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter is-online.
user_id  RequiredThe ID of the user.

Response

true if online, false if offline.

current-url
Gets or sets the current URL of a user or the last visited URL.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter current-url.
user_idThe ID of the user
urlThe URL to set as “Current URL”. If this argument is set the function will only set the value and it will not return any URL.

Response

{
    "success": true,
    "response": "https://smartai.support"
}

Returns {“success”:true,”response”:false} if the URL is not found. Returns {“success”:true,”response”:true} if the url argument is set.

count-users
Returns the total users’ count grouped by user type.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter count-users.

Response

{
    "success": true,
    "response": {
        "all": "335",
        "lead": "288",
        "user": "15",
        "visitor": "28"
    }
}

update-user-to-lead
Changes the user type to lead.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter update-user-to-lead.
user_id  RequiredThe ID of the user.

Response

{
    "success": true,
    "response": true
}

get-avatar
Generates the user profile image by using the first letter of first name, and last name, saves the image, and returns the image URL.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-avatar.
first_name  RequiredThe first name of the user.
last_nameThe last name of the user.

Response

https://example.com/supportboard/uploads/13-04-21/9455859.png

get-bot-id
Returns the Support Board bot ID.

Response

123

is-typing
Checks if a user or agent is typing a message in a conversation. This function will not work if Pusher is active.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter is-typing
user_id  RequiredThe ID of the user, or the agent, to check.
conversation_id  RequiredThe ID of conversation to check

Response

Returns true if the user is typing, otherwise, returns false

is-agent-typing
Checks if an agent is typing a message in a conversation, and returns the agent details. This function will not work if Pusher is active.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter is-agent-typing
conversation_id  RequiredThe ID of conversation to check.

Response

{
  "id": "",
  "first_name": "",
  "last_name": ""
}

Returns false if no agents are typing.

set-typing
Assigns the typing status to a user or agent relative to a conversation.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter set-typing
user_id  RequiredThe ID of the user, or the agent.
conversation_id  RequiredThe ID of the conversation.

Response

{
    "success": true,
    "response": true
}

login
Logins a user or agent. A user can log in in two ways: via email and password, or via user ID and token.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter login
emailThe email of the user to login. If this attribute is set you need to set also the password. Default: empty.
passwordThe password of the user to login. If this attribute is set you need to set also the email. Default: empty.
user_idThe ID of the user to login. If this attribute is set you need to set also the token. Default: empty.
tokenThe token of the user to login. If this attribute is set you need to set also the user ID. You can get the token from the Users area by opening the profile box of a user. Default: empty.

Response

{
    "success": true,
    "response": [
        {
            "id": "913",
            "profile_image": "https://smartai.support/user.svg",
            "first_name": "User",
            "last_name": "#29902",
            "email": null,
            "user_type": "visitor",
            "token": "9b25351047ee758aa97ee4868d130cc15eb8decf"
        },
        "YXNkWGNSeTdtRTdDYVkxVG8wckN4YWF6V2s0Tk1mczBSVHdQbHBpOWdmejVUTTdOUUxEUENhdUVoYmROWn..."
    ]
}

The last value is the encrypted login data ready to be stored in the sb-login cookie. Use the function SBF.loginCookie(response[1]); to store it. Returns false if login is unsuccessful.

logout
Logouts the logged-in user.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter logout.

Response

{
    "success": true,
    "response": true
}

The sb-login cookie must also be deleted from the user’s browser.

update-login
Updates the user details of the logged-in user. This function update all the user details, if a detail is not set it will be deleted from the database.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter update-login.
profile_imageThe profile image URL of the user. Default: empty.
first_nameThe first name of the user. Default: empty.
last_nameThe last name of the user. Default: empty.
emailThe email of the user. Default: empty.
departmentUpdate the department of the user. This setting is used in the admin area. Default: empty.

Response

YXNkWGNSeTdtRTdDYVkxVG8wckN4YWF6V2s0Tk1mczBSVHdQbHBpOWdmejVUTTdOUUxEUENhdUVoYmROWn…

The response must be saved into the sb-login cookie of the user’s browser.

delete-leads
Deletes all leads, including all the linked conversations and messages.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter delete-leads

Response

{
    "success": true,
    "response": true
}

update-bot
Updates the profile details of the bot. If the chatbot is not found a new chatbot profile is created.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter update-bot.
nameThe bot name.
profile_imageThe bot profile image URL.

Response

{
    "success": true,
    "response": true
}

Returns true on success, false otherwise.

csv-users
Exports all the users in a CSV file and returns the URL.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter csv-users.
user_idsArray of user IDs. If set, returns only users with the specified user IDs. Defaults: false.

Response

{
    "success": true,
    "response": "https://smartai.support/uploads/users.csv"
}

Conversations
Methods to manage conversations and messages.

get-conversation
Returns a conversation and the messages of the conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-conversation.
conversation_id  RequiredThe ID of the conversation.
user_idThe ID of the user linked to the conversation.

Response

{
    "success": true,
    "response": {
        "messages": [
            {
                "id": "2044",
                "user_id": "802",
                "message": "Hello!",
                "creation_time": "2020-05-0410:06:30",
                "attachments": "",
                "status_code": "0",
                "payload": "",
                "conversation_id": "946",
                "first_name": "Don",
                "last_name": "John",
                "profile_image": "https://smartai.support/user.svg",
                "user_type": "lead"
            },
            {
                "id": "2045",
                "user_id": "377",
                "message": "Hello,howcanIhelp?",
                "creation_time": "2020-05-0410:06:33",
                "attachments": "",
                "status_code": "0",
                "payload": "",
                "conversation_id": "946",
                "first_name": "Bruce",
                "last_name": "Peterson",
                "profile_image": "https://smartai.support/agent.svg",
                "user_type": "agent"
            }
            ...
        ],
        "details": {
            "user_id": "802",
            "first_name": "Don",
            "last_name": "John",
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "lead",
            "id": "946",
            "title": "",
            "conversation_time": "2020-05-0410:06:30",
            "conversation_status_code": "3",
            "department": null
        }
    }
}

Return {“success”:true,”response”:{“messages”:[],”details”:””}} if the conversation is not found.

get-conversations
Returns all the conversations. Each conversation includes the last message of the conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-conversations.
paginationInteger from 1 to N to limit the results number. Enter 0 to get the first 100 results, 1 for the results from 101 to 200, etc.
status_codeThe status code of the returned conversations. Default: all the conversations in the inbox, excluding the conversations in the trash and archive. Status codes: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4, all = includes all status codes.
routingSet it to true if the queue or routing is active in Settings > Miscellaneous. Default: false.
routing_unassignedSet it to true to also view the conversations not assigned to any agent. Default: false.
departmentReturns only the conversations assigned to the provided department ID.
sourceReturns only the conversations created from the provided source. Available sources: em (Email), tk (Ticket), wa (WhatsApp), fb (Facebook Messenger), ig (Instagram), tw (Twitter), wc (WeChat), tx (Text message), gb (Google Business Messages), tg (Telegram), ln (LINE) vb (Viber).
tagReturns only the conversations with the specified tag.

Response

{
    "success": true,
    "response": [
        {
            "message": "Hello World!",
            "message_id": "7351",
            "attachments": "",
            "payload": "",
            "message_status_code": "2",
            "last_update_time": "2023-10-02 16:00:06",
            "message_user_id": "377",
            "message_first_name": "Smart Assistant",
            "message_last_name": "",
            "message_profile_image": "https://example.com/image.jpg",
            "message_user_type": "bot",
            "conversation_id": "4084",
            "conversation_user_id": "4446",
            "conversation_status_code": "3",
            "conversation_creation_time": "2023-10-02 15:59:59",
            "department": "1",
            "agent_id": null,
            "title": "",
            "source": "tk",
            "extra": null,
            "tags": null,
            "conversation_first_name": "User",
            "conversation_last_name": "#26147",
            "conversation_profile_image": "https://example.com/image.jpg",
            "conversation_user_type": "lead"
        },
        ...
    ]
}

get-new-conversations
Returns the conversations created after the given date/ID or with a message created after the given date/ID. Each conversation includes the last message of the conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-new-conversations.
datetime  RequiredConversation ID or date and time in the following format: YYYY-MM-DD HH:MM:SS. E.g. 2020-05-13 13:35:59. You can remove the time and leave only the date. The dates stored in the database are in UTC+0.
routingSet it to true if the queue or routing is active in Settings > Miscellaneous. Default: false.
routing_unassignedSet it to true to also view the conversations not assigned to any agent. Default: false.

Response

{
    "success": true,
    "response": [
        {
            "message": "Hello World!",
            "message_id": "7351",
            "attachments": "",
            "payload": "",
            "message_status_code": "2",
            "last_update_time": "2023-10-02 16:00:06",
            "message_user_id": "377",
            "message_first_name": "Smart Assistant",
            "message_last_name": "",
            "message_profile_image": "https://example.com/image.jpg",
            "message_user_type": "bot",
            "conversation_id": "4084",
            "conversation_user_id": "4446",
            "conversation_status_code": "3",
            "conversation_creation_time": "2023-10-02 15:59:59",
            "department": "1",
            "agent_id": null,
            "title": "",
            "source": "tk",
            "extra": null,
            "tags": null,
            "conversation_first_name": "User",
            "conversation_last_name": "#26147",
            "conversation_profile_image": "https://example.com/image.jpg",
            "conversation_user_type": "lead"
        },
        ...
    ]
}

Return {“success”:true, “response”:[]} if no conversations are found.

get-user-conversations
Returns the conversations of a user. Each conversation includes the last message of the conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-user-conversations.
user_id  RequiredThe ID of the user.
exclude_idExclude a conversation from the results.
agentsSet it to true if the user is an agent or admin. Default: false.

Response

{
    "success": true,
    "response": [
        {
            "message": "Hello World!",
            "message_id": "7351",
            "attachments": "",
            "payload": "",
            "message_status_code": "2",
            "last_update_time": "2023-10-02 16:00:06",
            "message_user_id": "377",
            "message_first_name": "Smart Assistant",
            "message_last_name": "",
            "message_profile_image": "https://example.com/image.jpg",
            "message_user_type": "bot",
            "conversation_id": "4084",
            "conversation_user_id": "4446",
            "conversation_status_code": "3",
            "conversation_creation_time": "2023-10-02 15:59:59",
            "department": "1",
            "agent_id": null,
            "title": "",
            "source": "tk",
            "extra": null,
            "tags": null
        },
        ...
    ]
}

Return {“success”:true, “response”:[]} if no conversations are found.

get-new-user-conversations
Returns the user conversations created after the given date/ID or with a message created after the given date/ID. Each conversation includes the last message of the conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-new-user-conversations.
user_id  RequiredThe ID of the user.
datetime  RequiredConversation ID or date and time in the following format: YYYY-MM-DD HH:MM:SS. E.g. 2020-05-13 13:35:59. You can remove the time and leave only the date. The dates stored in the database are in UTC+0.

Response

{
    "success": true,
    "response": [
       {
            "message": "Hello World!",
            "message_id": "7351",
            "attachments": "",
            "payload": "",
            "message_status_code": "2",
            "last_update_time": "2023-10-02 16:00:06",
            "message_user_id": "377",
            "message_first_name": "Smart Assistant",
            "message_last_name": "",
            "message_profile_image": "https://example.com/image.jpg",
            "message_user_type": "bot",
            "conversation_id": "4084",
            "conversation_user_id": "4446",
            "conversation_status_code": "3",
            "conversation_creation_time": "2023-10-02 15:59:59",
            "department": "1",
            "agent_id": null,
            "title": "",
            "source": "tk",
            "extra": null,
            "tags": null
        },
        ...
    ]
}

Return {“success”:true, “response”:[]} if no conversations are found.

search-conversations
Returns the conversations matching the search.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter search-conversations.
search  RequiredThe string to search. The search function is capable of searching through attachment names, messages, user email, first name, and last name, tags, agent ID, department ID, conversation title and more.

Response

{
  "success": true,
  "response": [
        {
            "message": "Hello World!",
            "message_id": "7351",
            "attachments": "",
            "payload": "",
            "message_status_code": "2",
            "last_update_time": "2023-10-02 16:00:06",
            "message_user_id": "377",
            "message_first_name": "Smart Assistant",
            "message_last_name": "",
            "message_profile_image": "https://example.com/image.jpg",
            "message_user_type": "bot",
            "conversation_id": "4084",
            "conversation_user_id": "4446",
            "conversation_status_code": "3",
            "conversation_creation_time": "2023-10-02 15:59:59",
            "department": "1",
            "agent_id": null,
            "title": "",
            "source": "tk",
            "extra": null,
            "tags": null,
            "conversation_first_name": "User",
            "conversation_last_name": "#26147",
            "conversation_profile_image": "https://example.com/image.jpg",
            "conversation_user_type": "lead"
        },
        ...
  ]
}

Return {“success”:true, “response”:[]} if no conversations are found.

search-user-conversations
Returns the conversations of the given user ID that matches the search terms.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter search-user-conversations.
search  RequiredThe search function is capable of searching through attachment names, messages, user email, first name, and last name, tags, agent ID, department ID, conversation title and more.
user_id  RequiredThe ID of the user.

Response

{
  "success": true,
  "response": [
        {
            "message": "Hello World!",
            "message_id": "7351",
            "attachments": "",
            "payload": "",
            "message_status_code": "2",
            "last_update_time": "2023-10-02 16:00:06",
            "message_user_id": "377",
            "message_first_name": "Smart Assistant",
            "message_last_name": "",
            "message_profile_image": "https://example.com/image.jpg",
            "message_user_type": "bot",
            "conversation_id": "4084",
            "conversation_user_id": "4446",
            "conversation_status_code": "3",
            "conversation_creation_time": "2023-10-02 15:59:59",
            "department": "1",
            "agent_id": null,
            "title": "",
            "source": "tk",
            "extra": null,
            "tags": null
        },
        ...
  ]
}

Returns {“success”:true, “response”:[]} if no conversations are found.

new-conversation
Creates a new conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter new-conversation.
user_id  RequiredThe ID of the user linked to the conversation.
status_codeThe status code to assign to the conversation. Default: 1. Status codes: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4.
titleThe title of the conversation. Default: empty.
departmentThe ID of a department. You can get the IDs from Settings > Miscellaneous > Departments. Default: -1.
agent_idThe ID of the agent assigned to the conversation. Default: -1.
sourceSet the conversation source. Default: false.
extraExtra conversation values. Default: false.
extra_2Extra conversation values. Default: false.
extra_3Extra conversation values. Default: false.
tagsConversation tags separated by commas. Default: false.

Response

{
    "success": true,
    "response": {
        "messages": [],
        "details": {
            "user_id": "882",
            "first_name": "Don",
            "last_name": "John",
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "lead",
            "id": "1007",
            "title": "",
            "conversation_time": "2020-05-15 12:51:39",
            "conversation_status_code": "0",
            "department": null
        }
    }
}

Other possible responses: Conversation details array on success, otherwise user-not-found, MySQL error message.

update-conversation-status
Updates the status code of a conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter update-conversation-status.
conversation_id  RequiredThe ID of the conversation.
status_code  RequiredThe status code to assign to the conversation. Status codes: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4.

Response

{
    "success": true,
    "response": true
}

Returns invalid-status-code if the status code is invalid.

update-conversation-department
Updates the department of a conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter update-conversation-department.
conversation_id  RequiredThe ID of the conversation to update.
department  RequiredThe ID of a department. You can get the IDs from Settings > Miscellaneous > Departments. The department ID is not validated, so double-check it to make sure it exists. Set it to false to remove the department.
messageA string containing a message for the agents notifications. If set, all the agents assigned to the new department will be notified via email, push notification, and SMS.

Response

{
    "success": true,
    "response": true
}

update-conversation-agent
Assigns or update the agent assigned to a conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter update-conversation-agent.
conversation_id  RequiredThe ID of the conversation to update.
agent_id  RequiredThe ID of a agent. Set it to false to remove the agent.
messageA string containing a message for the agent notifications. If set, the agent will be notified via email, push notification, and SMS.

Response

{
    "success": true,
    "response": true
}

set-rating
Assigns a rating to a conversation and optionally updates a message of the conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter set-rating.
settings  RequiredEnter the following array in JSON format: { “settings” : { “conversation_id”: “ID”, “rating”: “RATING” }}. Replace ID with the ID of the conversation to rate, replace rating with 1 for a positive rating or with 0 for a negative one.
payloadThe payload of the message in JSON format.
message_idThe ID of the message to update.
messageThe content of the message.
user_idThe ID of the user linked to the conversation linked to the message.

Response

{
    "success": true,
    "response": true
}

get-rating
Gets the ratings of the conversations assigned to an agent.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-rating.
user_id  RequiredThe ID of an agent.

Response

{
    "success": true,
    "response": true
}

get-rating
Gets the ratings of the conversations assigned to an agent.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-rating.
user_id  RequiredThe ID of an agent.

Response

{
    "success": true,
    "response": [4,2]
}

The response array: [count of positive ratings, count of negative ratings]. In the example above there are 4 positive ratings and 2 negative ratings.

get-new-messages
Returns the messages of a conversation created after the given date/ID.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-new-messages.
user_id  RequiredThe ID of the user linked to the conversation.
conversation_id  RequiredThe ID of the conversation.
datetime  RequiredMessage ID or date and time in the following format: YYYY-MM-DD HH:MM:SS. E.g. 2020-05-13 13:35:59. You can remove the time and leave only the date. The dates stored in the database are in UTC+0.

Response

{
    "success": true,
    "response": [
        {
            "id": "2319",
            "user_id": "377",
            "message": "Welcome to our support chat!",
            "creation_time": "2020-05-12 18:04:50",
            "attachments": "",
            "status_code": "0",
            "payload": "",
            "conversation_id": "1004",
            "first_name": "Virtual",
            "last_name": "Agent",
            "profile_image": "https://smartai.support/bot.svg",
            "user_type": "bot"
        },
        {
            "id": "2320",
            "user_id": "877",
            "message": "Thank you! I need help.",
            "creation_time": "2020-05-12 18:04:51",
            "attachments": "",
            "status_code": "0",
            "payload": "",
            "conversation_id": "1004",
            "first_name": "Don",
            "last_name": "John",
            "profile_image": "https://smartai.support/user.svg",
            "user_type": "lead"
        },
        ...
    ]
}

Return {“success”:true, “response”:[]} if no conversations are found.

get-last-message
Returns the last message in a conversation.

token  RequiredYour admin secret token.
function  RequiredEnter get-last-message.
conversation_id  RequiredThe conversation ID.
exclude_messageIf set, excludes the message with the specified text. Default: false.
user_idIf set, checks only the messages created by the specified user ID. Default: false

Response

{
    "success": true,
    "response": {
        "message": "Welcome to our support chat!",
        "attachments": "",
        "payload": ""
    }
}

send-message
Adds a new message to an existing conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter send-message.
user_id  RequiredThe ID of the user who sends the message. Use the API ‘get-bot-id’ to get the ID of the bot.
conversation_id  RequiredThe ID of the conversation.
messageThe message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default: [].
conversation_status_codeThe status code to assign to the conversation. Status codes: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4. Set it to skip to leave the current conversation status.
payloadArray in JSON format of additional information. You can insert any value. Array syntax: { “key”: value, “key”: value, … }.
queueSet it to true if the queue is active in Settings > Miscellaneous > Queue. Default: false.
recipient_idThe ID of the user who receive the message. Use this attribute to get the user language.

Response

{
    "success": true,
    "response": {
        "status": "success",
        "message-id": 123456,
        "queue": false,
        "notifications": ["sms", "email"],
        "message": "Text of the message"
    }
}

Other possible responses: invalid-status-code, MySQL error message. The notifications response include the notifications sent to the user or agents.

update-message
Updates an existing message.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter update-message.
message_id  RequiredThe ID of the message.
messageThe content of the message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default: [].
payloadArray in JSON format of additional information. You can insert any value. Array syntax: { “key”: value, “key”: value, … }

Response

{
    "success": true,
    "response": true
}

delete-message
Deletes an existing message.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter delete-message.
message_id  RequiredThe ID of the message to delete.

Response

{
    "success": true,
    "response": true
}

delete-attachments
Deletes all attachments of a conversation or message, including the ones stored in AWS S3.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter delete-attachments.
conversation_idThe ID of the conversation containing the attachments to delete. Default: false.
message_idThe ID of the message containing the attachments to delete. Default: false.

Response

{
    "success": true,
    "response": true
}

update-messages-status
Updates the status code of multiple messages to read.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter update-messages-status.
message_ids  RequiredArray of message IDs in JSON format, e.g. [1, 212, 124].
user_idThe ID of the user linked to the messages. Required to update the user’s chat if Pusher is active.

Response

{
    "success": true,
    "response": true
}

get-agents-in-conversation
Returns an array with all the agents with at least one message in the conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-agents-in-conversation.
conversation_id  RequiredThe conversation ID. It can be an array of conversation IDs

Response

{
     "success": true,
     "response": {
         "1546": [
             {
                 "id": 5463,
                 "first_name": "Don",
                 "last_name": "John",
                 "profile_image": "https://smartai.support/user.svg",
                 "conversation_id": 1546
             },
             {
                 "id": 6413,
                 "first_name": "Steven",
                 "last_name": "Travolta",
                 "profile_image": "https://smartai.support/user.svg",
                 "conversation_id": 1546
             },
             ...
         ]
     }
 }

transcript
Exports a conversation in a CSV or TXT file and returns the URL.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter transcript.
conversation_id  RequiredThe ID of the conversation to export.
typeSet it to csv to export the conversation as a CSV file, set it to txt to export the conversation as a text file, set it to false to use the type set in Settings > Admin > Transcript type. Default: false.

Response

{
    "success": true,
    "response": "https://smartai.support/uploads/conversation-1021.csv"
}

Return {“success”:true, “response”:false} if the conversation is not found.

direct-message
Sends a direct chat message. Details here.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter direct-message.
user_ids  RequiredArray of user IDs, e.g. [45, 89, 65].
message  RequiredThe message.
subjectThe subject. Required only for emails. Default: false.

Response

{
    "success": true,
    "response": true
}

messaging-platforms-send-message
Sends a message to the messaging platform linked to the conversation. Available messaging platforms: Facebook Messenger, Instagram, WhatsApp, Twitter, Telegram, Google Business Messages, WeChat, LINE, Viber, Tickets, Emails, Text messages.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter messaging-platforms-send-message.
conversation_id  RequiredThe conversation ID.
message  RequiredThe message.
attachments  RequiredArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded.
user  RequiredAssociative array with { “id”: 123, “profile_image”: “https://example.com/image.jpg” } as values, or a user ID.
sourceAssociative array with { “source”: SOURCE CODE } as value. Available source codes: em (Email), tk (Ticket), wa (WhatsApp), fb (Facebook Messenger), ig (Instagram), tw (Twitter), wc (WeChat), tx (Text message), gb (Google Business Messages), tg (Telegram), ln (LINE) vb (Viber). For Telegram the source must also include { “chat_id”: “123456789” }. For Facebook Messenger the source must also include { “page_id”: “123456789” }.

Response

{
    "success": true,
    "response": true
}

count-conversations
Counts the number of conversations.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter count-conversations.
status_codeIf set, only the conversations with the specified status are counted. Status codes: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4. Default: false.

Response

{
    "success": true,
    "response": 123456
}

check-conversations-assignment
Checks if a list of conversations is assigned to a department or agent and returns only the conversation IDs that are assigned to that agent and/or department.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter check-conversations-assignment.
conversation_ids  RequiredArray of IDs of the conversations to check, e.g. [45, 565, 68].
agent_idThe agent ID. Default: false.
department_idThe department ID. Default: false

Response

{
    "success": true,
    "response": [1234, 5, ...]
}

get-last-agent-in-conversation
Returns the last agent who answered a conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-last-agent-in-conversation.
conversation_id  RequiredThe conversation ID.

Response

{
     "success": true,
     "response": {
        "id": 123,
        "first_name": "Don",
        "last_name": "John",
        "email": "email@example.com",
        "password": "$P$BcCpYeU21wYnXKW2LpJj/F9xRdSmLM/"
     }
 }  

Returns false the conversation has no replies from agents.

execute-bot-message
Sends a bot message and returns its content.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter execute-bot-message.
name  RequiredThe bot message name. Available values: offline, follow_up, welcome.
conversation_id  RequiredThe ID of the conversation to send the message to.
last_user_messageUse it to display different text excerpts in the admin area and chat dashboard. Default: false.
checkSet it to false to send the message also if it was already sent less than 10 days ago. Default: true.

Response

{
    "success": true,
    "response": {
       "message": "Lorem ipsum dolor",
       "attachments": [],
       "id": 123,
       "settings": {
          "active": true,
          "title": "",
          "message": ""
       }
    }
}

ID is the ID of the message that was just created.

Settings
Functions related to settings, articles, translations and more.

get-setting
Returns a setting saved in the Settings area.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-setting.
setting  RequiredThe setting ID. You can get the IDs of all the settings from the file resources\json\settings.json or with the API function Get Settings

Response

{
    "success": true,
    "response": {
        "option": "value",
        "option": "value",
        ...
    }
}

get-multi-setting
Returns a subsetting of another setting.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-multi-setting.
id  RequiredThe main setting ID. You can get the IDs of all the settings from the file resources\json\settings.json or with the API function get settings
sub_id  RequiredThe subsetting ID. You can get the IDs of all the settings from the file resources\json\settings.json or with the API function get settings
defaultThe value to return if the setting is not found. Default: false

Response

Returns the value of the subsetting if available, otherwise returns the default value.

get-external-setting
Returns an external setting. External settings are saved on a dedicated database row.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-external-setting.
name  RequiredThe setting name.
defaultThe value to return if the setting is not found. Default: false.

Response

Returns the value of the setting if available, otherwise returns the default value.

get-settings
Returns an array with all the settings.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-settings.

Response

{
    "success": true,
    "response": {
        "chat-manual-init": [
            false,
            "checkbox"
        ],
        "chat-login-init": [
            false,
            "checkbox"
        ],
        "init-dashboard": [
            true,
            "checkbox"
        ],
        "chat-timetable-disable": [
            false,
            "checkbox"
        ],
        "rtl": [
            false,
            "checkbox"
        ],
        "front-auto-translations": [
            true,
            "checkbox"
        ],
        ...
    }
}

save-settings
Saves all settings.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter save-settings.
settings  RequiredThe settings array. Get it from Getting started
external_settingsSettings saved to a dedicated row of the table sb_settings of the database.
external_settings_translationsTranslations of the external settings.

Response

{
    "success": true,
    "response": true
}

save-external-setting
Saves an external setting. External settings are saved on a dedicated database row.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter save-external-setting.
name  RequiredThe setting name.
value  RequiredThe setting value.

Response

{
    "success": true,
    "response": true
}

export-settings
Exports all Support Board settings to a JSON file and return the URL of the file.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter export-settings.

Response

{
    "success": true,
    "response": "http://example.com/supportboard/uploads/settings_855776223.json"
}

Returns the URL of the JSON file containing the settings.

import-settings
Imports the Support Board settings from a JSON file generated via the export-settings function.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter import-settings.
file_url  RequiredThe URL of the JSON file containing the settings.

Response

{
    "success": true,
    "response": true
}

get-departments
Returns the Support Board departments.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter get-departments.

Response

{
    "1": {
        "name": "Example",
        "color": "yellow",
        "image": "https://example.com/image.png"
    },
    "2": {
        "name": "Example",
        "color": "red",
        "image": "https://example.com/image.png"
    },
    ...
}

saved-replies
Returns an array with all the saved replies.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter saved-replies.

Response

{
    "success": true,
    "response": [
        {
            "reply-name": "hello",
            "reply-text": "Hello! How can I help?"
        },
        {
            "reply-name": "email",
            "reply-text": "Our email is support@example.com."
        },
        ...
    ]
}

get-translation
Returns the translations in the given language.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter get-translation.
language_code  RequiredThe two-letter language code

Response

{
    "name": "Arabic",
    "front": {
        "Activities": "أنشطة",
        "All": "الكل",
        "All articles": "جميع المقالات",
        "All fields are required.": "جميع الحقول مطلوبة",
        ...
    },
    "admin": {
        "A conversation was started by": "",
        "Activate": "",
        "Activation complete! Page reload in progress...": "",
        "Add a saved reply": "",
        ...
    }
}

get-translations
Returns the translations of the back-end and the frond-end, for all the available languages.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter get-translations.

Response

{
    "ar": {
        "name": "Arabic",
        "front": {
            "Activities": "أنشطة",
            "All": "الكل",
            "All articles": "جميع المقالات",
            "All fields are required.": "جميع الحقول مطلوبة",
            ...
        },
        "admin": {
            "A conversation was started by": "",
            "Activate": "",
            "Activation complete! Page reload in progress...": "",
            "Add a saved reply": "",
            ...
        }
    },
    "da": {
        "name": "Danish",
        "front": {
            "Activities": "Aktiviteter",
            "All": "Alle",
            "All articles": "Alle artikler",
            "All fields are required.": "Alle felter skal udfyldes.",
            ...
        },
        "admin": {
            "A conversation was started by": "",
            "Activate": "",
            "Activation complete! Page reload in progress...": "",
            "Add a saved reply": "",
            ...
        }
    },
    ...
}

save-translations
Save the translations and overwrite the translations files. Warning! If the given translations array is corrupted you could corrupt the translations files. Make a backup of the translations folder (\resources\languages) first. Each time a translation is saved a backup is created automatically in the uploads folder.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter save-translations.
translations  RequiredThe translations array with all the translations. Use the method get-translations to get the array.

Response


{
    "success": true,
    "response": true
}

translate-string
Translates a string in the language of the specified language code. This function works only for front translations.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter translate-string.
string  RequiredThe string to translate.
language_codeThe two-letter language code. Set it to false to use the active user language. Default: false.

Response

Returns the translated string if the translation is found, otherwise returns the original string.

Articles
Article/Knowledge Base functions.

get-articles
Returns an array with all the articles or a single article

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-articles.
idThe ID of the article. The get the articles IDs, execute this method again without arguments. Default: -1.
countThe maximum number of returned articles. Default: all.
fullBoolean. Set it to true to get full length article contents. Default: false.
categoriesSet it to true to get the array of all categories, in such a case the response is a double array, first item articles, second item categories. Set it to the category ID to get only the articles of the give category. Default: false.
articles_languageGet the articles in the language of the given language code. If there are no articles in the given language code, the articles in the default language are returned instead. Set it to all to get all the translations. Default: false.

Response

{
    "success": true,
    "response": [
        {
            "id": "6P2Oq",
            "title": "What's new with the API V2?",
            "content": "The API V2 is the new iteration of o ...",
            "link": "https://smartai.support",
            "categories": ["K92kl"]
        },
        {
            "title": "Should I move to the new system?",
            "content": "Yes. The newest version of the Actions ...",
            "link": "https://smartai.support",
            "id": "qf7kD",
            "categories": ["ols85"]
        },
        ...
    ]
}
{
    "success": true,
    "response": {
        "id": "6P2Oq",
        "title": "What's new with the API V2?",
        "content": "The API V2 is the new iteration of our developer API. The new API integrates...",
        "link": "https://smartai.support",
        "categories": ["K92kl"]
    }
}

save-articles
Saves all the articles. This function deletes all the existing articles and replace them with the ones of the given array.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter save-articles.
articles  RequiredThe array with the articles. Use the API get-articles to get the articles array. Array syntax:  {“articles”: [{“id”: “”, “title”: “”, “content”: “”, “link”:””, “categories”: []}, …]}
translationsThe array with the articles translations. Use the API get-articles to get the articles array. Array syntax:  { “es”: [{“id”: “”, “title”: “”, “content”: “”, “link”:””, “categories”: []}, …], “it”: […], …}

Response

{
    "success": true,
    "response": true
}

search-articles
Returns the articles matching the search.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter search-articles.
search  RequiredThe string to search. The search function supports title and content.
articles_languageSearch only the articles in the language of the given language code. If there are no articles in the given language code, the search returns the articles in the default language. Set it to all to get all the translations. Default: false.

Response

{
    "success": true,
    "response": [
        {
            "id": "6P2Oq",
            "title": "What's new with the API V2?p",
            "content": "The API V2 is the new iteration of o ...",
            "link": "https://smartai.support",
            "categories": ["K92kl"]
        },
        {
            "title": "Should I move to the new API?",
            "content": "Yes. The newest version (V2) of the Actions ...",
            "link": "https://smartai.support",
            "id": "qf7kD",
            "categories": ["K92kl"]
        },
        ...
    ]
}

Returns {“success”:true, “response”:[]} if no articles are found.

get-articles-categories
Returns an array with all the articles categories.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-articles-categories.

Response

{
    "success": true,
    "response": [
        {
            "id": "Nv9PG",
            "title": "Business"
        },
        {
            "id": "csPVh",
            "title": "Travel And Tourism"
        },
        {
            "id": "pl5S7",
            "title": "Finance"
        },
        ...
    ]
}

save-articles-categories
Saves or updates the articles categories array.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter save-articles-categories.
categories  RequiredArray of categories. Array syntax: [ { “id”: “123456”, “title”: “Category name” }, { “id”: “123456”, “title”: “Category name” }, …]. Get the existing categories array with the method categories

Response

{
    "success": true,
    "response": true
}

article-ratings
Gets the ratings of an article or adds a new rating to it.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter article-ratings.
article_id  RequiredThe ID of the article.
ratingThe rating to add. Enter 1 for a positive rating or 0 for a negative one. If this argument is set the method adds the rating, otherwise returns the existing ratings. Default: false.

Response

{
    "success": true,
    "response": "[-1, 1, 1, -1]"
}

Returns true if the rating argument is set.

More methods

send-email
Sends an email to an existing user using the email templates of the Settings > Notifications area.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter send-email.
recipient_id  RequiredThe ID of the user to which send the email.
sender_idThe ID of the sender user.
message  RequiredThe message of the email.
attachmentsArray of attachments in JSON format. Array syntax:[[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default:

Response

{
    "success": true,
    "response": true
}

Other possible responses: missing-user-id-or-message, security-error, user-email-not-found, user-or-sender-not-found.

send-custom-email
Sends a generic email to an email address. The sender email and name are the ones set in Settings > Notifications > Email settings.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter send-custom-email.
to  RequiredThe email address.
subject  RequiredThe email subject.
message  RequiredThe message of the email.
sender_suffixAppend the provided text to the sender name. Default: empty.

Response

{
    "success": true,
    "response": true
}

email-piping
Runs the email piping synchronization with Support Board and converts emails to chat messages.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter email-piping.
forceSet it to true to the execution of the synchronization, by default the synchronization is executed a maximum of one time per minute. Default: false.

Response

{
    "success": true,
    "response": true
}

send-sms
Sends a text message to a user or agent. If the template argument is true, the message is translated automatically.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter send-sms.
message  RequiredThe text message.
to  RequiredThe phone number. Include the country code.
templateSet it to false to send only the message without the template content. Default: the message is sent within the template of Settings > SMS notifications.
conversation_idSet it if the message contains the URL parameter {conversation_url_parameter}.
attachmentsArray of attachment. Array syntax: [[“name”, “link”], [“name”, “link”], …] or [“link”, “link”, …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default: false.

Response

{
    "success": true,
    "response": {
        "sid": "SM1f0e8ae6ade43cb3c0ce4525424e404f",
        "date_created": "Fri, 13 Aug 2010 01:16:24 +0000",
        "date_updated": "Fri, 13 Aug 2010 01:16:24 +0000",
        "date_sent": null,
        "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        "to": "+15305431221",
        "from": "+15104564545",
        "body": "A Test Message",
        "status": "queued",
        "flags": [
            "outbound"
        ],
        "api_version": "2010-04-01",
        "price": null,
        "uri": "/2010-04-01/Accounts/ACXXXX/Messages/SM1f004f.json"
    }
}

push-notification
Sends a Push notification to an agent, a group of agents, or all agents. Push notifications must be enabled in the settings area.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter push-notification.
title  RequiredThe title of the notification.
message  RequiredThe message text.
interests  RequiredThe following values are accepted: Agent or user ID Array of agents or users IDs (ex.[1, 2, 3]) Enter agents to send the notification to all agents without a department assigned. Enter all-agents to send the notification to all agents. Enter department-ID to send the notification to all agents assigned to the given department. Replace ID with the department ID.
conversation_idThe ID of the conversation to open when the user clicks the notification.
iconThe URL of the notification icon. Default: Support Board icon or notifications icon

Response

{
    "success": true,
    "response": {
        "id": "8b1c4e05-5e08-4926-86b0-a56ab7817e25",
        "external_id": null,
        "errors": {}
    }
}

Returns false it the Push notifications are disabled in the settings area.

get-versions
Returns the installed versions of Support Board and the Apps.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-versions.

Response

{
    "success": true,
    "response": {
        "sb": "3.0.4",
        "dialogflow": "1.0.2",
        "slack": "1.0.3"
    }
}

update
Starts the update of Support Board and all the apps. This method forces the update and always overwrite all plugin and apps files.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter update.

Response

{
    "success": true,
    "response": "success"
}

wp-synch
Starts the synchronization of the WordPress users and imports the new WordPress users into Support Board. This method is available only in the WordPress version.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter wp-synch.

Response

{
    "success": true,
    "response": true
}

app-get-key
Returns the License Key of a Support Board App like the Slack App or the Artificial Intelligence app.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter app-get-key.
app_name  RequiredThe app name. E.g. dialogflow, slack, whatsapp, messenger…

Response

{
    "success": true,
    "response": "9300AB16-014ZEE12-91E199EA-997CEX40"
}

app-activation
Activates an app, downloads it, and installs it.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter app-activation.
app_name  RequiredThe app name. E.g. dialogflow, slack, whatsapp, messenger…
key  RequiredThe License Key of the App. You can get the key with the function app-get-key.

Response

{
    "success": true,
    "response": "success"
}

cron-jobs
Runs the cron jobs. For more details click here.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter cron-jobs

Response

{
    "success": true,
    "response": true
}

pusher-trigger
Triggers an avent on a Pusher channel.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter pusher-trigger
channel  RequiredThe channel name.
event  RequiredThe event name.
dataArray of values. Syntax: [ “name” => “value” ].

Response

{
    "success": true,
    "response": true
}

chat-css
Returns the CSS style for the chat colors.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter chat-css
color_1The first color in RGB or HEX format. Default: the first color saved in the settings area.
color_2The second color in RGB or HEX format. Default: the second color saved in the settings area.
color_3The third color in RGB or HEX format. Default: the third color saved in the settings area.

Response

The CSS code.

text-formatting-to-html
Converts the text formatting of chat messages to the equivalent HTML codes and returns the message.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter text-formatting-to-html
message  RequiredThe text message.

Response

Lorem ipsum dolor <b>sit amet</b>, <i>consectetur adipiscing elit</i>, <code>sed</code> do eiusmod tempor incididunt.

clear-text-formatting
Removes the text formatting from a chat messages.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter clear-text-formatting
message  RequiredThe text message.

Response

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.

get-notes
Returns the internal notes of a conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter get-notes
conversation_id  RequiredThe conversation ID.

Response

{
    "success": true,
    "response": [
        {
            "id": 98207,
            "user_id": "1538",
            "name": "Lorem ipsum dolor sit amet",
            "message": "Lorem ipsum dolor sit amet, consectetur elit, sed do eiusmod tempor incididunt."
        },
        {
            "id": 76986,
            "user_id": "1596",
            "name": "Lorem ipsum dolor",
            "message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor."
        },
        ...
    ]
}

add-note
Adds a new note to a conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter add-note
conversation_id  RequiredThe conversation ID to which link the note to.
user_id  RequiredThe ID of the agent or admin who create the note.
name  RequiredThe note name.
message  RequiredThe note message.

Response

{
    "success": true,
    "response": 33560
}

Returns the node ID

delete-note
Deletes a note from a conversation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter delete-note
conversation_id  RequiredThe ID of the conversation linked to the note.
note_id  RequiredThe note ID.

Response

{
    "success": true,
    "response": true
}

automations-get
Returns all automation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter automations-get

Response

[
    {
        "emails": [
            {
                "id": "0BOaG",
                "conditions": [
                    [
                        "datetime",
                        "is-between",
                        "10/04/2021 - 13/04/2021"
                    ],
                    [
                        "include_urls",
                        "contains",
                        "https://example.com"
                    ],
                    ...
                ],
                "name": "Excepteur sint",
                "message": "Excepteur sint occaecat cupidatat non proident.",
                "subject": "Cupidatat non proident"
            },
            ...
        ],
        "sms": [
            {
                "id": "vo2sY",
                "conditions": [
                    [
                        "datetime",
                        "is-exactly",
                        "13/04/2021"
                    ]
                ],
                "name": "Excepteur sint",
                "message": "Excepteur sint occaecat cupidatat non caecat cupidatat non proident"
            },
            {
                "id": "hwkmQ",
                "name": "Excepteur sint occaecat cupidatat non proident",
                "message": "Excepteur sint occaecat cupidatat non  occaecat cupidatat non proident"
            },
            ...
        ],
        "messages": [],
        "popups": [
            {
                "id": "ckN24",
                "conditions": [
                    [
                        "user_type",
                        "is-user"
                    ],
                    [
                        "languages",
                        "en"
                    ]
                ],
                "name": "s",
                "message": "Excepteur sint occaecat cupidatat non prcaecat cupidatat non proident",
                "title": "Excepteur sint occaecat",
                "profile_image": "https://example.com/image.jpg"
            },
            ...
        ],
        "design": [
            {
                "id": "bX1qA",
                "conditions": [
                    [
                        "user_type",
                        "is-user"
                    ]
                ],
                "name": "Excepteur sint",
                "message": "Excepteur sint occaecat cupidatat caecat cupidatat non proident",
                "title": "",
                "color_1": "rgb(0, 235, 26)",
                "color_2": "rgb(255, 0, 0)",
                "color_3": "rgb(255, 0, 0)",
                "background": "https://example.com/image.jpg",
                "brand": "https://example.com/image.jpg",
                "icon": "https://example.com/image.jpg"
            },
            ...
        ]
    },
    {
        "fr": {
            "messages": [
                {
                    "id": "y6hNE",
                    "name": "XXXX",
                    "message": "XXXX"
                }
            ]
        },
        ...
    }
]

automations-save
Saves all automation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter automations-save
automations  RequiredAutomations array. Get it from the Automation-get function.
translationsAutomations translations array. Get it from the Automation-get function.

Response

{
    "success": true,
    "response": true
}

automations-validate
Validates an automation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter automations-validate
automation  RequiredThe automation.

Response

{
      "conditions": [
          [
              "user_type",
              "is-user"
          ],
          ...
      ],
      "repeat_id": ""
  }

Returns only the client-side conditions and invalid server-side conditions that can be validated in a later time. If no conditions are returned, the automation is valid and can be executed. Returns false if the automation is invalid.

automations-run-all
Validates all automations, executes the valid ones, and returns the automations with client-side conditions, invalid server-side conditions, and popup, design automation.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter automations-run-all

Response

[
    {
        "id": "0BOaG",
        "conditions": [
            [
                "datetime",
                "is-between",
                "10/04/2021 - 13/04/2021"
            ],
            [
                "include_urls",
                "contains",
                "https://example.com"
            ],
            ...
        ],
        "name": "Excepteur sint",
        "message": "Excepteur sint occaecat cupidatat non proident.",
        "subject": "Cupidatat non proident",
        "type": "emails"
    },
    {
        "id": "bX1qA",
        "conditions": [
            [
                "user_type",
                "is-user"
            ]
        ],
        "name": "Excepteur sint",
        "message": "Excepteur sint occaecat cupidatat caecat cupidatat non proident",
        "title": "",
        "color_1": "rgb(0, 235, 26)",
        "color_2": "rgb(255, 0, 0)",
        "color_3": "rgb(255, 0, 0)",
        "background": "https://example.com/image.jpg",
        "brand": "https://example.com/image.jpg",
        "icon": "https://example.com/image.jpg",
        "type": "design"
    },
    ...
]

automations-run
Executes a single automation and optionally validates it before executing it.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter automations-run
automation  RequiredThe automation.
validateSet it to true to validate the automation before executing it. Default: false

Response

{
    "success": true,
    "response": true
}

automations-is-sent
Checks if an automation has already been sent to a user.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter automations-is-sent
user_id  RequiredThe ID of the user to check.
automation  RequiredThe automation. It can be [“id” => 123] where 123 is the automation ID.
repeat_idSet it only if the automation can be sent multiple times to the user. Get it from sb_automations_validate Default: false.

Response

Returns true if the automation has already been sent, otherwise returns false.

clean-data
This function performs the following tasks: Deletes visitors older than 24h, deletes messages in trash older than 30 days, archives messages with an agent reply as last message older than 24h.

Requirements
This is an admin function and it works only if the active user is an agent or an admin.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter clean-data.

Response

{
    "success": true,
    "response": true
}

reports
Returns the the specified reports.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter reports.
name  RequiredThe report name. Available values: conversations, missed-conversations, conversations-time, visitors, leads, users, agents-response-time, agents-conversations, agents-conversations-time, agents-ratings, countries, languages, browsers, os, subscribe, follow-up, registrations, articles-searches, articles-ratings, articles-views-single, articles-views, sms-automations, email-automations, message-automations, direct-sms, direct-emails, direct-messages.
date_startThe start date of the reports. Format: dd/mm/yyyy or yyyy-mm-dd. Default: false.
date_endThe end date of the reports. Format: dd/mm/yyyy or yyyy-mm-dd. Default: false.
date_endThe timezone of the user who is calling this function, e.g. Europe/London. Default: false.

Response

{
   "title": "Conversations count",
   "description": "Count of new conversations started by users.",
   "data": {
       "03/2021": [
           2
       ],
       "04/2021": [
           0
       ],
       "05/2021": [
           0
       ],
       ...
   },
   "table": [
       "Date",
       "Count"
   ],
   "table-inverse": true,
   "label_type": 1,
   "chart_type": "line"
}  

reports-update
Adds a new row to the sb_reports database table.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter reports-update.
name  RequiredThe report name. Available values: conversations, missed-conversations, conversations-time, visitors, leads, users, agents-response-time, agents-conversations, agents-conversations-time, agents-ratings, countries, languages, browsers, os, subscribe, follow-up, registrations, articles-searches, articles-ratings, articles-views-single, articles-views, sms-automations, email-automations, message-automations, direct-sms, direct-emails, direct-messages.
valueThe row value. Default: false.
external_idAn external ID. Default: false.
extraAn extr avalue. Default: false.

Response

{
    "success": true,
    "response": true
}

updates-available
Checks if there are updates available for Support Board and the Support Board apps.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter updates-available.

Response

{
    "success": true,
    "response": true
}

Returns true if at least one update is available, otherwise returns false.

newsletter
Adds a subscriber to the newsletter service set in Settings > Miscellaneous > Newsletter. The setting Settings > Miscellaneous > Newsletter > Active must be active.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter newsletter.
email  RequiredThe subscriber email address.
first_nameThe subscriber first name. Default: empty.
first_nameThe subscriber last name. Default: empty.

Response

Returns the newsletter service response.

upload-path
Returns the Support Board uploads path.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter upload-path.
urlSet it to true to get the URL instead. Default: false.
dateSet it to true to get also the date folder relative to the current date. Default: false

Response

{
    "success": true,
    "response": "\var\www\htdocs\supportboard\uploads\10-03-23"
}
{
    "success": true,
    "response": "https://www.example.com/supportboard/uploads/10-03-23"
}

is-allowed-extension
Checks if uploading files with the specified file extension is allowed.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter is-allowed-extension.
extension  RequiredThe file extension, e.g. jpg

Response

{
    "success": true,
    "response": true
}

Returns true if the extension is allowed, otherwise returns false.

system-requirements
Checks if the host machine supports the Support Board system requirements.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter system-requirements

Response

{
                                  "success": true,
                                  "response": {
                                      "php-version": true,
                                      "zip-archive": true,
                                      "plugin-folder": true,
                                      "uploads-folder": true,
                                      "apps-folder": true,
                                      "languages-folder": true,
                                      "ajax": true,
                                      "curl": true,
                                      "UTF8mb4": true
                                  }
                              }      

logs
Adds a log message to the log file.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter logs.
string  RequiredThe log message.
userSet it to include the user ID to the log message. This value can be [“id” => 123]. Default: false.

Response

{
                              "success": true,
                              "response": true
                         } 

aws-s3
Uploads a file to Amazon S3, or delete a file from Amazon S3. Amazon S3 must be active and configured at Settings > Miscellaneous > Amazon S3

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter aws-s3.
file_path  RequiredThe path to the file to upload or the Amazon S3 file URL for deleting a file.
actionSet it to PUT to upload a file. Set to DELETE to delete a file. Default: PUT.

Response

{
                              "success": true,
                              "response": "https://example.s3.amazonaws.com/example.txt"
                          }

Returns the URL of the Amazon S3 file.

Artificial Intelligence
The Artificial Intelligence app is required to use this set of APIs.

dialogflow-message
Sends a message to Dialogflow and returns the response.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-message.
conversation_idThe ID of a conversation. If provided, the response it added to the conversation as a new message.
messageThe string containing the text of the message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. Dialogflow can read this array.
languageThe language of the bot. Default: the main bot language.
eventTrigger a Dialogflow event.
parametersArray of optional information. Array syntax: { “name”: “value”, “name”: “value”, …}.
audioURL of an audio file for speech recognition. Default: false.
tokenThe Dialogflow access token. For performance reasons always include this token. You will get the token after the first call of this function, from the response.

Response

{
    "success": true,
    "response": {
        "token": "ya29.a0AfH6SE4SVIeOPWSfxRVfHNcJIoR-IvRTtrEe4P9VXHa",
        "messages": [
            {
                "message": "Hi! How are you doing?",
                "attachments": []
            }
        ],
        "response": {
            "responseId": "1a5e30d0-d6d4-4f0c-83e3-2fb9e31c2a5e-e15c53b8",
            "queryResult": {
                "queryText": "Hello",
                "action": "input.welcome",
                "parameters": [],
                "allRequiredParamsPresent": true,
                "fulfillmentText": "Hi! How are you doing?",
                "fulfillmentMessages": [
                    {
                        "platform": "ACTIONS_ON_GOOGLE",
                        "simpleResponses": {"simpleResponses": [ { "textToSpeech": "Example"} ]}
                    },
                    {
                        "text": { "text": [ "Hi! How are you doing?" ]  }
                    }
                ],
                "intent": {
                    "name": "projects/api-project-657752147/agent/intents/fe27e-f39d-4db3-92c2",
                    "displayName": "Default Welcome Intent"
                },
                "intentDetectionConfidence": 1,
                "languageCode": "en"
            },
            "alternativeQueryResults": [
                {
                    "queryText": "Hello",
                    "languageCode": "en"
                }
            ]
        }
    }
}

Other possible responses: dialogflow-not-active, MySQL, or cURL error message.

dialogflow-get-intents
Returns the specified Dialogflow Intent or all Intents.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-get-intents.
intent_nameThe intent name.
languageThe agent language. Default: the main agent language

Response

[
  {
    "name": "projects/example/agent/intents/1655ee2c-8116-45f1-95fu-93700ff32e8d",
    "displayName": "Default Welcome Intent",
    "priority": 500000,
    "mlEnabled": true,
    "events": [ "WELCOME" ],
    "trainingPhrases": [
      {
        "name": "43ca0e72-6055-4b88-af13-b0d241",
        "type": "EXAMPLE",
        "parts": [
          {
            "text": "just going to say hi"
          }
        ]
      },
      {
        "name": "5159aabc-8524-404f-b679-f2228db1",
        "type": "EXAMPLE",
        "parts": [
          {
            "text": "Hello"
          }
        ]
      },
      ...
    ],
    "action": "input.welcome",
    "messages": [
      {
        "text": {
          "text": [ "Hi! How are you doing?", "Hello! How can I help you?" ]
        }
      }
    ]
  },
  ...
]

dialogflow-create-intent
Creates a new Intent in Dialogflow. The new Intent will be linked the agent synchronized in the admin area.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-create-intent.
expressions  RequiredArray with the training phrases. Array syntax: [“”, “”, …].
response  RequiredString containing the response of the bot when the user input matches a user expression.
agent_languageThe language code of the intent. Default: main agent language. For the languages codes list visit cloud.google.com/dialogflow/docs/reference/language. Default: false.

Response

{
    "success": true,
    "response": true
}

dialogflow-update-intent
Updates a Dialogflow Intent.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-update-intent.
intent_name  RequiredThe Intent name. Get it with the function dialogflow-get-intents..
expressions  RequiredArray with the training phrases. Array syntax: [“”, “”, …].
agent_languageThe language code of the intent. Default: main agent language. For the languages codes list visit cloud.google.com/dialogflow/docs/reference/language. Default: false.

Response

{
    "success": true,
    "response": true
}

dialogflow-entity
Creates a new Entity in Dialogflow. The new Entity will be linked the agent synchronized in the admin area.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-entity.
entity_name  RequiredThe unique Entity name.
synonyms  RequiredArray of Entity values. Single value syntax: [‘value’ => ”, ‘synonyms’ => [”, ”, …]].
agent_languageThe language code of the intent. For the languages codes list visit cloud.google.com/dialogflow/docs/reference/language. Default: false. Default: false.

Response

{
    "success": true,
    "response": true
}

dialogflow-get-entity
Returns a Dialogflow Entity, or all Entities of the agent.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-get-entity.
entity_id  RequiredThe ID of the Entity. Leave empty or insert all to get all Entities. Default: all.
agent_languageThe language code of the intent. For the languages codes list visit cloud.google.com/dialogflow/docs/reference/language. Default: false.

Response

{
    "success": true,
    "response": {
      "name":"projects/small-talk-43da7/agent/entityTypes/t5td1425-2k13-16cc-a7bb-f119b8d94112a",
      "displayName":"woocommerce-products",
      "kind":"KIND_MAP",
      "autoExpansionMode":"AUTO_EXPANSION_MODE_DEFAULT",
      "entities":[
         {
            "value":"Abstract Print Cotton Blouse",
            "synonyms":[
               "Abstract Print Cotton Blouse"
            ]
         },
         {
            "value":"Cashmere Carpenter Beanie",
            "synonyms":[
               "Cashmere Carpenter Beanie"
            ]
         },
         ...
      ],
      "enableFuzzyExtraction":true
    }
}

dialogflow-get-token
Generates a new Dialogflow Token and returns it. The token is valid for 1 hour.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-get-token.

Response

{
    "success": true,
    "response": "ya27.a1AfH6SMDu9dn0TfRbNVAIEsSoeJPD1_jr1JpfL15..."
}

dialogflow-get-agent
Returns the details of the Dialogflow agent

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-get-agent

Response

{
    "success": true,
    "response": {
        "parent":"projects/woocommerce-abcde",
        "displayName": "ABCDE",
        "defaultLanguageCode": "en",
        "timeZone": "Europe/Madrid",
        "enableLogging": true,
        "matchMode": "MATCH_MODE_HYBRID" ,
        "classificationThreshold": 0.6,
        "apiVersion": "API_VERSION_V2",
        "tier": "TIER_STANDARD"
    }
}

dialogflow-set-active-context
Activates a Dialogflow context in the active user session.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-set-active-context.
context_name  RequiredThe context name.
user_id  RequiredThe ID of the user linked to the context.
parametersArray of Dialogflow parameters linked to the context. Example: { “woocommerce-products”: “Running Shoes” }.
life_spanThe context lifespan. Default: 5.
tokenDialogflow Session Token(it’s not the Refresh Token). Pass it if you have it, otherwise it will be generated. Default: false.
languageThe agent language. Default: main agent language.

Response

{
   "success":true,
   "response": {
      "responseId":"09f2f825-3dbf-4c27-a5bb-6bd0b71e44b9-1d846bd2",
      "queryResult":{
         "queryText":"sb-trigger-context",
         "parameters":[
         ],
         "outputContexts":[
            {
               "name":"projects/abcde/agent/sessions/208/contexts/abcde",
               "lifespanCount":4,
               "parameters":{
                  "woocommerce-products":"Sampras Vibration Dampener"
               }
            }
         ],
         "languageCode":"en"
      }
   }
}

dialogflow-curl
Sends data to Dialogflow. Use this method to submit the queries to Dialogflow.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-curl.
query  RequiredThe Dialogflow query in JSON format.
languageThe Dialogflow agent language. Default: false.
typeThe call type. Supported values: POST, GET, PATCH. Default: POST.
tokenDialogflow Session Token(it’s not the Refresh Token). Pass it if you have it, otherwise it will be generated. Default: false

Response

{
   "success": true,
   "response": "..."
}

Returns the Dialogflow response. More details at https://cloud.google.com/dialogflow/es/docs/reference/rest/v2-overview

dialogflow-human-takeover
Triggers the Dialogflow human takeover.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-human-takeover.
conversation_id  RequiredThe conversation ID.
auto_messagesSet it to true to send also offline, follow_up and subscribe messages if they are active. Default: false.

Response

{
   "success": true,
   "response": [true, true, ...]
}

dialogflow-smart-reply
Returns the smart reply suggestions.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter dialogflow-smart-reply.
conversation_id  Required
message  RequiredThe text message from which generate the suggestions.
dialogflow_languageThe Dialogflow agent language. Defualt: false.
tokenThe Dialogflow access token. Default: false.
conversation_idSet it to enable the OpenAI suggestions. Default: false.

Response

{
   "suggestions": [
	   "I would be happy to help!",
	    "What can I do for you?",
       ...
	],
	"token": "ya29.a0AVvZVsrU7gAannWzuztBR-AphpjdWr0JrPoq9au0Ai",
	"detected_language": false,
	"smart_reply": false
}

open-ai-message
Sends a message to OpenAI and return the response, optionally add the response to an existing conversation as a new message.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter open-ai-message.
message  RequiredThe string containing the text of the message.
max_tokensThe max number of OpenAI tokens that can be used to generate the message. This parameter changes the response message length. Default: false. If this parameter is false the default value is the one saved in Settings > Dialoglfow > OpenAI > Max tokens, otherwise, if the active model is gpt-3.5-turbo, default is false, otherwise is 100.
modelThe OpenAI model. Default: false. If this parameter is false the default value is the one saved in Settings > Dialoglfow > OpenAI > Model, otherwise is gpt-3.5-turbo.
conversation_idThe ID of the conversation. It set, the OpenAI response is added to an existing conversation as a new message. Default: false.
audioURL of an audio file for speech recognition. Default: false.

Response

{
     "success": true,
     "response": [
         true,
         "I am an AI digital assistant. How can I help you today?",
         false,
         false
     ]
}

Return an array with the first value set to true on success, false on error. The second value is the OpenAI message on success, or the error message on error.

open-ai-curl
Calls the OpenAI API (ChatGPT) and return the response.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter open-ai-curl.
url_partThe URL part of the API. For example, if you want to call https://api.openai.com/v1/completions, enter only completions.
post_fieldsThe parameters of the API in JSON format.
typeThe HTTP call type. Allowed values: GET, POST, UPLOAD.

Response

{
   "success": true,
   "response": "..."
}

Returns the openAI response. More details at https://beta.openai.com/docs/api-reference/.

google-translate
Translates multiple strings via Google Translate.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter google-translate.
strings  RequiredArray of the strings to translate, e.g. [“Hello world”, “How are you?”].
language_code  RequiredThe two-letter language code of the language you want to translate into. For Traditional Chinese use zt, for Simplified Chinese use zh, for Brazilian Portuguese use pt

Response

{
    "success": true,
    "response": [
        [ "Ciao mondo", "Come stai?", ...],
        "ya29.a0AVvZVsqVHw9U7LxFukwIoQEfwA3JyT_2SSRnP2nX4oQ_XyMP9GQk2O"
    ]
}

google-language-detection-update-user
Detects the language of a text and assign it to a user.

Parameters

token  RequiredYour admin secret token.
function  RequiredEnter google-language-detection-update-user.
string  RequiredThe text from which to detect the language.
user_id  RequiredThe user ID.

Response

{
   "success": true,
   "response": true
}

WEB API

WhatsApp
The WhatsApp app is required to use this set of APIs.

Whatsapp-send-message
Sends a message to a WhatsApp number.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter whatsapp-send-message.
to  RequiredThe recipient’s phone number. Include the country code. E.g. +39321305455
messageThe message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default: [].
phone_idThe phone number ID. Get it from Settings > WhatsApp. This setting is required only if you have synched multiple WhatsApp numbers. Default: false.

Response

{
     "success": true,
     "response": {
         "messaging_product": "whatsapp",
         "contacts": [
             {
                 "input": "+16315551234",
                 "wa_id": "+16315551234"
             }
         ],
         "messages": [
             {
                 "id": "wamid.HBgLMTY1MDM4Nzk0MzkVAgARGBI3N0EyQUJDMjFEQzZCQUMzODMA"
             }
         ]
     }
 }

Messenger
The Messenger app is required to use this set of APIs.

messenger-send-message
Sends a message to Messenger or Instagram.

ds a message to a WhatsApp number.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter messenger-send-message.
psid  RequiredThe PSID. To get this information, the user must first send you a message through Facebook. Get it by using the get-user function.
facebook_page_id  RequiredThe Facebook Page ID. To get this information, the user must first send you a message through Facebook. Get it by using the get-conversation function. The ID is the extra value.
messageThe message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default: [].
metadataProvide the Support Board message ID linked to this message. Always include it when possible to avoid issues. Default: false.

Response

{
    "success": true,
    "response": {
        "recipient_id": "89995542233",
        "message_id": "11445777889"
    }
}

Telegram
The Telegram app is required to use this set of APIs.

telegram-send-message
Sends a message to Telegram.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter telegram-send-message.
chat_id  RequiredThe Chat ID. To get this information, the user must first send you a message through Telegram. Get it by using the get-conversation function. The ID is the extra value.
messageThe message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default: [].
conversation_idThis setting is required only if you have synched multiple Telegram bots. Default: false.

Response

{
    "success": true,
    "response": {
        "ok": true,
        "result": {
            "message_id": 2030,
            "from": {
                "id": 21202173,
                "is_bot": true,
                "first_name": "Support Board",
                "username": "sb_officialbot"
            },
            "chat": {
                "id": 148766722,
                "first_name": "Federico",
                "last_name": "Schiocchet",
                "username": "federicoschiocchet",
                "type": "private"
            },
            "date": 1699621061,
            "text": "Hello!"
        }
    }
}

Viber
The Viber app is required to use this set of APIs.

viber-send-message
Sends a message to Viber.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter viber-send-message.
viber_id  RequiredThe Viber ID. To get this information, the user must first send you a message through Telegram. Get it by using the get-user function.
messageThe message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default:

Response

{
   "status":0,
   "status_message":"ok",
   "message_token":5741311803571721087,
   "chat_hostname":"SN-CHAT-05_",
   "billing_status":1
}

Google Business Messages
The Google Business Messages app is required to use this set of APIs.

gbm-send-message
Sends a message to Google Business Messages.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter gbm-send-message.
google_conversation_id  RequiredThe Google ID. To get this information, the user must first send you a message through Google Business Messages. Get it by using the get-user function.
messageThe message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default:
tokenThe Google token. Get it from the response of this function. Always include it when possible for performance reasons. Default: false

Response

[
   "{...}",
   [
      "{...}"
   ],
   "5741311803571721087"
]

The first array element is the response, the second element is the response of the attachments sending, if any, the last element is the token.

LINE
The LINE app is required to use this set of APIs.

line-send-message
Sends a message to LINE.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter line-send-message.
line_id  RequiredThe LINE ID. To get this information, the user must first send you a message through LINE. Get it by using the get-user function.
messageThe message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default:

Response

{
"sentMessages": [
    {
        "id": "481156985669026149",
        "quoteToken": "fKOxH1EKOAKYFLW6fe8vFGoKl2I2UZocU6KcoZgwtVrSTQjLbXFVer3Z-UV-aNkxE5BAct3WZOJpHBxEQavyVfkmsVMSou2KBNSFSEwtwuGkDwzEiUNsJ4V9WBR_leJef0KCxvP-OO1Ma5mxmt4rXg"
    }
]
                                }

WeChat
The WeChat app is required to use this set of APIs.

wechat-send-message
Sends a message to WeChat.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter wechat-send-message.
open_id  RequiredThe WeChat ID. To get this information, the user must first send you a message through LINE. Get it by using the get-user function.
messageThe message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default: [].
tokenThe Google token. Get it from the response of this function. Always include it when possible for performance reasons. Default: false.

Response

[
   "{...}",
   "5741311803571721087"
]

The first array element is the response, the second element is the token.


Slack
The Slack app is required to use this set of APIs.

send-slack-message
Sends a message to Slack.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter send-slack-message.
user_id  RequiredThe ID of the user linked to the message.
full_name  RequiredThe name of the sender, it will appear in Slack on the left of the message. It should be an agent’s name if the message is from an agent, otherwise the user’s name.
profile_imageThe profile image of the sender, it will appear in Slack on the left of the message. It should be an agent’s profile image if the message is from an agent, otherwise the user’s profile image. Supported formats: PNG and JPG. Default: 
messageThe content of the message.
attachmentsArray of attachments in JSON format. Array syntax: [[“name”, “link”], [“name”, “link”], …]. Replace name with the name of the attachment and link with the full URL of the attachment. It’s up to you to upload attachments to a remote server, this argument only accepts the URL of the files already uploaded. Default: [].
channelThe Slack channel linked to the message. For performance reasons always include the channel. You will get the channel after the first call of this function, from the response (example: C011JFFGSKY).

Response

{“success”:true,”response”:[“C011JFFGSKY”]}

Other possible responses: slack-not-active, MySQL or cURL error message.

archive-slack-channels
Archives all the Slack channels. If you have a lot of channels, this operation may take a long time to complete and you could need to execute it again multiple times. Important: All of your slack channels will be archived.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter archive-slack-channels.

Response

{
    "success": true,
    "response": true
}

slack-users
Returns the agents-slack members’ connection information.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter slack-users.

Response

{
    "success": true,
    "response": {
        "slack_users": [
            {
                "id": "U328T701Z",
                "name": "Support Schio"
            },
            {
                "id": "UR5F0GK7T",
                "name": "Robert Pitt"
            }
            ...
        ],
        "agents": [
            {
                "id": "2",
                "name": "Alex Smith"
            },
            {
                "id": "445",
                "name": "Federico Schiocchet"
            },
            {
                "id": "724",
                "name": "Alberto Prade"
            }
            ...
        ],
        "saved": {
            "U328T701Z": "445",
            "UR5F0GK7T": "2"
            ...
        }
    }
}

slack-presence
Checks if a Slack agent is online, or if at least one agent is online, or returns all the online users.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter slack-presence.
agent_idThe ID of the agent to check. Default: false.
listSet it to true to return all online users. Default: false.

Response

{
    "success": true,
    "response": online
}

Returns online or offline for single agent check. Returns an array of user IDs for multiple users check.

slack-channels
Returns the list of all Slack channels, including archived channels.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter slack-channels.

Response

{
    "ok": true,
    "channels": [
        {
            "id": "C012AB3CD",
            "name": "general",
            "is_channel": true,
            "is_group": false,
            "is_im": false,
            "created": 1449252889,
            "creator": "U012A3CDE",
            "is_archived": false,
            "is_general": true,
            "unlinked": 0,
            "name_normalized": "general",
            "is_shared": false,
            "is_ext_shared": false,
            "is_org_shared": false,
            "pending_shared": [],
            "is_pending_ext_shared": false,
            "is_member": true,
            "is_private": false,
            "is_mpim": false,
            "updated": 1678229664302,
            "topic": {
                "value": "Company-wide announcements and work-based matters",
                "creator": "",
                "last_set": 0
            },
            "purpose": {
                "value": "This channel is for team-wide communication and announcements. All team members are in this channel.",
                "creator": "",
                "last_set": 0
            },
            "previous_names": [],
            "num_members": 4
        },
        {
            "id": "C061EG9T2",
            "name": "random",
            "is_channel": true,
            "is_group": false,
            "is_im": false,
            "created": 1449252889,
            "creator": "U061F7AUR",
            "is_archived": false,
            "is_general": false,
            "unlinked": 0,
            "name_normalized": "random",
            "is_shared": false,
            "is_ext_shared": false,
            "is_org_shared": false,
            "pending_shared": [],
            "is_pending_ext_shared": false,
            "is_member": true,
            "is_private": false,
            "is_mpim": false,
            "updated": 1678229664302,
            "topic": {
                "value": "Non-work banter and water cooler conversation",
                "creator": "",
                "last_set": 0
            },
            "purpose": {
                "value": "A place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber you'd prefer to keep out of more focused work-related channels.",
                "creator": "",
                "last_set": 0
            },
            "previous_names": [],
            "num_members": 4
        }
    ],
    "response_metadata": {
        "next_cursor": "dGVhbTpDMDYxRkE1UEI="
    }
}

Webhooks
slack-message-sent
Webhook sent when a message is sent to Slack.

Response

{
    "function": "slack-message-sent",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "message": "Hi! How are you doing?",
        "conversation_id": "1057",
        "slack_channel": "C028BGU6TTT"
    }
}

WooCommerce
The WooCommerce app is required to use this set of APIs.

woocommerce-get-customer
Returns the details of a WooCommerce customer.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-customer.
session_key  RequiredGet it with the method woocommerce-get-session-key.

Response

{
    "success": true,
    "response": {
        "customer_id": "1",
        "user_id": null,
        "username": "",
        "first_name": "Don",
        "last_name": "John",
        "email": "email@example.com",
        "date_last_active": "2020-08-03 07:21:18",
        "date_registered": null,
        "country": "UK",
        "postcode": "E14HR",
        "city": "London",
        "state": "London"
    }
}

woocommerce-get-user-orders
Returns an array with the orders summary of the user.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-user-orders.
user_id  RequiredThe user ID.

Response

{
    "success": true,
    "response": [
        {
            "id": "603",
            "date": "2020-10-22 14:58:11",
            "total": "19",
            "status": "wc-processing"
        },
        {
            "order_id": "602",
            "date": "2020-10-19 14:02:35",
            "total": "19",
            "status": "wc-on-hold",
        },
        ...
    ]
}

woocommerce-get-order
Returns the details of an order.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-order.
order_id  RequiredThe order ID.

Response

{
    "success": true,
    "response": {
        "id": "601",
        "date": "2020-10-19 14:02:10",
        "total": "19",
        "status": "wc-on-hold",
        "products": [
            {
                "name": "Sony Play Station 5",
                "id": "53",
                "quantity": "1",
                "price": "199"
            }
        ],
        "billing_address": "Don John\\n501 Baker Street\\nEW578H London, UK",
        "shipping_address": "",
        "currency_symbol": "€"
    }
}

woocommerce-get-product
Returns the details of a product.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-product.
product_id  RequiredThe product ID.

Response

{
    "success": true,
    "response": {
        "id": "53",
        "name": "Sony Play Station 5",
        "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elite...",
        "price": "19",
        "image": "https://example.com/image.jpg",
        "rating": "",
        "url": "https://example.com/?p=53"
    }
}

woocommerce-get-products
Returns the products matching the given query if any, otherwise returns all products.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-products.
filtersArray of filters. Syntax: [ “filter” => “value”, “filter” => “value”, … ]. Use filters to only get products that match specific criteria. Available filters: taxonomy  Taxonomy ID or name. Categories and tags are taxonomies. attribute  Product attribute term name. Example: color, size. date  Product publication date. If the value is a string, returns only the products older than the given date. If the value is an array, returns the products between the given dates. Array syntax: [ “startDate” => “”, “endDate” => “” ]. Multiple date formats are supported. Example: 2020-12-30 06:35:59. max-price  Product max price. Returns only the products with a price lower than the give one. min-price  Product min price. Returns only the products with a price larger than the give one. discounted  Products in promotion. Set it to true to get only the products in promotion.
paginationLimit the number of results to 100. Set it to 0 to get the products from 1 to 100, to 1 to get the products from 101 to 200…
languageThe products language code. Default: false.

Response

{
    "success": true,
    "response": [
        {
            "id": "53",
            "name": "Sony Play Station 5",
            "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elite...",
            "date": "2020-08-03 07:06:25",
            "price": "19",
            "image": "https://example.com/image.jpg",
            "rating": "",
            "url": "https://example.com?p=53"
        },
        {
            "id": "54",
            "name": "Xbox Series X",
            "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elite...",
            "date": "2020-08-03 07:08:19",
            "price": "59",
            "image": "https://example.com/image.jpg",
            "rating": "",
            "url": "https://example.com?p=54"
        },
        ...
    ]
}

woocommerce-search-products
Returns the products matching the search.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-search-products.
search  RequiredThe search string.

Response

{
    "success": true,
    "response": [
        {
            "id": "53",
            "name": "Sony Play Station 5",
            "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elite...",
            "date": "2020-08-03 07:06:25",
            "price": "19",
            "image": "https://example.com/image.jpg",
            "rating": "",
            "url": "https://example.com?p=53"
        },
        {
            "id": "54",
            "name": "Xbox Series X",
            "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elite...",
            "date": "2020-08-03 07:08:19",
            "price": "59",
            "image": "https://example.com/image.jpg",
            "rating": "",
            "url": "https://example.com?p=54"
        },
        ...
    ]
}

woocommerce-get-taxonomies
Returns the WooCommerce product categories or tags.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-taxonomies.
type  RequiredEnter category or tag.
languageThe language code of the taxonomies. Default: false.

Response

{
    "success": true,
    "response": [
        {
            "id": "33",
            "name": "Clothes",
            "slug": "clothes"
        },
        {
            "id": "34",
            "name": "Accessories",
            "slug": "accessories"
        },
        ...
    ]
}

woocommerce-get-attributes
Returns the WooCommerce product attributes and attribute terms.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-attributes.
typeSet it to terms to get only the terms name of all attributes, and to attribute to get only the attributes name. Default: all.
languageThe language code of the attributes. Default: false.

Response

All

{
    "success": true,
    "response": {
        "colors": {
            "id": "1",
            "name": "Color",
            "slug": "pa_color",
            "terms": {
                "red": "Red",
                "yellow": "Yellow",
                "green": "Green",
                ...
            }
        },
        ...
    }
}

Terms

{
    "success": true,
    "response": [
        {
            "name": "Red"
        },
        {
            "name": "Yellow"
        },
        {
            "name": "Small"
        },
        {
            "name": "Medium"
        },
        {
            "name": "Large"
        },
        ...
    ]
}

Attributes

{
    "success": true,
    "response": [
        {
            "id": "1",
            "name": "Color",
            "slug": "pa_color"
        },
        {
            "id": "2",
            "name": "Size",
            "slug": "pa_size"
        },
        ...
    ]
}

woocommerce-get-product-id-by-name
Searches for a product by name and returns its ID.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-product-id-by-name.
name  RequiredThe product name

Response

{
    "success": true,
    "response": 123 or false
}

woocommerce-get-product-images
Returns an array with the images of a product

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-product-images.
product_id  RequiredThe product ID.

Response

{
    "success": true,
    "response": [
        "https://example.com/image.jpg",
        "https://example.com/image.jpg",
        ...
    ]
}

woocommerce-get-product-taxonomies
Returns the categories and tags of a product.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-product-taxonomies.
product_id  RequiredThe product ID.

Response

{
    "success": true,
    "response": [
        {
            "term_id": "34",
            "name": "Red",
            "slug": "red",
            "term_group": "0",
            "taxonomy": "product_cat"
        },
        {
            "term_id": "35",
            "name": "Summer Edition",
            "slug": "summer-edition",
            "term_group": "0",
            "taxonomy": "product_tag"
        },
        ...
    ]
}

woocommerce-get-attribute-by-term
Returns the attribute of an attribute term.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-attribute-by-term.
term_name  RequiredThe term name.

Response

{
    "success": true,
    "response": {
        "id": "1",
        "name": "Color",
        "slug": "pa_color"
    }
}

woocommerce-get-attribute-by-name
Searches for an attribute by its name and returns it.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-attribute-by-name.
name  RequiredThe attribute name.

Response

{
    "success": true,
    "response": {
        "id": "1",
        "name": "Color",
        "slug": "pa_color"
    }
}

woocommerce-is-in-stock
Checks if a product is in stock.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-is-in-stock.
product_id  RequiredThe product ID.

Response

{
    "success": true,
    "response": true or false
}

woocommerce-coupon
Generates a coupon and returns the coupon code.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-coupon.
discount  RequiredDiscount percentage. Enter a value from 1 to 100.
expiration  RequiredCoupon expiration. Example: 3 days, 1 minutes, 60 seconds.
product_idString of IDs separated by commas. Example: 11,53,63. If setted the coupon is valid only for the products with the given IDs.
user_idIf setted the coupon is valid only for the user with the given ID.

Response

{
    "success": true,
    "response": [ "fxsocl3490oq", "50" ]
}

[ coupon code, discount value ]

woocommerce-coupon-check
Check sif there are coupons linked to the given user.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-coupon-check.
user_id  RequiredThe user ID.

Response

{
    "success": true,
    "response": true or false
}

Returns true if there are coupons linked to the user, otherwise returns false.

woocommerce-coupon-delete-expired
Deletes all expired coupons. This function runs automatically every hour via cron jobs.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-coupon-delete-expired

Response

{
    "success": true,
    "response": true
}

woocommerce-get-url
Returns a WooCommerce URL.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-url.
type  RequiredThe URL type to get. Accepted values: tag, category, cart, shop, , checkout.
nameThe name of the category or link.
languageThe language of the page of the URL. Default: false

Response

{
    "success": true,
    "response": "https://example.com/checkout"
}

woocommerce-get-session
Returns the session variable of a user. The session variable contains the user cart details and more.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-session.
session_keyThe session key of a user. Get it with the method woocommerce-get-session-key

Response

{
    "success": true,
    "response": {
        "cart": {
            "d82c8d1619ah8176d665453cfb2e66f0": {
                "key": "d82c8d1619ah8176d665453cfb2e66f0",
                "product_id": 53,
                "variation_id": 0,
                "variation": [],
                "quantity": 3,
                "data_hash": "b5c1d6ca8bae6d4896jf1807cdf713f0",
                "line_tax_data": {
                    "subtotal": [],
                    "total": []
                },
                "line_subtotal": 57,
                "line_subtotal_tax": 0,
                "line_total": 57,
                "line_tax": 0
            }
        },
        "cart_totals": {
            "subtotal": "57.00",
            "subtotal_tax": 0,
            "shipping_total": "0.00",
            "shipping_tax": 0,
            "shipping_taxes": [],
            "discount_total": 0,
            "discount_tax": 0,
            "cart_contents_total": "57.00",
            "cart_contents_tax": 0,
            "cart_contents_taxes": [],
            "fee_total": "0.00",
            "fee_tax": 0,
            "fee_taxes": [],
            "total": "57.00",
            "total_tax": 0
        },
        "applied_coupons": "a:0:{}",
        "coupon_discount_totals": "a:0:{}",
        "coupon_discount_tax_totals": "a:0:{}",
        "removed_cart_contents": "a:0:{}",
        "customer": {
            "id": "1",
            "date_modified": "2020-08-20T09:33:03+00:00",
            "postcode": "",
            "city": "",
            "address_1": "",
            "address": "",
            "address_2": "",
            "state": "",
            "country": "",
            "shipping_postcode": "",
            "shipping_city": "",
            "shipping_address_1": "",
            "shipping_address": "",
            "shipping_address_2": "",
            "shipping_state": "",
            "shipping_country": "",
            "is_vat_exempt": "",
            "calculated_shipping": "",
            "first_name": "",
            "last_name": "",
            "company": "",
            "phone": "",
            "email": "",
            "shipping_first_name": "",
            "shipping_last_name": "",
            "shipping_company": ""
        }
    }
}

woocommerce-get-session-key
Returns the session key of a user.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-get-session-key.
user_id  RequiredThe user ID.

Response

{
    "success": true,
    "response": "f96ab7c6da236e6754d"
}

woocommerce-payment-methods
Returns the available payment methods of the shop.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-payment-methods.

Response

{
    "success": true,
    "response": [
        "Direct bank transfer",
        "Check payments",
        "Cash on delivery",
        "Alipay",
        "Multibanco",
        "Credit Card (Stripe)"
    ]
}

woocommerce-shipping-locations
Returns the shop shipping locations, or checks if the shop ships to a specific location.

Arguments

token  RequiredYour admin secret token.
function  RequiredEnter woocommerce-shipping-locations.
country_codeA country code. If provided checks if the shop ships to the country of the given given code. Default: false.

Response

{
    "success": true,
    "response": [
        "Australia, Italy, United States, ...",
        [
            [
                "Australia",
                "AU"
            ],
            [
                "Italy",
                "IT"
            ],
            [
                "United States",
                "US"
            ],
            ...
        ],
        false
    ]
}

The last array value is true if the shop does not ship to the returned countries.

Webhooks
Webhooks are automated messages sent from Support Board to a URL when something happens. They contain custom data and are sent to a unique URL defined by you.

Usage

  • Login to the administration area and go to Settings > Miscellaneous > Webhooks
  • Enter the destination URL. Support Board will send the data to this URL. This URL should point to a PHP file that can read the data received, you can use the code $response = json_decode(file_get_contents(‘php://input’), true); to get the data, the $response variable will be an array.
  • Enter in the Secret key field a secret password of your choice. This key is included in all the Webhooks, you can use it to validate the Webhook and make sure it is sent by Support Board and not from someone else.
  • Activate the Webhooks and save. Support Board will now start sending the Webhooks of the list below to your URL.
  • The key sender-url is included in all the Webhooks and contains the URL from which the webhook is sent.
  • The setting Active webhooks defines what webhooks are active. Enter names of the webhooks separated by commas. Leave it empty to enable all webhooks.

Missing Webhook?
Do you need a Webhook that is not yet available? Contact us and we will add it!

message-sent
Webhook sent when a new message is sent by a user or an agent.

Response

{
    "function": "message-sent",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "user_id": "947",
        "conversation_user_id": "947",
        "conversation_id": "1057",
        "conversation_status_code": "2",
        "conversation_source": "wa",
        "message_id": "2574",
        "message": "Hello! How are you?",
        "attachments": [["name","https://example.com/image.png"],["name","https://example.com/file.txt"]]
    }
}

email-sent
Webhook sent when a notification email is sent to a user or to an agent.

Response

{
    "function": "email-sent",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "recipient_id": "957",
        "message": "Hello! How can I help you?",
        "attachments": [["name","https://example.com/image.png"],["name","https://example.com/file.txt"]]
     }
}

sms-sent
Webhook sent when a new text message is sent by a user or an agent.

Response

{
    "function": "sms-sent",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "recipent_id": "947",
        "message": "Hello! How are you?",
        "Body": "Hello! How are you?",
        "From": "+15104564545",
        "To": "+15305431221",
        "response": {
            "sid": "SM1f0e8ae6ade43cb3c0ce4525424e404f",
            "date_created": "Fri, 13 Aug 2010 01:16:24 +0000",
            "date_updated": "Fri, 13 Aug 2010 01:16:24 +0000",
            "date_sent": null,
            "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            "to": "+15305431221",
            "from": "+15104564545",
            "body": "A Test Message",
            "status": "queued",
            "flags":["outbound"],
            "api_version": "2010-04-01",
            "price": null,
            "uri": "/2010-04-01/Accounts/ACXXXX/Messages/SM1f004f.json"
        }
    }
}

new-messages
Webhook sent when new messages are received in the chat widget or the admin area.

Response

{
    "function": "new-messages",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "details": {
            "message": "Hello world!",
            "message_id": "10231",
            "attachments": "",
            "payload": "",
            "message_status_code": "0",
            "last_update_time": "2024-04-02 16:57:19",
            "message_user_id": "1964",
            "message_first_name": "Don",
            "message_last_name": "John",
            "message_profile_image": "https://example.com/image.jpg",
            "message_user_type": "admin",
            "department": null,
            "agent_id": null,
            "title": "",
            "source": null,
            "extra": null,
            "tags": null,
            "id": "4607",
            "user_id": "4747",
            "creation_time": "2024-04-02 16:57:17",
            "status_code": "1"
        },
        "messages": [
            {
                "details": {
                    "message": "Hello world!",
                    "attachments": "",
                    "payload": {},
                    "status_code": "0",
                    "id": "10231",
                    "profile_image": "https://example.com/image.jpg",
                    "first_name": "Don",
                    "last_name": "John",
                    "user_id": "1964",
                    "user_type": "admin",
                    "full_name": "Don John",
                    "creation_time": "2024-04-02 16:57:19"
                }
            }
        ]
    }
}

dialogflow-message
Webhook sent when the Dialogflow send a reply to a user message.

Response

{
    "function": "dialogflow-message",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "response": {
            "token": "ya29.a0Afkjh8MADFYeT4BgCy3917xqSDdVvw4mgVHrgrLDcgRk9ajWoQAgdjv5e...",
            "messages": [
                {
                    "message": "Hi! How are you doing?"
                }
            ],
            "response": {
                "responseId": "46d2c208-2a7f-4ca2-bd7d-6636982b8bee-0f0e27e1",
                "queryResult": {
                    "queryText": "hi",
                    "action": "input.welcome",
                    "allRequiredParamsPresent": "true",
                    "fulfillmentText": "Hi! How are you doing?",
                    "fulfillmentMessages": [
                        {
                            "text": {
                                "text": [
                                    "Hi! How are you doing?"
                                ]
                            }
                        }
                    ],
                    "outputContexts": [
                        {
                            "name": "projects/api-project-655517752147/agent/sessions...",
                            "lifespanCount": "1",
                            "parameters": {
                                "no-input": "0",
                                "no-match": "0"
                            }
                        }
                    ],
                    "intent": {
                        "name": "projects/api-project-655517752147/agent/intents...",
                        "displayName": "Default Welcome Intent"
                    },
                    "intentDetectionConfidence": "1",
                    "languageCode": "en"
                },
                "alternativeQueryResults": [
                    {
                        "queryText": "hi",
                        "outputContexts": [
                            {
                                "name": "projects/api-project-655517752147/agent...",
                                "parameters": {
                                    "no-match": "1",
                                    "no-input": "0"
                                }
                            }
                        ],
                        "languageCode": "en"
                    }
                ]
            }
        },
        "message": "Hello",
        "conversation_id": 123456
    }
}

message-deleted
Webhook sent when a message is deleted.

Response

{
    "function": "message-deleted",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": "2595"
}

The data key contains the ID of the deleted message.

rich-message
Webhook sent when the user press the submit button and the values entered in the Rich Message are sent to Support Board. All Rich Messages that require the submitting of data fire this Webhook, some of them are the follow-up email form, the registration form, the buttons.

Response

{
    "function": "rich-message",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "result": true,
        "data": {
            "type": "inputs",
            "result": {
                "name": [
                    "Don Jhon",
                    "Name"
                ],
                "your-email": [
                    "example@gmail.com",
                    "Your Email"
                ],
                "site-url": [
                    "www.example.com",
                    "Site URL"
                ]
            }
        },
        "id": "example"
    }
}

new-conversation
Webhook sent when a new conversation is received in the user’s chat widget.

Response

{
    "function": "new-conversation-received",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "messages": [
            {
                "id": "10222",
                "user_id": "4746",
                "message": "Hi there!",
                "creation_time": "2024-04-02 07:26:18",
                "attachments": "",
                "status_code": "0",
                "payload": "",
                "conversation_id": "4605",
                "first_name": "User",
                "last_name": "#19332",
                "profile_image": "https://example.com/image.png",
                "user_type": "lead"
            },
            {
                "id": "10223",
                "user_id": "377",
                "message": "How are you?",
                "creation_time": "2024-04-02 07:26:22",
                "attachments": "",
                "status_code": "2",
                "payload": "{\"follow_up_message\":true,\"preview\":\"Preview text!\"]\"}",
                "conversation_id": "4605",
                "first_name": "Smart Assistant",
                "last_name": "",
                "profile_image": "https://example.com/image.png",
                "user_type": "bot"
            }
        ],
        "details": {
            "user_id": "4746",
            "first_name": "User",
            "last_name": "#19332",
            "profile_image": "https://example.com/image.png",
            "user_type": "lead",
            "id": "4605",
            "title": "",
            "status_code": "0",
            "creation_time": "2024-04-02 07:26:17",
            "department": null,
            "agent_id": null,
            "source": null,
            "extra": null,
            "extra_2": null,
            "extra_3": null,
            "tags": null,
            "busy": false
        }
    }
}

new-conversation-created
Webhook sent when a new conversation is created.

Response

{
    "function": "new-conversation-created",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "messages": [
            {
                "id": "10222",
                "user_id": "4746",
                "message": "Hi there!",
                "creation_time": "2024-04-02 07:26:18",
                "attachments": "",
                "status_code": "0",
                "payload": "",
                "conversation_id": "4605",
                "first_name": "User",
                "last_name": "#19332",
                "profile_image": "https://example.com/image.png",
                "user_type": "lead"
            },
            {
                "id": "10223",
                "user_id": "377",
                "message": "How are you?",
                "creation_time": "2024-04-02 07:26:22",
                "attachments": "",
                "status_code": "2",
                "payload": "{\"follow_up_message\":true,\"preview\":\"Preview text!\"]\"}",
                "conversation_id": "4605",
                "first_name": "Smart Assistant",
                "last_name": "",
                "profile_image": "https://example.com/image.png",
                "user_type": "bot"
            }
        ],
        "details": {
            "user_id": "4746",
            "first_name": "User",
            "last_name": "#19332",
            "profile_image": "https://example.com/image.png",
            "user_type": "lead",
            "id": "4605",
            "title": "",
            "status_code": "0",
            "creation_time": "2024-04-02 07:26:17",
            "department": null,
            "agent_id": null,
            "source": null,
            "extra": null,
            "extra_2": null,
            "extra_3": null,
            "tags": null,
            "busy": false
        }
    }
}

conversation-status-updated
Webhook sent when the status code of a conversation changes.

Response

{
    "function": "conversation-status-updated",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "conversation_id": "1057",
        "status_code": "0"
    }
}

Status codes: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4.

login
Webhook sent when a user login successfully from the login form of the chat. This Webhook is sent only if the login is successful.

Response

{
    "function": "login",
    "key": "xxxxxxxx",
    "data": {
        "details": {
            "id": "18",
            "profile_image": "https://schiocco.s3.amazonaws.com/3045506.png",
            "first_name": "Fede",
            "last_name": "",
            "email": "fede@fede.com",
            "user_type": "user",
            "token": "ec83c134e5d53be98abd0025145473eec0ff814e",
            "url": "https://sandbox.cloud.smartai.support\/script",
            "password": "$2y$10$vYtwWDEqOt7jMSBcCmPigOrqw06tdD8ZSFm70L6c1PLEQ8j938l2W",
            "conversation_id": "false"
        }
    },
    "sender-url": "http:\/\/localhost\/"

registration
Webhook sent when a user registers successfully from the registration form of the chat. This Webhook is sent only if the registration is successful. This Webhook is sent also if the registration is updated via the registration form of a Rich Message.

Response

{
    "function": "registration",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "id": "example",
        "conversation_id": "123", 
        "user": {
            "profile_image": [
                "https://smartai.support/user.svg",
                "Profile image"
            ],
            "first_name": [
                "Don",
                "First name"
            ],
            "last_name": [
                "John",
                "Last name"
            ],
            "email": [
                "example@email.com",
                "Email"
            ],
            "password": [
                "12345678",
                "Password"
            ],
            "password-check": [
                "12345678",
                "Repeat password"
            ],
            "user_type": [
                "user",
                ""
            ]
        },
        "extra": {
            "phone": [
                "+02123456789",
                "Phone"
            ],
            "city": [
                "London",
                "City"
            ]
        }
    }
}

user-deleted
Webhook sent when a user is deleted.

Response

{
    "function": "user-deleted",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": "951"
}

The data key contains the ID of the deleted user.

new-email-address
Webhook sent when a user register his email via follow-up message, subscribe message, or email rich message.

Response

{
    "function": "new-email-address",
    "key": "xxxxxxxx",
    "sender-url": "https://example.com",
    "data": {
        "name": "John Doe",
        "email": "email@example.com"
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Empowering your journey with seamless, intelligent support from our SmartAI system
Integration
subscribe us
SmartAI Support | Copyright 2024 | All Rights Reserved.