Skip to main content

Veritran Docs

Inline Lambda Processes

Important

To use this feature, you need to update [mobile and webfly versions].

An inline lambda process is a type of process used to execute logic blocks directly from another lambda process. It allows you to execute a lambda process within an ongoing one while preserving the action sequence of that invoking process. This means that, once the execution of the inline process finishes, the flow of the invoking process continues without interruption, optimizing performance and simplifying the building process.

Inline lambda processes are built using the same visual editor as regular lambda processes, which makes it easy to integrate and manage them within other processes. To create an inline lambda process, go to the Processes list and click + Create. In the modal that opens, click Inline process. The lambdas editor opens, where you can build the inline process using blocks as with regular lambda process. Once created, you can invoke that inline process from any other lambda process using the execute inline lambda block. Refer to Create and invoke an inline lambda process to learn more.

Some important aspects of inline lambda processes are:

  • They are executed when invoked, not at the end of the invoking lambda process flow as with other Next blocks.

  • They can invoke another inline lambda process.

  • They do not include next action blocks, except for those used to invoke another inline lambda process (execute inline lambda block) or to set the next action of an async transaction (execute async transaction () with next (" ") and message (" ") bock).

  • They can call a transaction or a call API. Error handling within the transaction invocation interrupts the logic of the inline process and returns to the invoking process. If the error is handled by the application, it interrupts the entire logic (both the inline process and the invoking one or ones). Refer to Error management to learn more.

  • They can be invoked from other entities as any other lambda process (e.g., a screen). Refer to Invoke a process to learn more.

  • They are not included in the existing request next lambda block list of processes. This block includes all lambda processes except for inline processes, that are invoked using the execute inline lambda block. Refer to List of blocks to learn more.

Create and Invoke an Inline Lambda Process

See below an example on how to build an inline lambda process to generate an OTP (one-time password) that works as a second authentication factor, and another lambda process that executes a monetary transaction after the inline process is executed and the user's identity is validated. Keep in mind that, since processes vary depending on the functionality you want to build and on the client's requirements, you might encounter different approaches on how to build a similar lambda process.

Consider this scenario: You need to create a process that allows the user to transfer money into another bank account. But, before executing the money transfer, you want to ensure that the person using the app is actually the bank account owner and is authorized to execute that operation. To do so, first, you need to create the inline process that executes the call API required to generate the OTP that works as a second authentication factor. Then, you need to create another lambda process to execute the monetary transaction. From this process, you will also invoke the inline lambda process previously created to generate the OTP and validate the user's identity. Thus, after the inline lambda process is executed and the identity of the user validated, the flow of the invoking process continues with the execution of the monetary transaction.

Prerequisites

For this example, take into account that you need to use three elements:

  • a transaction that executes money transfers. To learn how to create the transaction, refer to Create a Configurable Transaction;Create a Configurable Transaction

  • a call API that generates OTPs (one-time passwords);

  • the screen where operations such as money transfers are done;

  • a lambda process containing the logic with the behavior of the app in case the transaction fails.

  • and a lambda process containing the logic to display the transaction receipt if successful.

Note

Even though the screen is not indispensable to create the lambda process, you should have it defined beforehand to complete the process configuration.

inline_basic_info.gif
  1. Go to Logic in the top menu (☰) and click Processes.

  2. In the Lambda processes tab, click + Create.

  3. In the Create modal, you can choose between a process or an inline process. For this example, click Inline process. The lambdas editor opens and the header indicates that you are working on a inline lambda process.

  4. In the Process Basic Info tab that opens by default, complete information about the inline lambda process you are building.

    1. In the Name field, add a name to the inline lambda process that represents its functionality. For this example, set TKN_GENERATE_OTP.

    2. In the Description field, add a short text that explains the aim of the logic created. If there is a call API included in the process, add its name to the process description to easily track it. For this example, set Generate OTP with VTToken API.

    3. In the Tags field, add keywords for you and your team to easily group processes according to their functionality. For this example, set token and OTP.

  5. First, set the call API function that generates the OTP as a variable. To do so, follow these steps:

    api_variable.gif
    1. Go to the blocks list and find the Variables block category or type variable in the search bar.

    2. Click to open the category and click Make a Variable... to create a new one.

    3. Set the variable name and click Ok to finish the creation process. For this example, enter api_generate_OTP_params.

    4. Then, find the set variable to block, drop it into the canvas and connect it to the on start block.

    5. Select the api_generate_OTP_params variable from the variables drop-down menu.

    6. Then, find the API function that generates the OTP. For this example, search for the vttoken api generate otp block. Drag the API function block into the canvas and connect it to the set variable to block.

    Best Practice

    Setting the API function as a variable is considered a good practice as it improves the readability of the lambda process and allows you to easily reuse the function within the lambda process as many times as you may need.

  6. Then, configure the call API function input parameters. To do so, follow these steps:

    complete_api_otp.gif
    1. Find the Registers block category in the blocks menu on the left or type register in the search bar. Then, click to open the category, drag the register text block into the canvas and connect it to the challenge parameter slot.

    2. Complete the register text block with 118, the register number that corresponds to the challenge parameter.

    3. Drag the register text block into the canvas and connect it to the pin parameter slot.

    4. Complete the register text block with 121, the register number that corresponds to the pin parameter.

    5. Drag the register text block into the canvas and connect it to the session data parameter slot.

    6. Complete the register text block with 122, the register number that corresponds to the session data parameter.

    7. Drag the register text block into the canvas and connect it to the crc validation parameter slot.

    8. Complete the register text block with 141, the register number that corresponds to the crc validation parameter.

    9. Drag the register text block into the canvas and connect it to the transform session data parameter slot.

    10. Complete the register text block with 142, the register number that corresponds to the transform session data parameter.

    11. In the ocra suit parameter, enter the value defined for your project.

    12. Finally, drag the register text block into the canvas and connect it to the flag clear password parameter slot.

    13. Complete the register text block with 125, the register number that corresponds to the flag clear password parameter.

  7. Once you have configured the call API function, define the actions to follow if the execution of the call API is successful and if it is not. If the call API is successful, the value true will be stored in a register. Otherwise, the value false will be stored. To do so, follow these steps:

    if_then_else_otp.gif
    1. Go to the blocks list and find the the Branch block category or type branch in the search bar.

    2. Click to open the category and see the blocks available. Drag the if then else conditional block into the canvas and connect it to the on start block below the set variable to block.

    3. Go to the blocks list and find the Call APIs block category or type call apis in the search bar. Then, click to open the category and see the blocks available, drag the execute call api and response success block into the canvas and connect it to the if then else block value slot.

    4. Then, find the api_generate_OTP_params variable in the Variables block category and drag it into the execute call api and response success block.

    5. To define the action to follow if the execution of the call API is successful, follow these steps:

      1. Go to the blocks list and find the Registers block category or type register in the search bar.

      2. Click to open the category and see the blocks available. Drag the save register with value block into the canvas and attach it to the if then else conditional block first socket.

      3. Define the register where the result will be stored. For this example, enter 10000. This register will then be retrieved by the invoking lambda to determine the result of the call API.

      4. Finally, to set the block value as true, go to the blocks list and find the Text block category or type text in the search bar. Then, click to open the category and see the blocks available, drag the " " block into the canvas and connect it to the save register with value block value slot. Complete the text block with true.

    6. To define the actions to follow if the execution of the call API is not successful, follow these steps:

      1. Go to the blocks list and find the Registers block category or type register in the search bar.

      2. Click to open the category and see the blocks available. Drag the save register with value block into the canvas and attach it to the if then else conditional block second socket.

      3. Define the register where the result will be stored. For this example, enter 10000. This register will then be retrieved by the invoking lambda to obtain the result of the call API.

      4. To set the block value as false, go to the blocks list and find the Text block category or type text in the search bar. Then, click to open the category and see the blocks available, drag the " " block into the canvas and connect it to the save register with value block value slot. Complete the text block with false.

      5. Finally, set the error message to be shown when the execution of the call API fails. To do so, Go to the blocks list and find the Registers block category or type register in the search bar.

      6. Click to open the category and see the blocks available. Drag the save register with value block into the canvas and connect it to the and attach it to the if then else conditional block second socket below the save register with value block previously configured.

      7. Complete the save register with value block first slot with 825, the register number that corresponds to generic messages.

      8. Go to the blocks list and find the Text block category or type text in the search bar.

      9. Click to open the category and see the blocks available. Drag the join block into the canvas and connect it to the save register with value block second slot.

      10. Type the error message to be shown if the call API fails into the join block first slot. For this example, type "Error generating OTP".

      11. Find the Registers block category in the blocks menu on the left or use the search bar. Click to open the category and see the blocks available. Drag the register text block into the canvas and connect it to the join block second slot.

      12. Complete the register text block with 112, the register number that corresponds to the call API result.

  8. Before saving, you can run the process through the simulator to test the logic of the inline lambda process and ensure that it works as expected. This step is optional.Simulator

  9. Click Save in the actions bar.

  10. The Commit message modal opens, complete the description of the last changes made and, if applicable, the details of the JIRA ticket involved, then click Save again to finish the creation process. The inline lambda process created is ready to be invoked from the lambda process that executes a monetary transaction after the user's identity is verified.

invoking_basic_info.gif
  1. Go to Logic in the top menu (☰) and click Processes.

  2. In the Lambda processes tab, click + Create.

  3. In the Create modal, you can choose between a process or an inline process. For this example, click Process. The lambdas editor opens and the header indicates that you are working on a lambda process.

  4. In the Process Basic Info tab that opens by default, complete information about the lambda process you are building.

    1. In the Name field, add a name to the lambda process that represents its functionality. For this example, set TRSF_TRX_CBU.

    2. In the Description field, add a short text that explains the aim of the logic created. If there is a transaction included in the process, add its code to the process description to easily track it. For this example, set Executes money transfer with trx 1068.

    3. In the Tags field, add keywords for you and your team to easily group processes according to their functionality. For this example, set transfer.

  5. Then, to clear the register that stores the call API result, find the Registers block category in the blocks menu on the left or use the search bar. Click to open the category and see the blocks available. Drag the clean register block into the canvas and connect it to the on start block.

    clean_and_execute_inline.gif
  6. Define the register where the call API result will be stored. For this example, enter 10000.

  7. To invoke the inline lambda process that executes the call API to generate the OTP, find the Next block category in the blocks menu on the left or use the search bar. Click to open the category and see the blocks available. Drag the execute inline lambda block into the canvas and connect it to the on start block below the clean register block.

  8. Select the inline lambda process previously created to be invoked and executed. For this example, select TKN_GENERATE_OTP.

  9. Then, set the transaction that executes the money transfer as a function. To do so, follow these steps:

    function_trx.gif
    1. Go to the blocks list and find the Functions block category.

    2. Click to open the category and click Make a Function... to create a new one.

    3. Set the function name and click Done to finish the creation process. For this example, enter executeTransfer.

    Best Practice

    Setting the transaction as a function is considered a good practice as it improves the readability of the lambda process.

  10. Once the function is created, set the transaction that executes the money transfer as a variable. To do so, follow these steps:

    1. Find the Variables block category in the blocks menu on the left or use the search bar.

    2. Click to open the category and click Make a Variable... to create a new one.

    3. Set the variable name and click Ok to finish the creation process. For this example, set trx_transf_params.

    4. Then, find the set variable to block, drop it into the canvas and connect it to the executeTransfer function.

    5. Select the trx_transf_params variable from the variables dropdown.

    6. Then, find the transaction created to execute the transfer. For this example, search for the transaction code 108. Drag the transaction block into the canvas and connect it to the set variable to block.

  11. To execute the transaction that executes the money transfer, follow these steps:

    1. Find the Transactions block category in the blocks menu on the left or use the search bar. Click to open the category and see the blocks available.

    2. Drag the execute transaction block into the canvas and connect it to the executeTransfer function below the set variable to block.

    3. Find the trx_transf_params variable in the Variables block category and drag it into the execute transaction block.

  12. Once you have configured the transaction function, define the actions to follow if the execution of the call API is successful and if it is not. If the call API is successful, the transaction is executed and a lambda process that shows the transaction receipt is also actioned. Otherwise, another lambda process that shows an error message is executed. To do so, follow these steps:

    if_then_else_invoking.gif
    1. Go to the blocks list and find the the Branch block category or type branch in the search bar.

    2. Click to open the category and see the blocks available. Drag the if then else conditional block into the canvas and connect it to the on start block below the execute inline lambda block.

    3. Drag the (" ") = (" ") comparison block from the Branch block category into the canvas and connect it to the if then else block value slot.

    4. Find the Registers block category in the blocks menu on the left or use the search bar. Click to open the category and see the blocks available. Drag the register text block into the canvas and connect it to the comparison block first value slot.

    5. Define the register where the call API result is stored. For this example, enter 10000.

    6. Finally, set the second block value as true. To do so, go to the blocks list and find the Text block category or type text in the search bar.

    7. Click to open the category and see the blocks available. Drag the " " block into the canvas and connect it to the comparison block second value slot. Complete the text block with true.

    8. To define the action to follow if the execution of the call API is successful, follow these steps:

      1. Go to the blocks list and find the Functions block category or type function in the search bar.

      2. Click to open the category and see the blocks available. Drag the call executeTransfer block into the canvas and attach it to the if then else conditional block first socket.

      3. Finally, go to the blocks list and find the Next block category or type next in the search bar.

      4. Click to open the category and see the blocks available. Drag the request next lambda block into the canvas and connect it to the if then else conditional block first socket below the call executeTransfer block.

      5. Select the lambda process that shows the transaction receipt.

    9. To define the actions to follow if the execution of the call API is not successful, follow these steps:

      1. Go to the blocks list and find the Next block category or type next in the search bar.

      2. Click to open the category and see the blocks available. Drag the request next lambda block into the canvas and connect it to the if then else conditional block second socket.

      3. Select the lambda process that shows the transaction error message.

  13. Before saving, you can run the process through the simulator to test the logic of the lambda process and ensure that it works as expected. This step is optional.Simulator

  14. Click Save in the actions bar.

  15. The Commit message modal opens, complete the description of the last changes made and, if applicable, the details of the JIRA ticket involved, then click Save again to finish the creation process. The lambda process created is ready to be invoked from the screen where operations such as money transfers are done.