The PHP API supplies a collection of PHP functions that underpin the majority of Support Board functionality. To start using the PHP API follow the steps below.
Include the file functions.php in your PHP file. The file is located in the include folder of the plugin folder. If you are using the PHP or WP versions, you're done! You can start using the functions of this documentation.
require("include/functions.php");
Get the absolute path of your Support Board installation from Settings > Miscellaneous > Get Path. You can also use the variable $_SERVER["DOCUMENT_ROOT"]. E.g. require($_SERVER["DOCUMENT_ROOT"] . "/supportboard/include/functions.php");.
If you are using the SaaS version you also have to add the code sb_cloud_load(); immediately after the require("include/functions.php"); code. To make the functions related to a single customer work follow one of the methods below.
Functions to manage users, agents, and admins.
Log ins a user or agent. The login can be completed in two ways: via email and password, or user ID and token.
|
The email of the user to log in. If this attribute is set you need to set also the password. Default: empty string. |
password |
The password of the user to log in. If this attribute is set you need to set also the email. Default: empty string. |
user_id |
The ID of the user to log in. If this attribute is set you need to set also the token. Default: empty string. |
token |
The token of the user to log in. 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 string. |
[ { "id": "913", "profile_image": "https://board.support/user.svg", "first_name": "User", "last_name": "#29902", "email": null, "user_type": "visitor", "token": "9b25351047ee758aa97ee4868d130cc1ceb8decf" }, "YXNkWGNSeTdtRTdDYVkxVG8wckN4YWF6V2s0Tk1mczBSVHdQbHBpOWdmejVUTTdOUUxEUENhdUVoYmROWn..." ]
The last value is the encrypted login data ready to be stored in the Web Storage of the user' browser. Returns false if the login is unsuccessful.
Log outs the logged-in user, only on the server-side.
true
This function logout the user only from the server. Use the Javascript API function SBF.logout(); to log out the user also in the client-side.
Returns the user details of the logged-in user.
db |
Set it to true to check if the user exists in the database. Default: false. |
login_app |
Encrypted array with the email and password of the logged-in WordPress user. This argument is used only in the WordPress version. If set, the function returns the logged-in WordPress user. Use this code to generate the array: sb_encryption(json_encode(['id' => "", 'email' => "")). Default: false. |
[ { "id": "913", "profile_image": "https://board.support/user.svg", "first_name": "User", "last_name": "#29902", "email": null, "user_type": "visitor", "token": "9b25351047ee758aa97ee4868d130cc1ceb8decf" }, "YXNkWGNSeTdtRTdDYVkxVG8wckN4YWF6V2s0Tk1mczBSVHdQbHBpOWdmejVUTTdOUUxEUENhdUVoYmROWn..." ]
Returns the user details of the given user ID.
user_id |
The ID of the user. |
extra |
Set it to true to get also the extra user details. Default: false. |
{ "id": "123456", "first_name": "John", "last_name": "Doe", "email": "johon@example.com", "profile_image": "https://board.support/user.svg", "user_type": "visitor", "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" }, ... ] }
Returns the extra user details of the given user ID, or the requested one.
user_id |
The ID of the user. |
slug |
The slug of the setting to retrieve. If this argument is not set, all user details are returned. Default: false. |
default |
The default value to return if the user details are not found. Default: false. |
[ { "slug": "browser", "name": "Browser", "value": "Chrome" }, { "slug": "current_url", "name": "Current URL", "value": "https://board.support/" }, { "slug": "os", "name": "OS", "value": "Windows 10" }, { "slug": "phone", "name": "Phone", "value": "3203057977" }, ... ]
Returns the full name of the active user, or the given one.
user |
The user object. |
The user name string
Returns the user details of all the users.
sorting |
Set 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_types |
Array in JSON format of user types to include in the returned value. Array syntax: ["", "", "", ...]. Accepted values: visitor, lead, user, agent, admin. Default: all. |
search |
String with the search terms. |
pagination |
Integer from 1 to N to limit the results number. Enter 1 to get the first 100 results, 2 for the results from 101 to 200, etc. |
extra |
Set 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_ids |
Array of IDs. If set, returns only the users with ID included in the given array of IDs. Default: false. |
[ { "id": "880", "first_name": "User", "last_name": "#29938", "email": null, "profile_image": "https://board.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://board.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" }, ... ]
Returns the users created after the given date/ID.
datetime |
User ID or date and time in the following format: YYYY-MM-DD HH:MM:SS. Ex. 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. |
[ { "id": "880", "first_name": "User", "last_name": "#29938", "email": null, "profile_image": "https://board.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://board.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" }, ... ]
Returns the online users or the online agents and admins.
sorting |
The name of the database table used for sorting. Default: creation_time. |
agents |
Set it to true to return only agents and admins. Default: false. |
[ { "id": "881", "first_name": "Don", "last_name": "John", "email": null, "profile_image": "https://board.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://board.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 an array with the IDs of the online users and agents.
agents |
Set it to true to return only agents and admins, to agent to return only agents, to admin to return only admins. Default: false. |
[ 881, 548, 125, ... ]
Returns an array with the user IDs and details of the users who have the requested details.
details |
Array of user details. Ex. [ "email", "phone" ]. |
user_ids |
Array, 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. |
{ "email": [ { "id": 4561, "value": "albert@example.com" }, { "id": 98436, "value": "jessica@example.com" }, ... ], "phone": [ { "id": 12563, "value": "+4462367136" }, { "id": 778956, "value": "+4462999345" }, ... ], ... }
Returns the users matching the search.
search |
String with the search terms. Additional user details are supported too. |
[ { "id": "881", "first_name": "Don", "last_name": "John", "email": null, "profile_image": "https://board.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://board.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" }, ... ]
Creates a new user.
settings |
Array with the user details. Array keys and syntax: [ "profile_image" => "", "first_name" => "", "last_name" => "", "email" => "", "password" => "", "user_type" => "", "department" => "" ]. Accepted user_type values: visitor, lead, user, agent, admin. Default: visitor if the email is not provided, otherwise, user. |
settings_extra |
Array of additional user details. Array syntax: ["key" => ["value", "Name"], "key" => ["value", "Name"], ...]. Any detail is accepted. Built-in details (keys): phone, city, language, country, birthday, company, facebook, twitter, linkedin, website, ip, country_code, browser, currency, location, os, time_zone, current_url. |
login_app |
Encrypted array with the email and password of the logged-in WordPress user. This argument is used only in the WordPress version. If set, the new user will use the user details of the given WordPress user ID. Use this code to generate the array: sb_encryption(json_encode(['id' => "", 'email' => "")). Default: false. |
hash_password |
Set it to false to skip the password hashing. Use this setting if the passowrd is already hashed. Default: true. |
123456
Responses: ID of the new user on success, otherwise, duplicate-email, invalid-user-type, SQL error message.
Creates a new user, log ins it, and returns the login data for the client-side.
This function uses the same arguments of the sb_add_user() function.
This function returns the same response of the sb_login() function.
Adds additional user details to the user of the given ID. Existing user details will not be updated.
user_id |
The ID of the user to update. |
settings |
Array of additional user details. Array syntax: ["key" => ["value", "Name"], "key" => ["value", "Name"], ...]. Any detail is accepted. Built-in details (keys): phone, city, language, country, birthday, company, facebook, twitter, linkedin, website, ip, country_code, browser, currency, location, os, time_zone, current_url. |
true
Updates the details of an existing user.
user_id |
Enter the ID of the user to update. |
settings |
Array with the user details. Array keys and syntax: [ "profile_image" => "", "first_name" => "", "last_name" => "", "email" => "", "password" => "", "user_type" => "", "department" => "" ]. Accepted user_type values: visitor, lead, user, agent, admin. Default: visitor if the email is not provided, otherwise, user. |
settings_extra |
Array of additional user details. Array syntax: ["key" => ["value", "Name"], "key" => ["value", "Name"], ...]. Any detail is accepted. Built-in details (keys): phone, city, language, country, birthday, company, facebook, twitter, linkedin, website, ip, country_code, browser, currency, location, os, time_zone, current_url. |
hash_password |
Set it to false to skip the password hashing. Use this setting if the passowrd is already hashed. Default: true. |
true
Other possible responses: duplicate-email, invalid-user-type, SQL error message.
Updates a single detail, or extra detail, of an existing user, agent, or admin.
user_id |
The ID of the user to update. |
slug |
The unique name of the detail. Ex. first_name, email, city, birthday. |
value |
The new value of the detail. |
name |
The name of the extra detail. Required only if the user detail to update is an extra detail. |
true
Updates the login details of the logged-in user and returns the login data for the client-side. Use the Javascript API function SBF.loginCookie(response); to update the login details also in the client-side, the response is the response data returned by this function.
profile_image |
The URL of the profile image of the user. |
first_name |
The first name of the user. |
last_name |
The last name of the user. |
|
The email of the user. |
department |
The ID of the department of the user. You can get the IDs from Settings > Miscellaneous > Departments. No department ID validation is performed, so double-check the department ID to be sure it exists. |
YXNkWGNSeTdtRTdDYVkxVG8wckN4YWF6V2s0Tk1mczBSVHdQbHBpOWdmejVUTTdOUUxEUENhdUVoYmROWn...
Deletes a user and all the linked conversations and messages.
user_id |
The ID of the user to delete. |
true
Deletes multiple users and all the linked conversations and messages.
user_ids |
Array of IDs of the users to delete. Array syntax: [123, 123, 123, ...] |
true
Deletes all leads, including all the linked conversations and messages.
true
Gets or sets the current URL of the user or the last visited URL.
user_id |
The ID of the user |
url |
The 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. |
https://board.support
Return false if the URL is not found. Return true if the url argument is set.
Returns the total users' count grouped by user type.
{ "all": "335", "lead": "288", "user": "15", "visitor": "28" }
Changes the user type to lead.
user_id |
The ID of the user. |
true
Returns the agents-slack members' connection information. The Slack App is required.
{ "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" ... } }
true
Checks if the given password matches the given password hash. The password hash is saved in the database in the password column of the sb_users table.
password |
The password to check. |
hash |
The password hash. |
Return true if the password matches the hash, otherwise, return false.
Adds the following user details to the active user: city, location, country, timezone, currency, browser, browser language, os. These details are generated automatically.
user_id |
The ID of the active user. |
true
Checks if a user or agent is typing a message in a conversation.
user_id |
The ID of the user, or the agent, to check. |
conversation_id |
The ID of conversation to check. |
Return true if the user is typing, otherwise, return false.
Assigns the typing status to a user or agent relative to a conversation.
user_id |
The ID of the user or the agent. |
conversation_id |
The ID of conversation. |
source |
Array to set the typing status on external services. Facebook Messenger: ['fb', USER-ID, FB-PAGE-ID]. |
true
Checks if the given date and time are recognized as online by Support Board.
datetime |
Date and time in the following format: YYYY-MM-DD HH:MM:SS. Ex. 2020-05-13 13:35:59. You can remove the time and leave only the date. |
true if online, false if offline.
Checks if the user is online. This function is compatible with Pusher and Slack.
user_id |
The user ID. |
true if online, false if offline.
Returns the ID of the bot.
123456
Returns the details of the user, or last agent, of the given conversation.
conversation_id |
The conversation ID. |
agent |
Set it to true to get the last agent who replied to the conversation. Default: false. |
{ "id": "123456", "email": "email@example.com" }
Generates the user profile image by using the first letter of first name, and last name, save the image, and returns the image URL.
first_name |
The first name of the user. |
last_name |
The last name of the user. |
https://example.com/supportboard/uploads/13-04-21/9455859.png
Returns the ID of the active user.
The User ID.
Searches for a user with the specified user details and returns it.
by |
The user detail name. Accepted values: email, first_name, last_name, phone, [extra] (replace [extra] with any user additional detail name). |
value |
The value of the field. |
{ "id": "881", "first_name": "Don", "last_name": "John", "email": "example@example.com", "user_type": "visitor", "department": null }
Updates the profile details of the chatbot. If the chatbot is not found a new chatbot profile is created.
name |
The bot name. |
profile_image |
The bot profile image URL. |
Returns true on success, false otherwise.
Functions related to agents and admins only. For more functions visit the users section.
Returns an array with the IDs of Agents.
admins |
Set it to false to exclude the admins. Default: true; |
[ 881, 153, ... ]
Checks if the active admin is the supervisor and returns the supervisor settings if true.
Return the supervisor settings if the active agent ID is the same of the one set in Settings > Admin > Supervisor > Admin ID, otherwise returns false.
Returns the profile details of an agent or admin.
agent_id |
The agent ID. |
{ "id": "881", "first_name": "Don", "last_name": "John", "email": "example@example.com", "user_type": "visitor", "department": null }
Checks if the given user type string is an admin, an agent, or the bot.
user |
A Support Board user, or a string. |
exclude_bot |
Set it to true to return false if the active user is the bot. Default: false. |
admin |
Set it to true to return true only if the active user is an administrator. Default: false. |
Return true if the user type string is "admin", "agent", or "bot", otherwise return false.
Returns the department of the active agent or admin.
Returns the department ID if set, otherwise, return false.
Checks if an agent is typing a message in a conversation, and returns the agent details.
conversation_id |
The ID of conversation to check. |
{ "id": "", "first_name": "", "last_name": "" }
Return false if no agents are typing.
Checks if at least one agent or admin is online.
Returns true if there are agents or admin online, or false if all Agents are offline.
Functions to manage conversations and messages.
Returns a conversation and the messages of the conversation.
user_id |
The ID of the user linked to the conversation. |
conversation_id |
The conversation ID. |
{ "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://board.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://board.support/agent.svg", "user_type": "agent" }, ... ], "details": { "user_id": "802", "first_name": "Don", "last_name": "John", "profile_image": "https://board.support/user.svg", "user_type": "lead", "id": "946", "title": "", "conversation_time": "2020-05-0410:06:30", "conversation_status_code": "3", "department": null } }
Returns all the conversations. Each conversation includes the last message of the conversation.
pagination |
Integer from 1 to N to limit the results number. Enter 1 to get the first 100 results, 2 for the results from 101 to 200, etc. |
status_code |
The status code of the returned conversations. Default: all the conversations in the inbox, excluding conversations in 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. |
department |
Returns only the conversations assigned to the provided department ID. |
source |
Returns 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), ln (LINE), vb (Viber). |
tag |
Returns only the conversations assigned to the specified tag. |
[ { "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" }, ... ]
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.
datetime |
Conversation ID or date and time in the following format: YYYY-MM-DD HH:MM:SS. Ex. 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. |
[ { "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" }, ... ]
Returns the conversations of a user. Each conversation includes the last message of the conversation.
user_id |
The ID of the user of the conversations to get. |
exclude_id |
Exclude a conversation from the results. |
agent |
Set it to true if the user is an agent or admin. Default: false. |
[ { "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 the ID of the last user conversation if any, otherwise create a new conversation and returns its ID.
user_id |
The ID of the user. |
conversation_status_code |
The status code of the conversation to create if not conversations are found. Status codes: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4. |
The conversation ID
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.
user_id |
The ID of the user of the conversations to get. |
datetime |
Conversation ID or date and time in the following format: YYYY-MM-DD HH:MM:SS. Ex. 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. |
[ { "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 the conversations matching the search terms.
search |
String with the search terms. The search function supports attachment names, messages of the conversations, user email, and name of a message of the conversation. |
[ { "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" }, ... ]
Returns the conversations of the active user or given user ID that matches the search terms.
search |
String with the search terms. The search function supports attachment names, messages of the conversations, and the conversation title. |
user_id |
The ID of the user. Default: active user ID |
[ { "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 }, ... ]
Creates a new conversation.
user_id |
The ID of the user linked to the conversation. |
status_code |
The status code of the conversation. Default: 1. Status codes: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4. |
title |
The title of the conversation. Default: empty string. |
department |
The ID of a department. You can get the IDs from Settings > Miscellaneous > Departments. Default: -1. |
agent_id |
The ID of the agent assigned to the conversation. Default: -1. |
source |
Set the conversation source. Default: false. |
extra |
Extra value. Default: false. |
extra_2 |
Extra value. Default: false. |
extra_3 |
Extra value. Default: false. |
tags |
Conversation tags separated by commas. The value can be also an array. Default: false. |
{ "messages": [], "details": { "user_id": "882", "first_name": "Don", "last_name": "John", "profile_image": "https://board.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, SQL error message
Updates the status code of a conversation.
conversation_id |
The conversation ID. |
status_code |
The status code of the conversation. Status codes: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4. |
true
Return invalid-status-code if the status code is invalid.
Updates the department of a conversation and optionally sends an email to all the agents in the new department.
conversation_id |
The ID of the conversation to update. |
department |
The ID of a department. You can get the IDs from Settings > Miscellaneous > Departments. No department ID validation is performed, so double-check the department ID to be sure it exists. |
message |
A message to send to the agents. If set, an email with the message will be sent to all the agents to notify the department change. |
true
Assigns a rating to a conversation and optionally updates a message of the conversation.
settings |
Enter the following array: [ "settings" => [ "conversation_id" => "ID", "rating" => "RATING" ] ]. Replace ID with the ID of the conversation to rate, replace rating with 1 for a positive rating, with 0 for a negative rating. |
payload |
The message payload in JSON format. |
message_id |
The ID of the message to update. |
message |
The content of the message. |
user_id |
The user ID of the conversation linked to the message. |
true
Gets the ratings of the conversations assigned to an agent.
user_id |
The ID of the agent. |
[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.
Returns the messages of a conversation created after the given date/ID.
user_id |
The ID of the user of the conversation. |
conversation_id |
The conversation ID. |
datetime |
Date and time in the following format: YYYY-MM-DD HH:MM:SS. Ex. 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. |
last_id |
ID of the last message, use this parameter to exclude all messages with a lower ID. |
[ { "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://board.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://board.support/user.svg", "user_type": "lead" }, ... ]
Returns the last message in a conversation.
conversation_id |
The conversation ID. |
exclude_message |
If set, excludes the message with the specified text. Default: false. |
user_id |
If set, checks only the messages created by the specified user ID. Default: false. |
{ "message": "Welcome to our support chat!", "attachments": "", "payload": "" }
Adds a new message to an existing conversation.
sender_id |
The ID of the user who sends the message. |
conversation_id |
The conversation ID. |
message |
The content of the message. |
attachments |
Array of attachments. 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 |
The status code of 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. |
payload |
Array of additional information. You can enter any value. Array syntax: { "key": value, "key": value, ... }. Use this attribute to set an event. Available events: delete-message, open-chat. |
queue |
Set it to true if the queue is active in Settings > Miscellaneous > Queue. Default: false. |
recipient_id |
The ID of the user who receive the message. Use this attribute to get the user language. |
{ "status": "success", "message-id": 123456, "queue": false, "notifications": ["sms", "email"], "message": "Text of the message" }
Other possible responses: invalid-status-code, SQL error message. The notifications response include the notifications sent to the user or agents.
Sends a direct chat message, email, or text message to a single user, or several users. No email and text message notifications are sent for direct chat message. You need to send the notifications manually via sb_email() and sb_send_sms().
user_ids |
Array, or comma-separated string of user IDs to send the message to. Set it to all to send the message to all users. |
message |
The message. |
true
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.
message |
The message. |
conversation |
The conversation object, or the conversation ID. |
message_id |
The ID of the Support Board message. Use this argument to avoid duplicated messages. |
true
Sends a message to Slack. The Slack App is required and Slack must be active in the settings area.
["success", "C011JFFGSKY"]
Other possible responses: slack-not-active, SQL, or cURL error message.
Updates an existing message.
message_id |
The ID of the message. |
message |
The content of the message. |
attachments |
Array of attachments. 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: []. |
payload |
Array of additional information. You can enter any value. Array syntax: { "key": value, "key": value, ... }. |
true
Updates the status code of multiple messages.
message_ids |
Array of message IDs, e.g. [1, 212, 124]. |
user_id |
The ID of the user linked to the messages. Required to update the user's chat if Pusher is active. |
true
Deletes an existing message.
message_id |
The ID of the message to delete. |
true
Deletes all attachments of a conversation or message, including the ones stored in AWS S3.
conversation_id |
The ID of the conversation containing the attachments to delete. Default: false. |
message_id |
The ID of the message containing the attachments to delete. Default: false. |
true
Sends the close message to a user conversation. The close message' contents can be set in the Settings > Chat > Close message area.
conversation_id |
The ID of the conversation to send the message to. |
bot_id |
The ID of the sender user. Usually the bot ID. You can get the bot ID with the function sb_get_bot_id(); |
{ "status": "success", "message-id": 123456 }
Converts the text formatting of chat messages to the equivalent HTML codes and returns the message.
message |
The text message. |
Lorem ipsum dolor <b>sit amet</b>, <i>consectetur adipiscing elit</i>, <code>sed</code> do eiusmod tempor incididunt.
Removes the text formatting from a chat messages.
message |
The text message. |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.
Checks if the active user is authorized to update the conversation. Agents and admins can always update all conversations, users can only update their own conversations.
conversation_id |
The conversation ID. |
Returns true if the active user is not authorized, otherwise, returns false.
Checks if an agent is replying to a conversation. This function checks if the function sb_set_agent_active_conversation() has been executed for the given conversation by another agent within 2 hours.
agent_id |
The agent ID. |
skip |
Set it to the active user ID to exclude the active agent from the check. Default: -1. |
Returns true if an agent is replying to the conversation.
Notify that an agent is responding to a conversation. The conversation is marked as busy for 2 hours if this function is not executed again by the same agent for another conversation.
conversation_id |
The conversation ID. |
agent_id |
The agent ID. Default: active user ID. |
Returns an array with all the agents with at least one message in the conversation.
conversation_id |
The conversation ID. It can be an array of conversation IDs. |
{ "1546": [ { "id": 5463, "first_name": "Don", "last_name": "John", "profile_image": "https://board.support/user.svg", "conversation_id": 1546 }, { "id": 6413, "first_name": "Steven", "last_name": "Travolta", "profile_image": "https://board.support/user.svg", "conversation_id": 1546 }, ... ], ... }
Changes the agent assigned to a conversation or assigns it. This feature also sends notifications to other agents notifying the change, refreshing the chat widget if needed, and triggering the related event.
conversation_id |
The conversation ID. |
agent_id |
The agent ID. Set it to routing to lets Support Board assigning the correct agent by following the routing rules. Set it to routing-unassigned to remove the assigned agent from the conversation. |
message |
The message of the agents notifications. Set it to send the notifications. Default: false. |
Returns true on success, otherwise returns false.
Returns the nubmer of conversations with the specified status code.
status_code |
The status code of the conversations. Available values: live = 0, waiting answer from user = 1, waiting answer from agent = 2, archive = 3, trash = 4. Set it to false to count all conversations. Default: false. |
123456
Checks if the specified conversations are assigned to the specified agent or department and returns only unassigned conversation IDs.
conversation_ids |
The ID of the conversations to check. |
agent_id |
The agent ID. Default: false. |
department |
The department ID. Default: false. |
[12, 345, 6, ...]
Returns the last agent who answered a conversation.
conversation_id |
The conversation ID. |
{ "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.
Sends a bot message and returns its content.
name |
The bot message name. Available values: offline, follow_up, welcome. |
conversation_id |
The ID of the conversation to send the message to. |
last_user_message |
Use it to display different text excerpts in the admin area and chat dashboard. Default: false. |
check |
Set it to false to send the message also if it was already sent less than 10 days ago. Default: true. |
{ "message": "Lorem ipsum dolor", "attachments": [], "id": 123, "settings": { "active": true, "title": "", "message": "" } }
ID is the ID of the message that was just created.
Functions to read data from the database and to save data in it.
Returns the data of a SQL query.
query |
The SQL query. |
single |
Set it to false if the query should returns multiple results. Default: true. |
The result of the query as a single value or as an array of values. Return SBError if the query is invalid.
Runs a SQL query to update the data in the database.
query |
The SQL query. |
return |
Set it to true if the query should returns a value. Default: false. |
Return true, the returns value, or SBError if the query is invalid.
Escapes special characters in a string for use it in an SQL query. Use this function to escape every variable used in a SQL query containing strings without a known value.
value |
The string to escape. |
Returns the escaped string.
Converts an array to JSON and escapes the values for using them in an SQL query. Use this function to convert every variable containing arrays that is used in a SQL query.
array |
The array to convert and escape. |
Returns the converted array.
Checks if the database connection is valid or checks if the details provided are valids. All arguments are optional. If an argument is not provided will be used the one provided during the installation.
name |
The database name. |
user |
The database username. |
password |
The database password. |
host |
The database host. |
name |
The database port. |
Returns true if the connection is valid, otherwise, returns the connection error message.
Functions to translate strings in other languages and to manage the translations.
Translates a string to the active user language. Use the function sb_e($string) to translate and echo the string. Use sb_s to translate a setting and sb_se to translate and echo it.
string |
The string to translate. |
Returns the translated string if available, otherwise, returns the original string.
Returns the translations of the back-end and the front-end, for all the available languages.
{ "ar": { "name": "Arabic", "front": { "Activities": "أنشطة", "All": "الكل", ... }, "admin": { "A conversation was started by": "", "Activate": "", ... }, "admin/js": { "Add new user": "", "Add translation": "", ... }, "admin/settings": { "Active for agents": "", "Active for users": "", ... } }, "da": { "name": "Danish", "front": { "Activities": "Aktiviteter", "All": "Alle", ... }, ... }, ... }
Returns the translations of the back-end and the front-end of a single language.
{ "name": "Arabic", "front": { "Activities": "أنشطة", "All": "الكل", ... }, "admin": { "A conversation was started by": "", "Activate": "", ... }, "admin/js": { "Add new user": "", "Add translation": "", ... }, "admin/settings": { "Active for agents": "", "Active for users": "", ... } }
Saves the translations and overwrites 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.
translations |
The translations array with all the translations. Use the function sb_get_translations() to get it. |
true
Returns the active language code used by the user. By default, it's the user browser language.
user_id |
The ID of the user from whom you want to get the language. Default: false. |
The two-digit language code. Examples: es, it.
Returns the language code of the admin area relative to the active user.
user_id |
The ID of the agent or admin from whom you want to get the language. Default: false. |
The two-digit language code. Examples: es, it.
Translates a string in the language of the specified language code if the translation is available(only for front translations). Otherwise, if the Artificial Intelligence app is active and the multilingual translation setting is enabled, the string will be translated into the user's language.
string |
The string to translate. |
language_code |
The two-letter language code. Set it to false to use the active user language. Default: false. |
Returns the translated string, otherwise returns the original string.
Functions related to settings, articles, translations and more.
Returns a setting of the settings area.
setting |
The 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(). |
Returns the value of the setting.
Returns an array with all the settings.
{ "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" ], ... }
Saves the chat settings. This function overwrites all settings with the given ones.
settings |
Array of settings. You can get the array of the current settings with the function sb_get_settings(). |
external_settings |
Array of additional settings. Each value of the array is saved in a new row of the table sb_settings of the database. Default []. |
external_settings_translations |
Array of translations of the external settings. Each language of the array is saved in a new row of the table sb_settings of the database. Array syntax: [ "es" => [], "it" => [], ...]. Default []. |
true
Returns the translated value of a multilingual setting.
name |
The setting name. Set it to emails to get the emails settings. |
sub_name |
The ID of the sub setting. Ex. email-agent. Get the list of all IDs from the file resources/json/settings.json. |
language |
The language code. If there are no translations for the given language code, or if it's set to false or en, the default language is returned instead. Default: false. |
Returns the value of the setting in the specified language if available, otherwise returns the value of the setting in the original language.
Returns an external setting. External settings are saved on a dedicated database row.
setting |
The setting name. |
default |
The value to return if the setting is not found. Default: false. |
Returns the value of the setting if available, otherwise returns the default value.
Saves an external setting. External settings are saved on a dedicated database row.
name |
The setting name. |
value |
The setting value. |
true
Returns a subsetting of another setting.
id |
The 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 |
The 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(). |
default |
The value to return if the setting is not found. Default: false. |
Returns the value of the subsetting if available, otherwise returns the default value.
Exports all Support Board settings to a JSON file and returns the URL of the file.
{ "success": true, "response": "http://example.com/supportboard/uploads/settings_855776223.json" }
Imports the Support Board settings from a JSON file generated via the export-settings function.
file_url |
The URL of the JSON file containing the settings. |
true
Returns the Support Board departments.
{ "1": { "name": "Example", "color": "yellow", "image": "https://example.com/image.png" }, "2": { "name": "Example", "color": "red", "image": "https://example.com/image.png" }, ... }
Article/Knowledge Base functions.
Returns an array with all the articles or a single article.
id |
The ID of the article. Add multiple IDs separated by commas. To get the article IDs execute this function without any argument. Default: false. |
count |
The maximum number of returned articles. Default: all. |
full |
Set it to true to get full-length articles contents. Default: false. |
categories |
Boolean. Set it to true to get the array of all categories. If true the response is a double array, first item articles, second item categories. Default: false. |
articles_language |
Get 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. |
[ { "id": "6P2Oq", "title": "What's new with the API V2?p", "content": "The API V2 is the new iteration of o ...", "link": "https://board.support" "categories": ["ols85"] }, { "id": "qf7kD" "title": "Should I move to the new API?", "content": "Yes. The newest version (V2) of the Actions ...", "link": "https://board.support", "categories": [] }, ... ]
Single article response
{ "id": "6P2Oq", "title": "What's new with the API V2?p", "content": "The API V2 is the new iteration of our developer API. The new API integrates...", "link": "https://board.support", "categories": ["ols85"] }
Saves all the articles. This function replaces all the existing articles with the articles of the given array.
articles |
The array with the articles. Use the function
sb_get_articles() to get the articles array.
Array syntax:
[["id" => "", "title" => "", "content" => "", "link" => ""] , ["title" => "", "content" => "", "link" => "", "id" => ""], ...] |
categories |
Array of category IDs. Set it to delete_all to delete all categories. |
translations |
The array with the articles translations. Use the function
sb_get_articles() to get the articles array.
Array syntax:
[ "es" => [["id" => "", "title" => "", "content" => "", "link" => ""], ...], "it" => [...], ...] |
true
Returns the articles matching the search.
search |
String with the search terms. The search function supports the title and the content. |
articles_language |
Search 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. |
[ { "id": "6P2Oq", "title": "What's new with the API V2?p", "content": "The API V2 is the new iteration of o ...", "link": "https://board.support", "categories": ["ols85"] }, { "id": "qf7kD" "title": "Should I move to the new API?", "content": "Yes. The newest version (V2) of the Actions ...", "link": "https://board.support", "categories": [] }, ... ]
Returns an array with all the articles categories.
[ { "id": "Nv9PG", "title": "Business" }, { "id": "csPVh", "title": "Travel And Tourism" }, { "id": "pl5S7", "title": "Finance" }, ... ]
Saves or update the articles categories array.
categories |
Array of categories. Array syntax: [ { "id": "123456", "title": "Category name" }, { "id": "123456", "title": "Category name" }, ...]. Get the existing categories array with the function get_articles_categories(). |
true
Gets the ratings of an article or adds a new rating to it.
article_id |
The ID of the article. |
rating |
The rating to add. Enter 1 for a positive rating or 0 for a negative one. If this argument is set the function adds the rating, otherwise returns the existing ratings. Default: false. |
[-1, 1, 1, -1, ...]
Returns true if the rating argument is set.
List of functions for Pusher. More details at pusher.com.
Sends a Push notification to an agent, user, or all agents.
title |
The title of the notification. |
message |
The message text. |
icon |
The icon of the notification. Default: Support Board icon or notifications icon. |
interest |
The following values are accepted:
|
conversation_id |
The ID of the conversation to open when the user clicks the notification. |
user_id |
The ID of user who sent the message. |
attachments |
Message attachments to show the image preview. Syntax: [["name", "url"], ...]. |
{ "publishId": "pubid-781799f5-6el4-4789-bc60-ee293543781" }
Returns false it the Push notifications are disabled in the settings area.
Triggers an avent on a Pusher channel.
channel |
The channel name. |
event |
The event name. |
data |
Array of values. Syntax: [ "name" => "value" ]. |
true
Returns the array of IDs of online users and agents subscribed to the presence channel.
[ { "id": "1538" }, { "id": "1758" }, ... ]
Checks if there is at least one agent online by checking the presence channel.
true if online, false if offline.
Checks if Pusher is active in Settings > Miscellneous > Pusher.
true if active, false otherwise.
Initializes the Pusher PHP SDK.
Various functions that perform different tasks.
Sends an email to an existing user using the email templates, and settings, of the Settings > Notifications area. The email is translated automatically.
recipient_id |
The ID of the user to which send the email. |
message |
The message of the email. |
attachments |
Array 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: []. |
sender_id |
The ID of the sender user. Default: active user ID. |
true
Sends a generic email to an email address. The sender email and name are the ones set in Settings > Notifications > Email settings.
to |
The email address. |
subject |
The email subject. |
message |
The message of the email. |
sender_suffix |
Append the provided text to the sender name. Default: empty. |
true
Runs the email piping synchronization with Support Board and converts emails to chat messages.
force |
Set it to true to the execution of the synchronization, by default the synchronization is executed a maximum of one time per minute. Default: false. |
true
Sends a text message to a user or agent. If the template argument is true, the message is translated automatically.
message |
The text message. |
to |
The phone number. |
template |
Set 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_id |
Set it if the message contains the URL parameter {conversation_url_parameter}. |
attachments |
Array 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. |
{ "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" }
Sends all the agent notifications: email notification, push notification, and SMS notification.
message |
The message text. |
bottom_message |
Additional message to append at the end of the email notification. |
conversation_id |
The ID of the conversation linked to the message. If this value is not set the notifications are sent to all agents. |
attachments |
Array of attachments. 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: false. |
user |
User of the conversation as array of user details. |
extra |
Array of values. Enter the value force: true to force the notifications also if the agent is online. Enter the value email: [email_content] to send a different message only for the email notification. |
true
Checks if a variable is of type SBError. Use the method $error->code() to get the error code, the method $result->function_name() to get the function name that generated the error, the method $result->message() to get the error message.
object |
The variable to check. |
Return true if the variable is of type SBError, otherwise, return false.
Checks if a variable is of type SBValidationError. Use the method $error->code() to get the error code.
object |
The variable to check. |
Returns true if the variable is of type SBValidationError, otherwise, returns false.
Checks if an array key exists and returns its value only if it exists and if it isn't an empty string.
array |
The array in which to look for the key. |
key |
The key to search. |
default |
The value to returns if the key is not found or if it's empty. Default: false. |
Returns the value of the key or the default value.
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. The Slack App is required.
true
Checks if there are updates available for Support Board and the Support Board apps.
Returns true if at least one update is available, otherwise returns false.
Returns the installed version of Support Board and the Apps.
{ "sb": "3.0.4", "dialogflow": "1.0.2", "slack": "1.0.3" }
Starts the update of Support Board and all the apps. This function forces the update and always overwrite all plugin and apps files.
success
Returns the License Key of a Support Board App like the Slack App or the Artificial Intelligence app.
app_name |
Enter one of the following values: slack, dialogflow. |
9300AB16-014ZEE12-91E199EA-997CEX40
Activates an app, downloads it, and installs it.
app_name |
Enter one of the following values: slack, dialogflow . |
key |
The License Key of the App. You can get the key with the function app-get-key. |
success
Exports all the users in a CSV file and returns the URL.
user |
|
key |
The License Key of the App. You can get the key with the function app-get-key. |
user_ids |
Array of user IDs. If set, returns only users with the specified user IDs. Defaults: false. |
Returns the URL of the CSV file.
Exports a conversation in a CSV or TXT file and returns the URL.
conversation_id |
The ID of the conversation to export. |
type |
Set 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. |
Returns the URL of the CSV file.
Converts a JSON string to an array.
json |
The JSON string. |
default |
The value to returns if the conversion is unsuccessful. Default: []. |
Returns a PHP array if the conversion is successful, otherwise, returns the default value.
Checks if the current time is within the office hours.
Return true if the current time is within the office hours, otherwise, returns false.
Encrypts a string or decrypts an encrypted string.
string |
The string to encrypt or decrypt. |
encrypt |
Set it to false to decrypt. Default: true. |
Returns the encrypted string or the decrypted string.
Converts a string to a slug or a slug to a string. When converting a string to a slug all spaces are converted to - and all chars are in lowercase. When converting a slug to a string all the occurrences of the chat - are converted to spaces and the first chat is in uppercase.
string |
The string to convert. |
action |
Enter slug to convert a string to a slug, enter string to convert a slug to a string. Default: slug. |
Returns the slug or the converted string.
Sends data to a URL.
url |
The destination URL that will receive the data. |
post_fields |
Array with the attributes. It can be an array, example: ["attribute" => "value", "attribute" => "value", ...]. It can be a string containing an array in JSON format. |
header |
The HTTP header. It is usually an array like ["Content-Type: application/json", "Content-Length: 123456"]. |
method |
The HTTP method. Default: POST. |
timeout |
The max operation execution time. Default: false. |
Returns a PHP array with the data of the JSON array returned by the server.
Returns the data of a URL.
URL |
The destination URL. |
Returns the file or the data returned by the server.
Downloads a file, saves it in the uploads folder, and returns the URL.
URL |
The destination URL. |
file_name |
The file name of the saved file. Default: original file name. |
mime |
Set it to true to retrieve the file extension automatically. Set it to a mime type string to assign the mime extension to the file name. |
Returns the URL of the file saved in the uploads folder.
Creates a CSV file from an array.
items |
Array containing the data to save in the CSV file. It must be a basic array, each item is a new row in the CSV file. |
header |
Array containing the header elements. Example: ["ID", "First Name", "Last Name", "Email"]. |
filename |
The name of the CSV file. |
Returns the URL of the CSV file. The file is saved into the uploads folder. By default, it's located in the supportboard plugin folder or in the wp-content/uploads folder if you're using the WordPress version.
Creates a new file containing the given content and saves it in the destination path.
path |
The file system destination path, the file will be saved there. |
content |
The content of the file. |
true
This function performs the following tasks: delete visitors older than 24h, delete messages in trash older than 30 days, archive conversation older than 24h with status code equal to 0 or 1 (waiting an answer from the user or without any user reply).
true
Runs the cron jobs.
Converts a shortcode into an array containing the shortcode name and the shortcode settings.
shortcode |
The shortcode string. Example: [rating title="Rate your conversation" message="Tell us your experience." success="Thank you!"]. |
name |
The shortcode name. Example: inputs. Default: false. |
type |
Set it to merge if the shortcode is a merge field like {}. |
{ "shortcode": "[rating title="Rate your conversation" message="Tell us your experience." success="Thank you!"]", "shortcode_name": "rating", "title": "Rate your conversation", "message": "Tell us your experience.", "success": "Thank you!" }
Checsk the cron jobs and runs them if the date and time matchs the job time.
Returns or echos the CSS style for the chat colors.
color_1 |
The first color in RGB or HEX format. Default: the first color saved in the settings area. |
color_2 |
The second color in RGB or HEX format. Default: the second color saved in the settings area. |
color_3 |
The third color in RGB or HEX format. Default: the third color saved in the settings area. |
return |
Set it to true to return the code instead of echo it. Default: false. |
The CSS code
Returns the internal notes of a conversation.
conversation_id |
The conversation ID. |
[ { "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." }, ... ]
Adds a new internal note.
conversation_id |
The conversation ID to which link the note to. |
user_id |
The ID of the agent or admin who create the note. |
name |
The note name. |
message |
The note message. |
The note ID
Deletes an internal note.
conversation_id |
The ID of the conversation linked with the note. |
note_id |
The note ID. |
true
Returns all automations.
[ { "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" } ] }, ... } ]
Saves all automations.
automations |
Automations array. Get it from sb_get_automations(). |
translations |
Automations translations array. Get it from sb_get_automations(). |
true
Validates an automations.
automation |
The automation. |
{ "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.
Validates all automations, executes the valid ones, and returns the automations with client-side conditions, invalid server-side conditions, and popup, design automations.
[ { "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" }, ... ]
Executes a single automation and optionally validates it before executing it.
automation |
The automation. |
validate |
Set it to true to validate the automation before executing it. Default: false. |
true
Checks if an automation has already been sent to a user.
user_id |
The ID of the user to check. |
automation |
The automation. It can be ["id" => 123] where 123 is the automation ID. |
repeat_id |
Set it only if the automation can be sent multiple times to the user. Get it from sb_automations_validate. Default: false. |
Returns true if the automation has already been sent, otherwise returns false.
Adds a subscriber to the newsletter service set in Settings > Miscellaneous > Newsletter. The setting Settings > Miscellaneous > Newsletter > Active must be active.
|
The subscriber email address. |
first_name |
The subscriber first name. Default: empty. |
first_name |
The subscriber last name. Default: empty. |
Returns the newsletter service response.
Returns the Support Board uploads path.
url |
Set it to true to get the URL instead. Default: false. |
date |
Set it to true to get also the date folder relative to the current date. Default: false. |
\var\www\htdocs\supportboard\uploads\10-03-23
https://www.example.com/supportboard/uploads/10-03-23
Checks if uploading files with the specified file extension is allowed.
extension |
The file extension, e.g. jpg. |
Returns true if the extension is allowed, otherwise returns false.
Saves a message in a log file saved in the same directory as the PHP file calling this function. Each call to this function adds the message to the existing contents of the log.
value |
The message. |
Checks if the host machine supports the Support Board system requirements.
{ "php-version": true, "zip-archive": true, "plugin-folder": true, "uploads-folder": true, "apps-folder": true, "languages-folder": true, "ajax": true, "curl": true, "UTF8mb4": true }
Adds a log message to the log file.
string |
The log message. |
user |
Set it to include the user ID to the log message. This value can be ["id" => 123]. Default: false. |
true
Uploads a file to Amazon S3, or deletes a file from Amazon S3. Amazon S3 must be active and configured at Settings > Miscellaneous > Amazon S3.
file_path |
The path to the file to upload or the Amazon S3 file URL for deleting a file. |
action |
Set it to PUT to upload a file. Set to DELETE to delete a file. Default: PUT. |
https://example.s3.amazonaws.com/example.txt
Returns the URL of the Amazon S3 file.
Returns the the specified reports.
name |
The 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_start |
The start date of the reports. Format: dd/mm/yyyy or yyyy-mm-dd. Default: false. |
date_end |
The end date of the reports. Format: dd/mm/yyyy or yyyy-mm-dd. Default: false. |
timezone |
The timezone of the user who is calling this function, e.g. Europe/London. Default: false. |
{ "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" }
Adds a new row to the sb_reports database table.
name |
The 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. |
value |
The row value. Default: false. |
external_id |
An external ID. Default: false. |
extra |
An extr avalue. Default: false. |
{ "success": true, "response": true }
Export a report in CSV format.
name |
The 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_start |
The start date of the reports. Format: dd/mm/yyyy or yyyy-mm-dd. Default: false. |
date_end |
The end date of the reports. Format: dd/mm/yyyy or yyyy-mm-dd. Default: false. |
timezone |
The timezone of the user who is calling this function, e.g. Europe/London. Default: false. |
Returns the URL of the exported report.
Artificial Intelligence app functions to manage the chatbot and more. The Artificial Intelligence app is required to use this set of APIs.
Sends a message to Dialogflow and add the Dialogflow response to an existing conversation as a new message.
conversation_id |
The conversation ID. |
message |
The content of the message. |
token |
Dialogflow Session Token(it's not the Refresh Token). Pass it if you have it, otherwise it will be generated. For performance reasons always include this token. You will get the token after the first call of this function, from the response. Default: false. |
language |
The Dialogflow agent language code. Default: main agant language code. |
attachments |
Array of attachments. 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. Default: []. |
event |
Trigger a Dialogflow event. |
parameters |
Array of optional information. Array syntax: { "name": "value", "name": "value", ...}. |
project_id |
Set it to change the default Dialogflow agent. |
audio |
URL or path of an audio file for speech recognition. Default: false. |
{ "token": "ya29.a0AfH6SMB5Y04TwKvxeah5pCEtcupfncTOLMlewxlnUAhH5H4HE4SVIeOPWSfxRVfHNcJIoR-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-655517752147/agent/intents/fe275c2e-f39d-4db3-92c2-e55582ce38fb", "displayName": "Default Welcome Intent" }, "intentDetectionConfidence": 1, "languageCode": "en" }, "alternativeQueryResults": [ { "queryText": "Hello", "languageCode": "en" } ] } }
Other possible responses: dialogflow-not-active, SQL, or cURL error message.
Sends data to Dialogflow. Use this function to submit the queries to Dialogflow.
url_part |
The Dialogflow API partial URL. Examples: /agent/entityTypes, /agent/intents:batchUpdate. |
query |
The Dialogflow query in JSON format or as array. |
language |
The Dialogflow agent language code. Default: main agant language code. |
type |
The call type. Supported values: POST, GET, PATCH. Default: POST. |
token |
The Dialogflow Session Token(it's not the Refresh Token). Pass it if you have it, otherwise it will be generated. Default: false. |
Returns the Dialogflow response in associative array format. More details at https://cloud.google.com/dialogflow/es/docs/reference/rest/v2-overview
Generates a new Dialogflow Token and returns it. The token is valid for 1 hour.
ya27.a1AfH6SMDu9dn0TfRbNVAIEsSoeJPD1_jr1JpfL15...
Returns the details of the Dialogflow agent.
{ "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" }
Activates a Dialogflow context in the active user session.
context_name |
The context name. |
parameters |
Array of Dialogflow parameters linked to the context. Example: ['woocommerce-products' => 'Running Shoes']. The array can be also a string in JSON format. |
life_span |
The context lifespan. Default: 5. |
token |
The Dialogflow refresh token. |
user_id |
The ID of the user linked to the context. Default: active user. |
language |
The agent language. Default: active user language. |
{ "responseId": "4f6912db-71ac-41e1-b006-088b7647cb59-fddac234", "queryResult":{ "queryText": "sb-trigger-context", "parameters":{ "any": "sb-trigger-context" }, "allRequiredParamsPresent":true, "fulfillmentMessages":[ { "text":{ "text":[ "" ] } } ], "outputContexts":[ { "name": "projects/abcde/agent/sessions/244/contexts/abcde", "lifespanCount":1, "parameters":{ "woocommerce-products": "", "any": "sb-trigger-context", "any.original": "sb-trigger-context" } } ], "intent":{ "name": "projects/abcd/agent/intents/abcde", "displayName": "woocommerce-waiting-list" }, "intentDetectionConfidence":0.6, "languageCode": "en" } }
Creates a new Dialogflow Intent. The Intent will be linked to the Dialogflow agent synchronized in the admin area.
expressions |
Array with the training phrases. Array syntax: ["", "", ...]. |
response |
String containing the response of the bot when the user input matches a user expression. |
agent_language |
The language code of the intent. Default: main agent language. For the language codes list visit cloud.google.com/dialogflow/docs/reference/language. |
Creates multiple Dialogflow Intents and allow a deeper customization than the sb_dialogflow_create_intent() function.
intents |
Array of Intents. Each Intent must be a SBDialogflowIntent object. |
language |
The Dialogflow agent language code. Default: main agant language code. |
{ "name": "projects/woocommerce-app-rojq/operations/bg-f0adhdc5-a1a1-472b-a06c-15559a12cfc7", "done":true, "response":{ "@type": "type.googleapis.com/google.cloud.dialogflow.v2.BatchUpdateIntentsResponse", "intents":[ { "name": "projects/abcde/agent/intents/abcde", "displayName": "Cart details", "priority":500000, "outputContexts":[ { "name": "projects/abcde/agent/sessions/-/contexts/abcde", "lifespanCount":5 } ], "messages":[ { "text":{ "text":[ "Hi there!" ] } } ] }, ... ] } }
Deletes multiple Intents at once.
intents |
Array of Intents. Each Intent must be a SBDialogflowIntent object. You can get the existing Intents with the function sb_dialogflow_curl('/agent/intents?pageSize=1000', '', '', 'GET'). |
Creates a new Dialogflow Entity.
entity_name |
The Entity unique name. |
values |
SBDialogflowEntity object or array of Entity values. Single value syntax: ['value' => '', 'synonyms' => ['', '', ...]]. |
language |
The Dialogflow agent language code. Default: main agant language code. |
Returns true on success, otherwise returns the Dialogflow error response.
Updates an existing Dialogflow Entity.
entity_id |
The Entity ID. You can get this value with the function sb_dialogflow_get_entity(). |
values |
SBDialogflowEntity object or array of Entity values. Single value syntax: ['value' => '', 'synonyms' => ['', '', ...]]. |
language |
The Dialogflow agent language code. Default: main agant language code. |
Return true on success, otherwise returns the Dialogflow error response.
Returns a Dialogflow Entity, or all Entities of the agent.
entity_id |
The ID of the Entity. Leave empty or enter all to get all Entities. Default: all. |
language |
The Dialogflow agent language code. Default: main agant language code. |
[ { "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 } ]
Calls the OpenAI API (ChatGPT) and return the response.
url_part |
The URL part of the API. For example, if you want to call https://api.openai.com/v1/completions, only enter completions. |
post_fields |
The parameters of the API. |
header |
The header values. |
type |
The HTTP call type. Allowed values: GET, POST, UPLOAD. |
Returns the openAI response. More details at https://beta.openai.com/docs/api-reference/.
WordPress functions.
Returns the details of a WordPress user.
user_id |
The WordPress user ID. |
{ "id": 123, "first_name": "Don", "last_name": "John", "email": "email@example.com", "password": "$P$BcCpYeU21wYnXKW2LpJj/F9xRdSmLM/" }
Returns false if no user was found.
Gets the currently active WordPress user and register it as a Support Board user. If a Support Board user is currently active, update it with the WordPress details. After the registration the user is logged-in. Returns the login details and encrypted data of the Support Board user.
user_id |
The currently active WordPress user ID. |
[ { "id": "913", "profile_image": "https://board.support/user.svg", "first_name": "User", "last_name": "#29902", "email": null, "user_type": "visitor", "token": "9b25351047ee758aa97ee4868d130cc1ceb8decf" }, "YXNkWGNSeTdtRTdDYVkxVG8wckN4YWF6V2s0Tk1mczBSVHdQbHBpOWdmejVUTTdOUUxEUENhdUVoYmROWn..." ]
Syncronizes the WordPress users with the Support Board users. If Ultimate Membership Pro App is installed, the syncronization imports also the additional users details.
true
Returns the user ID of the WordPress user with the given email.
|
The user email. |
1234
Returns false if no user was found.
Saves a new WordPress post (page, post, ...). This function is equivalent to wp_insert_post().
post_title |
The post title. |
post_content |
The post content. |
post_type |
The post type. Ex.: page, post. |
Returns the ID of new post.
Creates or update a WordPress option. This function is equivalent to update_option().
name |
The option name. |
value |
The option value. |
Returns the ID of new option.
Returns the value of a WordPress option. This function is equivalent to get_option().
name |
The option name. |
Returns the option value, or false if no option with given name was found.
Returns the URL of the image with the given ID. This function is equivalent to wp_get_attachment_image_src().
id |
The WordPress image ID. |
https://example.com/image.jpg
Returns an empty string if no image with the given ID was found.
Returns the website URL.
https://www.example.com
Returns the languages settings of WordPress.
plugin |
The multilingual plugin name. Default: the plugin set at Settings > WordPress > Multilingual plugin. |
{ "default": "en", "languages": [ "en", "de", "it" ], "post-types": [ "attachment", "wp_block", "product", "product_variation", "food", "post", "page" ], "taxonomies": [ "translation_priority", "product_cat", "product_tag", "product_shipping_class", "pa_colore-prodotti", "pa_taglia-prodotti", "category", "post_tag" ], "link-type": "3", "plugin": "wpml" }
Returns the translated page ID of the given page ID.
id |
The page ID. |
Returns the translated page ID if the translation is found, otherwise returns the given ID.
WooCommerce App functions. The WooCommerce App is required to use this set of APIs.
Returns the details of a WooCommerce customer.
session_key |
The customer session key. You can get this value with the function sb_woocommerce_get_session_key(). |
{ "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": "" }
Returns an array with the orders summary of the user. Use the function sb_woocommerce_get_last_order() to get only the last order of the user.
user_id |
The user ID. |
[ { "id": "602", "date": "2020-10-19 14:02:35", "total": "0", "status": "wc-on-hold", }, { "id": "601", "date": "2020-10-18 14:02:35", "total": "0", "status": "wc-processing", }, ... ]
Returns the details of an order.
order_id |
The order ID. |
{ "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": "€" }
Returns the details of a product.
product_id |
The product ID. |
{ "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" }
Returns the products matching the given query if any, otherwise returns all products.
filters |
Array of filters. Syntax:
[ "filter" => "value", "filter" => "value", ... ].
Use filters to only get products that match specific criteria. Available filters:
|
pagination |
Limit 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... |
language |
The products language code. Default: false. |
[ { "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" }, ... ]
Returns the products matching the search.
search |
The search string. |
[ { "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" }, ... ]
Returns the WooCommerce product categories or tags.
type |
Enter category or tag. |
language |
The language code of the taxonomies. Default: false. |
[ { "id": "33", "name": "Clothes", "slug": "clothes" }, { "id": "34", "name": "Accessories", "slug": "accessories" }, ... ]
Returns the WooCommerce product attributes and attribute terms.
type |
Set it to terms to returns only the terms name of all attributes, and to attribute to returns only the attributes name. Default: all. |
language |
The language code of the attributes. Default: false. |
{ "colors": { "id": "1", "name": "Color", "slug": "pa_color", "terms": { "red": "Red", "yellow": "Yellow", "green": "Green", ... } }, ... }
[ { "name": "Red" }, { "name": "Yellow" }, { "name": "Small" }, { "name": "Medium" }, { "name": "Large" }, ... ]
[ { "id": "1", "name": "Color", "slug": "pa_color" }, { "id": "2", "name": "Size", "slug": "pa_size" }, ... ]
Searches a product by name and returns its ID.
name |
The product name. |
Returns the product ID, or false if no products with the given name are found.
Returns an array with the images of a product.
product_id |
The product ID. |
[ "https://example.com/image.jpg", "https://example.com/image.jpg", ... ]
Returns the categories and tags of a product.
product_id |
The product ID. |
[ { "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" }, ... ]
Returns the attribute of an attribute term.
term_name |
The term name. |
{ "id": "1", "name": "Color", "slug": "pa_color" }
Searches an attribute by its name and returns it.
name |
The attribute name. |
{ "id": "1", "name": "Color", "slug": "pa_color" }
Checks if a product is in stock.
product_id |
The product ID. |
Return true if the product is available, otherwise return false.
Generates a coupon and returns the coupon code.
discount |
Discount percentage. Enter a value from 1 to 100. |
expiration |
Coupon expiration. Example: 3 days, 1 minutes, 60 seconds. |
product_id |
String of IDs separated by commas. Example: 11,53,63. If setted the coupon is valid only for the products with the given IDs. |
user_id |
If setted the coupon is valid only for the user with the given ID. |
[ "fxsocl3490oq", "50" ]
[ coupon code, discount value ]
Checks if there are coupons linked to the given user.
user_id |
The user ID. |
Returns true if there are coupons linked to the user, otherwise returns false.
Deletes all expired coupons. This function runs automatically every hour via cron jobs.
true
Calculates and returns the average rating.
rating |
Array of ratings. Get this value from the rating value of a product. |
4.56
Returns a WooCommerce URL.
type |
The URL type to get. Accepted values: tagcategory, cart, shop, checkout. |
name |
The name of the category or link. |
language |
The language of the page of the URL. Default: false. |
Returns the URL if found, otherwise returns an empty string.
Returns the session variable of a user. The session variable contains the user cart details and more.
session_key |
The session key of a user. Get it with the function sb_woocommerce_get_session_key(). Default: active user session key. |
{ "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": "" } }
Returns the session key of a user.
user_id |
The user ID. Default: active user ID. |
Returns the session key if found, otherwise returns false.
Returns the available payment methods of the shop.
[ "Direct bank transfer", "Check payments", "Cash on delivery", "Alipay", "Multibanco", "Credit Card (Stripe)" ]
Returns the shop shipping locations, or checks if the shop ships to a specific location.
country_code |
A country code. If provided checks if the shop ships to the country of the given given code. Default: false. |
[ "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.