Skip to main content

AloAi Agents custom functions setup guide

Laarni D avatar
Written by Laarni D
Updated today

What are AloAi Agents' custom functions?

Custom functions in AloAi provide the ability to define specific actions that interact directly with external systems or APIs. This feature facilitates data exchange, enabling AloAi agents to perform real-time automated tasks based on customer inputs.

By utilizing custom functions, your bots can execute dynamic workflows, fetch data, and trigger operational processes, such as updating customer records or confirming transactions, without requiring manual intervention.


Creating and applying a custom function

  1. Adding a new custom function

    1. To add a new custom function to an existing AloAi Agent or when creating a new one (either Voice or Text), navigate to the Custom Functions tab.

      Custom functions tab in AloAi Voice Agents

      Custom functions tab in AloAi Text Agents

    2. Click on +Add Function to start the setup.

    3. Configure your custom function

      Function name - enter a name for your custom function.

      Function description - provide a brief description that helps the AloAi Agent understand the purpose of this custom function, when to use it, and what it should communicate when executing.

    4. Additional settings

      Respond to the contact during execution - enable this option if you want the agent to provide audible feedback while executing the function. This is particulary helpful if the execution takes longer than 3 seconds.

      Respond to the contact after execution - enable this option if you want the agent to communicate with the contact after the function has completed.


Additional settings

  1. Define your variables

    Determine the pieces of information you need (e.g., CustomerFirstName, CustomerLastName, CustomerEmail).

    Each variable should have a type (string, number, etc.) and indicate whether it is required for execution.

    • CustomerEmail - string, required

    • CustomerLastName - string, required

    • CustomerFirstName - string, required

  2. Setup the API request

    Choose the request type - select the appropriate method for your request based on your API requirements. In this example, a POST request is recommended for creating new resources. However, if POST is unavailable, you may opt for a GET request to retrieve data instead.

    Method available:

    • GET - used to retrieve data from the server. It does not modify any resources and is typically safe and idempotent.

    • POST - utilized to create new resources on the server. It submits data to be processed and can result in a change in the server's state.

    • PUT - employed to update an existing resource entirely. It replaces the resource with the request payload and is idempotent.

    • DELETE - used to remove a specified resource from the server. This method is idempotent, meaning repeated requests will have the same effect.

    • PATCH - similar to PUT, but it is used to apply partial modifications to a resource. It updates only the fields provided in the request.

    Add parameters - add any necessary query parameters or body data that your API endpoint requires.

    Examples of JSONs:

  3. Execute the function and test the API call

    Connect and send data - use the defined function to send the prepared data to the API, simulating the request as needed. Ensure that you provide real data values during testing.

  4. Handle API responses

    1. Set up response handling - define how to handle the data returned from the API.

    2. Map the response to the relevant fields in your application.

      Example: Map field ProductMessage in response to RecordStatus from API response.

  5. Save and test your function

    Ensure to save your function once all parameters and settings are configured properly.

  6. Integrate with user interactions

    Integrate the function into user prompts - specify when the custom function should be called based on user queries (e.g., if a user asks about Cancel Customer Reservation or Account).

    Add action > Custom function

    Select custom function

    Example:

    If the user asks about the cancel reservation:

    • Add action - cancel customer account

    • Specify which custom function to use

Did this answer your question?