Vulavula Logo
Integrations

Turn.io Integration

Turn.io ships built-in Lelapa.ai functions that expose Vulavula's Natural Language Processing capabilities inside Turn.io code blocks, so you can add intelligent text processing to your WhatsApp journeys.

You can also check out the Turn.io documentation for more information.

Prerequisites:

All Lelapa.ai functions operate within Turn.io code blocks and require a connection object (conn) established using lelapa_connect().

1. lelapa_connect(token)

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.

ParameterTypeDescription
tokenstringYour Lelapa.ai API token from your Lelapa.ai account

Returns: conn (object) — a connection object that must be passed as the first argument to all other Lelapa.ai functions. Its structure is opaque; treat it as a connection handle.

Error handling: incorrect or invalid tokens will result in a connection error. Turn.io code blocks should handle potential errors during connection establishment.

Example (Turn.io start node):

Code
card Start do conn = lelapa_connect("YOUR_LELAPA_API_TOKEN") if conn == nil do say("Error connecting to Lelapa.ai. Please check your token.") stop() end end

2. lelapa_translate(conn, text, source_language, target_language)

Translates the input text from source_language to target_language using Lelapa.ai's Translation API. It supports a range of languages, with a particular focus on African languages.

ParameterTypeDescription
connobjectThe connection object
textstringThe text to be translated
source_languagestringLanguage code of the source text (e.g., "eng_Latn", "zul_Latn")
target_languagestringLanguage code for the desired translation (same code standard as the source)

Returns: translation_result (map) — the translation result:

Code
%{ "__value__" => "translated_text", // String: The translated text "translation" => [ // List, typically contains one translation %{ "translation_text" => "translated_text" // String: Redundant key, same as "__value__" } ] }

Example (Turn.io code block):

Code
card TranslateText do text_to_translate = params[:message] # User input in source language source_lang = "eng_Latn" # Example: Assume source is English target_lang = "zul_Latn" # Example: Translate to Zulu translation_data = lelapa_translate(conn, text_to_translate, source_lang, target_lang) if translation_data != nil do translated_text = translation_data["__value__"] say("Original Text (#{source_lang}): #{text_to_translate}") say("Translated Text (#{target_lang}): #{translated_text}") else say("Translation failed.") end end

Important notes

  • Language codes: ensure you use correct and supported language codes for source_language and target_language in lelapa_translate() — see Language Support for the complete list.
  • Error handling: check for nil return values or utilise Turn.io's error handling mechanisms within code blocks.
  • Rate limits and usage: be aware of the rate limits and usage quotas of your Vulavula account to avoid service interruptions — see plans for details.
Last modified on