Imagine you’re part of an organization, whether it’s a new one or you’ve been using the platform for a while. You’ve just finished planning your program, carefully crafting each message and determining the flow of the entire discussion as well as the user experience. To put your plan into action, you start by creating a flow, building the entire user conversation one node at a time in the flow editor screen. You add labels and store data points as you go.
Once your flow is complete, you realize that since your program will be launched in multiple languages, you want to make some adjustments by translating the messages into those languages. How would you typically handle this? Probably by clicking on each node, copying the text that needs to be translated, pasting it into Google Translate, copying the translated text from another tab, and then pasting it back into the flow. You’d repeat this process for each node, while constantly thinking and frequently checking what if a node is left untranslated.
Now, take a moment to consider what if there was a magic button you could click, and all the nodes would be translated, making your task a breeze. Sounds exciting, doesn’t it? Well, this isn’t just a far-fetched dream. We’ve recently made progress in developing an auto-translation feature in Glific to address exactly this issue.
We’ve been thinking about auto translation for a while, but we couldn’t work on it due to other commitments. However, this time around, we’ve picked it up and started brainstorming and documenting how the auto translation feature works in Glific. We’ve also analyzed the current state of things, like how many organizations are using flow in multiple languages and which languages are most commonly used. As the document started taking shape, we had some internal discussions and invited organizations to review and contribute their thoughts to gain a better understanding before we start development. Interested folks can read more about it here.
Once we finalized the requirements, development began at the end of 2023. While we at Project Tech4dev were preparing for a week-long organization break, it was the OGs who stepped up and decided to work on this feature during the break. Kudos to Kurund and Lobo for their dedication and hard work. By the time we returned from the break, most of the development was already completed, and we were ready to launch the feature on staging for the team to test and experiment with.
A small translation button at the bottom of the flow editor screen is added. This button provides three options:
Automatic translation: This option automatically translates the text in send_msg node.
Export translations: It generates a CSV file with existing text in the send_msg node, including a column where translation is missing.
Import translations: This option accepts a CSV file with text for the send_msg node, along with all the translations.
While working on this feature we made a couple of decisions along the way:
Where to start with:
While the idea of translating the entire flow with a single click may seem tempting, we also need a practical starting point. So, we made the decision to begin by translating the “send_msg” node. However, sending messages can be done in three ways entering message text, using templates, or using interactive messages. To keep things simple and easy to test, we opted to start with translating message text initially. Down the line, we may consider introducing translation for templates and interactive messages as well.
Choosing the Translation Engine:
When deciding on the translation engine, we considered the fact that organizations use various translation engines for their programs, depending on the language and local dialect. Since we didn’t have a direct comparison between different translation engines, we opted to use the OpenAI API. We recently secured a $15,000 grant in our Open AI account, which we plan to use to kickstart the auto-translation feature with OpenAI for beta usage.
In the future, we might consider switching to Google Translate, Bhasini, or other language translation modules. Additionally, we’ll be using our OpenAI keys for production usage, allowing organizations to use auto-translate without needing their own OpenAI keys or incurring additional costs.
Text Size Limit:
While the latest GPT models support up to 16K tokens, for the beta version, we want to limit it to a smaller number of tokens. This is because converting fairly large text can take a considerable amount of time.
To determine an appropriate limit, we conducted research by exporting published flows in Glific across various organizations and calculated the average size of text used in send_message nodes. Based on our findings, we decided to set a limit of 200 tokens.
Additionally, to make efficient use of API calls to OpenAI, we’ll chunk together nodes based on size so multiple nodes with small text will be clubbed together for translation, while fairly long text will be translated individually.
Prompt for text
Now, we have to send the text to OpenAI along with a prompt to translate it from the source language to the destination language. Here’s the prompt we’re currently using
I'm going to give you a template for your output. CAPITALIZED WORDS are my placeholders.
Please preserve the overall formatting of my template to convert list of strings from english to hindi.Each comma separated strings can be multi-lined where linebreak can be \n or \n\n. Keep the translated message also multi-lined
["CONVERTED_TEXT_1", "CONVERTED_TEXT_2","CONVERTED_TEXT_3"]
Please return only the list. Here's sample
User: ["hello there", "oops wrong answer", "Great to meet you"]
Think: there are 3 comma separated strings list in english convert it to 3 comma separated list of string in hindi
System: ["नमस्ते", "उफ़ ग़लत उत्तर", "बड़ा अच्छा लगा आपसे मिल के"]
User: ["welcome", "correct answer, keep it up", "you won 1 point"]
Think: there are 3 comma separated strings list in english convert it to 3 comma separated strings list in tamil
System: ["வரவேற்பு", "சரியான பதில், தொடருங்கள்", "நீங்கள் 1 புள்ளியை வென்றீர்கள்"]
Locking the Flow Screen
During the auto-translation process, which may take time depending on the number of nodes and the length of the text, we’ll lock the flow screen to prevent any potential overlap.
Feature Flag
Although this feature seems game-changing and holds great potential, we’re taking a cautious approach by implementing a feature flag. Initially, we’ll enable it for only a select few organizations, allowing us to thoroughly test, gather feedback, and make necessary improvements before rolling it out for general use. Currently, we have released this feature on our staging environment, where our product team is conducting testing. If you’d like to try it out, please feel free to do so in the staging environment and share your feedback with us. We value your input!
With this we’re off to a great start in 2024 as we’re on the brink of rolling out something big. This feature is a game-changer for NGOs on Glific, transforming the way multilingual conversational flows are created. Say goodbye to the old ways of manual translation work one node at a time while constantly thinking and frequently checking if a node is left untranslated. With Auto Translation translation can be done on a click of a button making it super simple and time-efficient. Get ready to experience the difference!”
