Skip to main content

Functions

The Functions section allows users to define tool calls that extend the chatbot's capabilities by integrating with external services, such as APIs or SMTP for email. Functions enable dynamic actions, making the chatbot capable of handling complex workflows and real-time interactions.


What is a Function?

A Function is a tool call that enables the chatbot to perform actions like retrieving data from external APIs, sending emails, or interacting with custom services. Functions are triggered automatically based on user interactions or predefined tasks. The chatbot uses the function to fetch or perform the action, and users can control how the result is displayed using the response field.


Supported Actions

HTTP Action

The HTTP Action enables the chatbot to make API calls to external services.

Example Use Case:
Retrieve product details from an API.

Example Workflow:

  • The chatbot receives a request: "Tell me more about product ID 12345."
  • The function triggers an HTTP Action to fetch product details from an API endpoint.
  • The response is formatted and displayed to the user based on the defined output in the function's response field.

SMTP Action

The SMTP Action allows the chatbot to send emails using configured SMTP settings.

Example Use Case:
Send a confirmation email after a user completes registration.

Example Workflow:

  • The chatbot receives user data, such as an email address.
  • It triggers an SMTP Action to send a custom email message to the user.
  • The chatbot may notify the user that the email has been sent, with the response formatted as per the function's definition.

How to Define Functions

  1. Create a New Function:
    Provide a name and description for the function, explaining its purpose clearly.

  2. Add Properties:
    Define input parameters (e.g., user ID, product ID) required by the function. These parameters allow the chatbot to dynamically handle data during interactions.

  3. Configure Actions:
    Specify the actions the function should perform, such as API requests (HTTP) or email sending (SMTP). Each action defines how the function interacts with external services.

  4. Define the Response Format:
    In the response field, define how the chatbot should display the results after the function is executed. This response can be customized to include dynamic data returned by the function.

  5. Assign the Function:
    Once defined, the function will automatically trigger when a relevant interaction occurs in the chatbot. No manual intervention is required to activate the function.


Example Scenarios

1. Fetch User Data from an API

  • Task: Retrieve user profile information from an internal service.
  • Action: HTTP request to https://api.example.com/users/{userId}.
  • Response Format:
    "Here are the details for the user with ID {userId}..."

2. Send a Welcome Email

  • Task: Send a welcome email to new users.
  • Action: SMTP email action using the platform's email template.
  • Response Format:
    "A welcome email has been sent to {userEmail}. Let me know if you need anything else!"

Benefits of Functions

  • Extend Capabilities: Integrate the chatbot with your services, APIs, or third-party tools.
  • Dynamic Responses: Automate real-time actions like data retrieval and messaging.
  • Custom Output: Control how results are presented to users using the function's response field.
  • Seamless Automation: Functions are triggered automatically based on chatbot interactions, making workflows efficient and user-friendly.

By defining custom functions, you empower your chatbot to interact with your infrastructure and services, providing a richer, dynamic experience for users.