Turn.io Integration
This document provides a overview of Lelapa.ai functions available for integration within Turn.io. These functions expose Vulavula's Natural Language Processing (NLP) capabilities, allowing developers to enhance Turn.io applications with intelligent text processing features.
You can also check out the Turn.io Documentation for more information.
Prerequisites:
- A Vulavula API Key is required. Obtain it at Vulavula Platform.
- Familiarity with Turn.io platform and its code block functionality.
Function Details:
All Lelapa.ai functions operate within Turn.io code blocks and require a connection object (conn
) established using lelapa_connect()
.
1. lelapa_connect(token)
Description:
This function establishes a persistent connection to the Lelapa.ai API using the provided API token
. It handles authentication and sets up the necessary context for subsequent Lelapa.ai function calls.
Input Parameters:
token
(String): Your Lelapa.ai API token obtained from your Lelapa.ai account.
Return Value:
conn
(Object): A connection object. This object must be passed as the first argument to all other Lelapa.ai functions. The specific structure of this object is opaque to the Turn.io user and should be treated as a connection handle.
Error Handling:
- Incorrect or invalid tokens will likely result in a connection error. Turn.io code blocks should handle potential errors during connection establishment.
Code Example (Turn.io Start Node):
Code
2. lelapa_intent_classification(conn, text, intents)
Description:
This function utilizes Lelapa.ai's Intent Classification API to classify the text
based on a provided list of intents
. It employs a minimal-training approach, allowing for effective classification with limited examples.
Input Parameters:
conn
(Object): The connection object returned bylelapa_connect()
.text
(String): The input text to be classified (e.g., user message).intents
(List of Lists): A list defining intents and their example phrases. Each inner list has the format:["intent_name", "example_phrase"]
.
Return Value:
result
(Map): A map containing the classification result. Structure:Code
Data Types:
text
: Stringintents
:List<List<String>>
result
:Map<String, String | Float>
Code Example (Turn.io Code Block):
Code
3. lelapa_entity_recognition(conn, text)
Description:
This function leverages Lelapa.ai's Entity Recognition API to identify and extract entities from the input text
. It supports recognition of various entity types (e.g., person, location, organization).
Input Parameters:
conn
(Object): The connection object.text
(String): The input text for entity recognition.
Return Value:
entities
(List of Maps): A list of extracted entities. Each entity is represented as a map:Code
Data Types:
text
: Stringentities
:List<Map<String, String | Integer>>
Code Example (Turn.io Code Block):
Code
4. lelapa_sentiment_analysis(conn, text)
Description:
This function utilizes Lelapa.ai's Sentiment Analysis API to determine the sentiment (positive, negative, or neutral) of the input text
. It can analyze sentiment at a sentence level and provide an overall sentiment for the entire text.
Input Parameters:
conn
(Object): The connection object.text
(String): The input text for sentiment analysis.
Return Value:
sentiment_result
(Map): A map containing sentiment analysis results. Structure:Code
Data Types:
text
: Stringsentiment_result
:Map<String, String | Float | List<Map<String, List<Map<String, String | Float>>>>>
(Complex structure, refer to example)
Code Example (Turn.io Code Block):
Code
5. lelapa_translate(conn, text, source_language, target_language)
Description:
This function utilizes Lelapa.ai's Translation API to translate the input text
from source_language
to target_language
. It supports a range of languages, particularly focusing on African languages.
Input Parameters:
conn
(Object): The connection object.text
(String): The text to be translated.source_language
(String): Language code of the source text (e.g.,"eng_Latn"
for English,"zul_Latn"
for Zulu). Refer to Lelapa.ai documentation for supported language codes.target_language
(String): Language code for the desired translation language (following the same code standard assource_language
).
Return Value:
translation_result
(Map): A map containing the translation result. Structure:Code
Data Types:
text
: Stringsource_language
: String (Language Code)target_language
: String (Language Code)translation_result
:Map<String, String | List<Map<String, String>>>
Code Example (Turn.io Code Block):
Code
Important Notes:
- Language Codes: Ensure you use correct and supported language codes for
source_language
andtarget_language
inlelapa_translate()
. Refer to language support for the complete list of supported codes. - Error Handling: Check for
nil
return values or utilize Turn.io's error handling mechanisms within code blocks. - Rate Limits and Usage: Be aware of any rate limits or usage quotas associated with your Vulavula account to avoid service interruptions. Consult plans for details.