Skip to main content
If you are looking for a function that only exists inside a single flow, visit the transition functions page.
Functions are custom Python scripts designed to handle tasks requiring deterministic logic or API integrations. They enhance the agent’s ability to interact with external systems and allow for advanced customization of responses. Use conv.log to write structured logs that appear in Conversation reviewDiagnosis and using the Conversations API.
In the Agent Studio UI, functions are found under Build > Tools in the sidebar. Functions are a type of tool alongside other integrations. The special start function and end function retain their original names.
For detailed guides, explore the subpages below:

Subpages

  1. How to set up a function: Learn how to set up a function, including naming conventions, parameter definitions, and writing Python code.
  2. How to import libraries: Understand how to use standard and non-standard libraries within your function, enabling external API integrations.
  3. How to start a function: Discover the role of the start_function in initializing conversation context and preparing data before user interactions.
  4. Understanding return values: Explore how to use string and dictionary return values to dynamically guide the agent’s behavior.
  5. Using the conv object: Reference the conv object to manage conversation states, flows, and telephony-related attributes effectively.
  6. Working with variables: Learn how to define, update, and persist variables across turns using the conversation state.
  7. Invoking functions in the knowledge base: Discover methods for integrating functions into the knowledge base and testing their usage effectively.
  8. The delay controls interface: Keep the conversation on track in high-latency functions by adding delay phrases.
  9. Logging from functions (conv.log): Record structured diagnostics and PII-scoped entries for review in Diagnosis and export using the API.
  10. Conversation utilities (conv.utils): Use built-in helpers to extract and validate structured data like addresses and cities from user input.
  11. Agent memory: Store and retrieve persistent data about users across conversations for repeat-caller logic and personalization.
If you are looking to use functions to enable multi-site configuration, like handling reservations for multiple restaurant locations, visit the variant management feature page.

Best practices

  • Use descriptive names – Action-oriented names like book_reservation or send_notification help the LLM understand when to call the function.
  • Write clear descriptions – Explain what the function does, its parameters, and when it should be triggered.
  • Use meaningful parameter namesreservation_date is clearer than r_date.
  • Control triggering – Define specific rules to prevent over-triggering or under-triggering.
  • Test thoroughly – Use Test Cases and Test Sets to validate function behavior across scenarios.

Troubleshooting

  • Function not triggering – Check Conversation review → Diagnosis to see if the function was considered. Refine your function description or add clearer rules.
  • Wrong parameters – Review conv.log entries to see what the LLM extracted. Adjust parameter descriptions or add validation.
  • Unexpected behavior – Simplify function logic and test in isolation before integrating with the agent.