How To Build New Aurora Functions
How To Build New Aurora Functions
How To Build New Aurora Functions
This guide outlines the steps required to add a new function inside our app using Python. Follow these steps carefully to ensure proper integration with the system.
This guide outlines the steps required to add a new function inside our app using Python. Follow these steps carefully to ensure proper integration with the system.
Step 1: Create a New Function File
Navigate to app/functions
and create a new Python file named after the function you are building. Ensure the file name follows the convention: function_name.py
.
Navigate to app/functions
and create a new Python file named after the function you are building. Ensure the file name follows the convention: function_name.py
.
Example: If you are building a function to send a text message to a team, create a file called:
Example: If you are building a function to send a text message to a team, create a file called:
app/functions/send_text_to_team.py
Inside this file, define your function and include the necessary logic.
Inside this file, define your function and include the necessary logic.
Step 2: Organize and Integrate the function
Create an appropiate module (if not already present)
Example modules:
app/functions/text_functions.py
for text-related functionsapp/functions/jobber_functions.py
for job-related functions
Import your function in the module.
Define a handler function.
Add preprocessing and additional logic before calling your function.
Include logging to track when the function is called
Create an appropiate module (if not already present)
Example modules:
app/functions/text_functions.py
for text-related functionsapp/functions/jobber_functions.py
for job-related functions
Import your function in the module.
Define a handler function.
Add preprocessing and additional logic before calling your function.
Include logging to track when the function is called
from app.functions import( # Other Functions function_name as function_name_function ) def function_name(data): """ Description """ logger.info("Called function_name") # Handle data before calling the function return function_name_function(data)
Ensure functions include proper docstrings
Every function should have a clear docstring explaining:
Its purpose
Expected parameters
Return value
Example usage
Ensure functions include proper docstrings
Every function should have a clear docstring explaining:
Its purpose
Expected parameters
Return value
Example usage
def function_name(data) -> str: """ Briefly describe what this function does. Args: param1 (str): Description of the first parameter. param2 (int): Description of the second parameter. Returns: str: Explanation of the return value. Example: result = function_name(data) print(result) # Expected output example """ # Function implementation here...
How the Assistant Uses This Function
The assistant automatically extracts the required parameters from the function call and passes them as arguments. To ensure seamless execution, the function signature should match the expected input format.
After the function is called:
If it executes successfully, the assistant will use the returned value to generate a response or take the next appropriate action.
If an error occurs or the function returns an unexpected value, the assistant will interpret the result and explain what went wrong.
How the Assistant Uses This Function
The assistant automatically extracts the required parameters from the function call and passes them as arguments. To ensure seamless execution, the function signature should match the expected input format.
After the function is called:
If it executes successfully, the assistant will use the returned value to generate a response or take the next appropriate action.
If an error occurs or the function returns an unexpected value, the assistant will interpret the result and explain what went wrong.
Step 3: Add the Function to Calendar Agent
Modify app/swarm/calendar_agent.py
to make the function accessible via the agent.
Modify app/swarm/calendar_agent.py
to make the function accessible via the agent.
Import your function from the module.
Locate the
build_agent_from_config
function.Add your function to the
function_map
.
Import your function from the module.
Locate the
build_agent_from_config
function.Add your function to the
function_map
.
from app.functions.module import ( # Other Functions function_name ) def build_agent_from_config(assistant_config, user_phone,session_id): ... function_map = { # Other functions... "function_name": function_name, } ...
Step 4: Update the Database for Assistant Access
For the assistant to access this new function, update the assistantId_to_info
database table.
For the assistant to access this new function, update the assistantId_to_info
database table.
Locate the assistant you want to associate with this function.
Add the function name under the
functions
row.(Optional) Add function usage examples inside assistantPrompt
Locate the assistant you want to associate with this function.
Add the function name under the
functions
row.(Optional) Add function usage examples inside assistantPrompt
Step 5: Call and Test the New Function
Once all the above steps are complete, call your assistant and test the newly added function.
Once all the above steps are complete, call your assistant and test the newly added function.
Ensure the assistant recognizes the new function.
Verify that the function executes as expected.
Check logs to confirm the function call is recorded properly.
Debug any issues as needed.
Ensure the assistant recognizes the new function.
Verify that the function executes as expected.
Check logs to confirm the function call is recorded properly.
Debug any issues as needed.
Smarter Conversations Start Here
Smarter Conversations Start Here
Smarter Conversations Start Here
With VoxSuite, you can deliver better customer service while saving time and money. Let Aurora do the heavy lifting, so you can focus on what matters most.
With VoxSuite, you can deliver better customer service while saving time and money. Let Aurora do the heavy lifting, so you can focus on what matters most.
