API Actions are a powerful feature that allows you to integrate your application with external services through APIs. You can define custom actions that make requests to external APIs and process the responses.

Use Cases

API Actions can be used for a variety of purposes, such as:

  • Sending data to a CRM: When a new user registers, you can use an API Action to send their information to your CRM.
  • Processing payments: Integrate with a payment gateway to process payments from your users.
  • Sending notifications: Send notifications to your users through a third-party service like Slack or Telegram.
  • Retrieving data: Fetch data from an external service and display it in your application.

Configuration

When configuring an API Action node in the workflow builder, you will need to provide:

  • Endpoint URL: The full URL of the external service (e.g., https://api.crm.com/v1/leads).
  • HTTP Method: GET, POST, PUT, PATCH, or DELETE.
  • Bearer Token: (Optional) The authentication token if the API requires Bearer auth.
  • Custom Headers: Any additional headers required by the API (e.g., X-Custom-Header: value).

Data Payload

You can dynamically construct the data sent to the API using two methods:

1. Fields Mapping

Map data from your internal system to the keys expected by the external API.

  • Key: The field name expected by the external API.
  • Value: The path to the data in the Nviti model (e.g., visitor.email, data.custom_field, metadata.source).

2. Append Data

Add static data to every request. useful for API keys or fixed tags.

  • Key: Static field name.
  • Value: Static value.

Response Handling & AI Integration

The system can intelligently handle the API response to interact with the user in the chat.

Direct Chat Response

If your API returns a JSON object with a chat_message key, its value will be immediately sent to the user as a message from the assistant.

Example API Response:

{
  "status": "success",
  "chat_message": "Thank you! Your ticket #12345 has been created."
}

AI-Interpreted Response

If you enable "Send Response to User" but the API does not return a chat_message field, the system will use AI to interpret the raw JSON response.

  1. The system converts the JSON response into a simplified format.
  2. The AI Assistant analyzes this data along with its persona and instructions.
  3. The Assistant generates a natural language response explaining the API result to the user.

This allows you to connect to complex APIs without needing them to return pre-formatted chat messages.