Skip to main content

How to set up custom functions in AloAi Agents

Set up custom functions in AloAi Agents to automate tasks, connect APIs, and enhance real-time customer interactions.

Written by Laarni D

Custom functions allow AloAi Voice and Text Agents to communicate with external systems through APIs. A custom function can retrieve information, send data, or trigger an action based on information collected during a conversation.

For example, an agent can use a custom function to retrieve customer information, check appointment availability, update a CRM record, or submit information to another system.


When to use custom functions

Use a custom function when an AloAi Agent needs to retrieve real-time information or perform an action in an external system during a conversation.

AloAi text agents

  1. Self-service answers from live data

    Use a function to automatically pull policy information, pricing, or order status from your support systems.

    Example: When a user asks, “What’s your return policy?”, the agent uses a function to fetch the latest policy from your knowledge base.

  2. Lead capture and qualification

    Automatically follow up with missed callers or new inquiries by asking for key lead details (e.g., business size). Based on their answers, the function can update your CRM or route the lead to sales.

  3. Appointment booking via text

    Connect the agent to your scheduling tool. Users can check available slots and confirm bookings without agent assistance—all done through a triggered API call.

  4. Personalized marketing responses

    If a user asks about promotions, the agent can call a function to pull applicable offers from your CRM and reply with tailored content or follow-up actions (e.g., sending a discount code).

AloAi voice agents

  1. Smart call routing and IVR

    Voice Agents can handle routing using logic from your internal systems.

    Example: If the caller says “billing,” a function determines the right department and handles the transfer.

  2. Missed call follow-up

    When no one is available to take the call, use a function to log the details and send a follow-up via SMS or email—ensuring no inquiry is lost.

  3. Legal and consulting intake

    Voice Agents can pre-screen callers by collecting case or inquiry details. The function forwards this data to your intake system for review by your team.

  4. Outbound sales and booking

    For sales development (SDR/BDR) tasks, Voice Agents can call leads, assess interest using a function, and schedule meetings directly in your calendar.


Creating and applying a custom function

  1. Adding a new custom function

    1. To create a function, go to your AloAi Agent (Voice or Text) and navigate Function card > Advanced > Custom Function.

    2. Configure your custom function

      Name it and describe what it does. The description helps the agent understand when to use this function and what to say when it’s called.

      Note: The description has a 255 character limit, so keep it short and clear. One or two sentences explaining what the function does and when the agent should use it.

    3. 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 particularly 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

    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

    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?