Schedulease

Schedulease

 

XCALLY section

Plugins → Schedulease

On this page

 

Overview

The Schedulease plugin provides tools to automate groups of actions in XCALLY.
With this plugin, you can:

  • Execute different types of API requests

  • Run custom Unix commands or scripts

  • Close channel interactions based on specific conditions

  • Execute database queries, with the option to save results as a report

Please note that a dedicated license is required to use the Schedulease plugin. For further details, refer to the price list or contact your sales account.

 

Installation

To install the plugin:

  1. Upload the Schedulease zip archive through the admin interface on XCALLY Motion V3, from the AppZone → Plugins section.

  1. After the upload is complete, you can find the Schedulease plugin row. Click on the three dots button menu and select Install plugin.

  2. The Schedulease plugin is now installed, and you can find it under the Plugins Menu.

  3. Go under the Configuration tab and insert the credentials for the motion2 database connection, where the configuration tables for the plugin will be created, and the details of your server, including your server reachable URL and an admin APIkey.

Remember to restart the plugin from the AppZone → Plugins section after saving the configuration

 

How it works

  1. You configure one or more automations, routines that are executed periodically, based on an interval that can take one or multiple values

  2. For each one of these automations, you can create multiple actions, that will be executed sequentially, one after another, when the specified interval for that automation is met. The actions are queued, so the next action is not executed until the previous one has not finished or failed.
    The queue is common through all the automations, so there is no possibility of two actions of two different automations to be executed at the same time, since all the actions are put in the same queue.

  3. Everything that’s happening in the background is logged and can be checked on the log files

Automations

To create a new automation:

  1. Go under Plugins → Schedulease → Automations

  1. Click the plus button located in the right bottom side of the page

  1. Enter the below details:

  • Name of the automation

  • Interval: when the automation needs to be executed. You can choose the base unit of the repetition (Hour, Day, Week, etc..) and then you can select multiple subparts of that unit (e.g., every Hour at both 0 and 30 minutes)

  • Skip actions if still in execution: as mentioned before, the actions are all queued in a single queue, and executed after the previous one is completed. It could be, in a remote case, that while the action is still waiting to be executed, the automation interval is met again, and the system will try to insert the action again in the queue. If you want to avoid inserting the action in the queue while it still needs to be executed, you can select this.

  • Enabled button to enable the automation

4. Click Add Automation

  1. Edit the automation, by clicking on the automation row, or through the three dots button menu on the right.

  1. Review the General Settings

  2. Go under Actions tab to create new actions and click on the plus button. Each one of these actions, when the automation interval is met, will be added to a queue, and executed sequentially, one after another.

Every time an automation or an action is executed, the Last Exec field is updated. Also, in the interval column you can check when the next run of the automation will be.

  1. Select the action type: API request, System Command, Close Interactions, DB Query

Please note that you must not put ; at the end of queries when using Schedulease.

API Request

The API request allows you to perform an API request toward a specified endpoint. You can:

  • use the most common API methods (GET, POST, PUT, PATCH, DELETE)

  • Set a timeout for the Api request

  • Set custom headers for your request, in json format

  • In case of a POST/PUT/PATCH request, you can specify a request body, in json format

System Command

The System Command action allows running a unix command on your server. It includes two modes:

  • Command: it allows you to specify a command to run on your server. Useful, for example, to run command line instructions (e.g. date) or to run scripts files that are located on your server (e.g. sh /usr/src/myscript.sh)

  • Embedded: it allows you to directly define a script file with its content to be executed, directly from the web interface. You can choose among 3 programming languages (bash, javascript, python) and insert the code directly in the Code input. The system will create the corresponding script file (based on the name you choose) and execute it when the automation is launched

Close Interactions

The Close Interactions action allows to close a group of XCALLY Motion channels interactions, based on the channel, one or multiple accounts, and one or more conditions.
The conditions are applied with an AND operator (all selected conditions must be met) and are:

  • Inactivity: Amount of time since the last message in the interaction

  • Tags: The interaction must include at least one of the tags selected

  • Creation: Amount of time since the interaction has been created

If all the conditions are met, the found interactions are closed automatically.

DB Query

The DB query action allows you to perform database queries using one of the ODBC connections configured in your XCALLY Motion server.

You can choose to execute the query, and optionally choose a Post query action to perform among these 4 options described below

1. Extract the query as an XCALLY report: You can choose different ouput formats (csv, pdf, xlsx, old xlsx). The extracted results will be available as normal extracted reports in the Motion server related section, where you’ll be able to download or delete them.

Eventually you can also choose to send the extracted report through email, using one of the email accounts configured on XCALLY.

You can only enable the report extraction if the inserted query is a SELECT statement

The report extraction takes in account the split configuration on your XCALLY server and splits the report files accordingly to the rows limit you setup in XCALLY general settings (report tab).

You can also decide if you want to send a notification email even if the results for the report are empty.

2. Send Query results to API: You can forward the results of the extracted query to an API endpoint. You can choose the API method, specify the URL, the headers in a JSON format and the request timeout.

By default, the body of the request will be the filled with the array of objects resulting from the query.

If you enable the Send each row individually flag, the resulting rows will be sent one at a time toward the API. In that case you can also specify the object you want to send as the body of the request and use the columns values with the {{column_name}} syntax, or you can leave the body empty to send the whole row.
In that case can also use the columns values in the url (E.g. http://mywebsite.com/api/update/{{id}).

3. Insert the query results into another db table: in this case, you can choose the database connection from xcally ODBC connections, and then specify the table where the results will be inserted.

The columns extracted in the query needs to be named the same as the columns required to be populated on the destination table, so using the “AS” syntax is recommended (e.g. SELECT source_column AS destination_column, etc…)

  1. Execute a shell command: You can sexecute a system command after the query has been completed.

You can also choose to pass the query result to the command you are executing. For example, you can run a script located in your system, and chhose to pass the entire query output (as a json array) to the script (by selecting “Send query output as parameter”), or send the resulting rows json individually (in a json format) (by selecting “Send each row individually”).

Logs

The application stores log files for each component and/or function that is executed in the background. You can find these logs in the Log view, where you can check when a specific log is been updated, download, or delete it.

The logs allow you to check the proper functioning of the application, and to eventually check for errors.

You can find logs in folder /var/log/xcally/schedulease
As mentioned, the log files are organized by component and by type, and can be of four types:

  • <component_name>-combined.log, includes the list of all the complete logs for that component.

  • <component_name>-combined.date.log (e.g. api-combined.2024-01-01.log): these files gather the log details for the specified component, including both debug and error messages, and for the day specified in the date part of the name. The logs are rotated daily, meaning that you’ll have a new combined log file for each component for each day. The rotation limit is set to 30 days, meaning that after 30 days the oldest logs will be deleted.

  • <component_name>-error.log, includes the list of all the error logs for that component.

  • <component_name>-error.date.log: these files gather the log details related to the errors only, and for the day specified in the date part of the name. The logs are rotated daily, meaning that you’ll have a new combined log file for each component for each day. The rotation limit is set to 30 days, meaning that after 30 days the oldest logs will be deleted.

Troubleshooting

If the plugin is not working, you can check whether it is active.

Navigate to Settings → System → Processes and verify in the list if the plugin is running (ONLINE label).

If not, go to App Zone → Plugins, open the plugin list, click the three-dots menu of the specific plugin, select Uninstall plugin, and then Install plugin again.

Please note that uninstalling only stops the processes; it does not remove the plugin itself, so all previously entered configurations are preserved.