Skip to content

Functions

With this guide you will learn how to master Functions in uContact, which allow you to create custom developments and enhance the use of the platform through automations.

What are they?

Functions are processes that run automatically when a condition is met or a request is received. They can be triggered in three ways:

  • Webhook: When an external service sends data to uContact.
  • Event: When an internal action occurs on the platform.
  • Scheduler: When a programmed date/time or interval is reached.

How to create a function?

  1. Go to Automations inside the Admin Menu and then click on Functions.

  2. Click the New button located in the top right corner.

  3. Choose the type of function you want to create.

Types of functions

In uContact there are three types of functions, each designed to automate actions in a different way.

Webhook

Integrates uContact with other applications or external services by receiving data into the platform. Webhooks are triggered by making a GET, POST, PUT or DELETE request to a specific route.

  • Name: Unique name associated with the Webhook.
  • URL: This field will be automatically completed with the Webhook URL once it has been created.
  • Description: Short text explaining the purpose of the Webhook and what data it processes.

How are they created?

  1. Select the Webhook type and optionally add a description that explains the Webhook's purpose. Then click Save.
  2. Once created, the Flow Designer will automatically open, where you can build the custom logic you need.
  3. After you finish designing the flow, click the Production button and the flow will be ready to use. If you have any questions about how to use the Flow Designer, you can check the following guide.

Only requests with the following Content-Type are accepted:

  • application/json
  • application/x-www-form-urlencoded

Execution route

https://<instance>.ucontactcloud.com/api/webhook/<webhookName>

Replace <instance> with the name of your instance without .ucontactcloud.com. For example, if the instance is https://marketing.ucontactcloud.com and the webhook is called leads:

https://marketing.ucontactcloud.com/api/webhook/leads

Available variables

When a webhook flow is executed, global variables are created and available from JavaScript containing request information:

METHOD
  • Type: String
  • Description: HTTP method used (GET, POST, PUT, DELETE).
BODY
  • Type: Object
  • Description: Request body if application/json.
  • Example:
json
{ "name": "Daniel", "age": 23 }
FORM_PARAMS
  • Type: Object
  • Description: Request body if application/x-www-form-urlencoded.
  • Example:
json
{ "param1": "value1", "param2": "value2" }
HEADERS
  • Type: Object
  • Description: Headers sent in the request.
  • Example:
json
{
  "Accept": "*/*",
  "Cache-Control": "no-cache",
  "Connection": "close",
  "User-Agent": "PostmanRuntime/7.26.8"
}
QUERY_PARAMS
  • Type: Object
  • Description: Parameters sent via URL (key=value).
  • Example:
https://instance.ucontactcloud.com/api/webhook/test?phone=123123&name=John

Generates:

json
{ "phone": "123123", "name": "John" }

What can you do in the flow?

Inside a Webhook flow, you can execute all available actions in the Flow Designer, for example:

  • Query the database.
  • Execute uContact API methods.
  • Use any Flow Designer activity.
  • And more!
Webhook Response!

If the SetWebhookResponse activity is not used in the flow, by default the response will be 200 with an empty body. If you use this activity, you can fully control the response: status code, body, and headers.

Botito

Example

A company wants that every time someone completes a form on their website (with name, email, and phone), that data is automatically saved in uContact as a new lead to be called using an Outbound Hub.

  • The website form makes a POST request to the webhook configured in uContact: https://marketing.ucontactcloud.com/api/webhook/leads.
  • In the webhook flow, the received BODY is processed:
json
{ 
  "name": "María Pérez", 
  "email": "maria@example.com", 
  "phone": "59891234567",
  "product": "Credit card"
}
  • With that data, the flow adds the lead into the desired Outbound Hub using uContact’s Leads API. Learn more about uContact APIs in the following guide.

Events

Executes actions automatically when an event occurs on the platform.

  • Name: Unique name associated with the event.
  • Event: Internal uContact action that will trigger the function (example: Agent logs in, Interaction classified).
    • What are these events?
      Learn more about the events by visiting the following guide.
  • URL: External endpoint to which the event information will be sent via POST (optional if an internal flow is used).
  • Description: Optionally explains what the function will do when triggered and in which cases it is used.

How it works

When an event occurs in uContact, you can configure it to:

  • Send a POST to an external URL.
  • Execute a custom flow inside uContact.

In both cases, the event is passed as an EVENT object with its full information:

json
{
  "type": "agent_logged_in",
  "timestamp": "2025-08-11T14:32:00Z",
  "agent": "juanperez",
  "campaign": "Sales"
}

Example

A company wants that every time a user logs in to uContact, that event is recorded in an external monitoring system.

  • An event is created in uContact of type Agent Logged.
  • Every time it occurs, uContact triggers a POST to the configured URL, for example: https://monitoring.com/api/agent-activity.
  • The body sent could be:
json
{
  "type": "agent_logged_in",
  "timestamp": "2025-08-18T09:30:00Z",
  "agent": "jlopez",
  "campaign": "Support"
}
  • The external system receives the data and stores a record in its database to later display it in the activity dashboard.

Scheduler

Automates tasks that run on a scheduled basis.

  • Name: Unique name associated with the Scheduler.

  • Type: Action to execute when the scheduler is triggered:

    • SQL script: Executes a script or SQL query on the configured database.
    • Shell script: Executes a command or script in the server terminal.
    • Export: Generates an export file with data based on the defined configuration (CSV, XLSX, etc.).
  • Description: Indicates what task will be performed, the purpose, and any important details.

  • Enabled task: Indicates whether the task is enabled or not; by default it is enabled. If disabled, it will not run.

Warning!

Remember that Schedulers run on the server, so it is not recommended to execute very heavy tasks during production hours. It is advisable to run these tasks outside of peak hours to avoid stability issues while users are working.

Botito

Configuration

In this tab, you must configure the necessary setup depending on the type of task you selected.

  • SQL script: Write the SQL statement you want to execute in the database.
  • Shell script: Write the commands to execute in the server console.
  • Export: Write the SQL statement to obtain the information you want to export. Then select the way you want to export that data.

Schedule

In this tab, you can select the task execution frequency. The frequency can be configured using minutes, hours, days of the month, months, and days of the week. It is not necessary to use all fields; you can combine them according to your specific needs.

Minutes
  • Every minute: The task will run every minute.
  • Every x minutes: Allows you to select a specific interval in minutes for task execution.
  • Select minutes: Allows you to select specific minutes at which the task will run.
Hours
  • Every hour: The task will run every hour.
  • Every x hours: Allows you to select a specific interval in hours for task execution.
  • Select hours: Allows you to select specific hours at which the task will run.
Days of the month
  • Every day: The task will run every day at a specific time.
  • Every x days: Allows you to select a specific interval in days for task execution.
  • Select days: Allows you to select specific days of the month on which the task will run.
Months
  • Every month: The task will run every month.
  • Every x months: Allows you to select a specific interval in months for task execution.
  • Select months: Allows you to select specific months in which the task will run.
Days of the week
  • Every weekday: The task will run every day of the week.
  • Every x weekdays: Allows you to select a specific interval in weekdays for task execution.
  • Select weekdays: Allows you to select specific weekdays on which the task will run.

How to verify the configuration?

To verify if the configured frequency is correct, as you make changes, you can see two preview boxes. The first will show the cron expression, and the second will display a description of the task execution frequency. For example: "The task will run every day at 12:00 hours."


Examples of execution

Below you will find some examples of task execution frequencies to try out. Each one details the values for each option.

Task that runs every day at 00:00 hours

  • Minutes: 00
  • Hours: 00
  • Days of the month: Every day
  • Months: Every month
  • Days of the week: Every day

Cron expression: 0 0 * * *
Description: The task will run every day at 00:00 hours.

Task that runs every hour every Monday

  • Minutes: 00
  • Hours: Every hour
  • Days of the month: Every day
  • Months: Every month
  • Days of the week: Monday

Cron expression: 0 * * * 1
Description: The task will run every hour every Monday.

Task that runs on the first day of the month at 09:00 hours

  • Minutes: 00
  • Hours: 09
  • Days of the month: 1
  • Months: Every month
  • Days of the week: Every day

Cron expression: 0 9 1 * *
Description: The task will run on the first day of the month at 09:00 hours.

Practical example

A supervisor wants to receive every day at 9:00 AM a file with the interactions handled the previous day.

  • A Scheduler function is created called daily_interactions_report with type Export.
  • It is scheduled to run every day at 9:00 AM.
  • The generated file is automatically sent to the supervisor’s email or made available for download in the system.

In this way, Schedulers allow you to program repetitive tasks such as exporting data, running SQL scripts, or executing server commands without having to do it manually.

uContact by net2phone