Rate this page:

Creating functions

Functions help you create a serverless environment that allows developers to create production-ready Voximplant Kit applications in accordance with their business requirements.

Note

In Voximplant Kit, functions are written on Node.js. You can add extra functionality by uploading the appropriate packages.

Creating a function

Use the Function section to bring together functions, dependencies, and environment variables. In this section, you can also access all functions to edit or delete them if needed.

Important

To avoid any problems affecting the Voximplant Kit work, please, make sure you know the rules of functions in programming languages.

  1. Log in to your Voximplant Kit account.
  2. On the left sidebar, select Administration > Functions.
  3. In the Management subsection, click New function. The system opens the Create function window where you can configure your function.
New function
  1. In the Properties field, enter the name of the function.
  2. On the Code tab, enter the code you want to execute.
  3. Click Create.
Create a function

Click the Logs tab to review the information about the executed code.

Learn here about the methods you can use in your functions. For example, you can configure a chatbot and use it tp process outbound chats.

Moreover, by using getVariable and setVariable methods, you can extend manipulations with variables used in a scenario.

Here are the examples of using functions in Voximplant Kit.

Creating a dependence

The system allows functions to use external Node.js modules as well as local data. Dependencies in Node.js are managed with npm and stored in a package.json file.

To import npm modules to Voximplant Kit functions, do the following:

  1. Select the Configuration subsection.
  2. Select the API token from the drop-down list.
  3. In the Dependencies group box, enter the name of the dependence and select or enter the version of the npm module.
Create a dependance
  1. Click Save changes to install and deploy the npm module.

Adding a variable

Variables are key and value pairs that you can add to a specific environment. The system encrypts variables, so you can use them as a preferred way to store API keys, passwords, and any other data. You do not need to deploy a new code every time you update a variable – the system immediately reflects the new value in subsequent function executions.

To add a variable, do the following:

  1. Go to the Variables subsection.
  2. Click Add variable.
  3. In the Add variable dialog window, enter the name and value of the variable.
  4. Click Confirm.
Add a variable

To edit a variable, do the following:

  1. Click the Actions menu icon next to the required variable.
  2. Select Edit.
  3. In the dialog window that opens, edit the name or value of the variable.
  4. Click Save changes. The system updates the variable.

To delete a variable, do the following:

  1. Click the Actions menu icon next to the required variable.
  2. Select Delete.
  3. Confirm the deletion.