Twilio Challenge: Language Translator via Twilio Functions, WhatsApp, Appwrite & OpenAI

Aditya Oberai - Jun 16 - - Dev Community

This is a submission for Twilio Challenge v24.06.12

What I Built

As an avid translator who often faces challenges with different languages when traveling across different countries. To solve my own problem, I wanted to create a simple chatbot that lets me quickly translate text from my preferred language to another, making it so much easier to communicate with other people.

Therefore, I created an AI Language Translator using the WhatsApp Sandbox mode in Twilio Programmable Messaging, Twilio Functions, Appwrite Database and OpenAI's GPT-4o API.

Demo

Watch how it works

Here is a demo video of the app:

Tech Stack

  • The chatbot uses Twilio Programmable Messaging (WhatsApp Sandbox) and Twilio Functions to communicate with the user.
  • Appwrite Database is primarily used to store the state of the user through the conversation, and all conversation data is deleted as soon as the translation is sent to the user.
  • OpenAI's GPT-4o API is used to translate the text to the specified language.

Steps to try

You can try it out by scanning the QR Code in the image or by texting the code join trail-has to the number +14155238886 on WhatsApp.

Twilio WhatsApp Sandbox

Once that is done, send the message Hello Twilio to begin using the chatbot.

Source code

You can also view the source code of the Twilio Function on GitHub:

GitHub logo adityaoberai / language-translator-twilio-function

Twilio function that translates language using GPT-4o and responds through the Twilio Programmable Messaging on WhatsApp

Twilio Challenge: Language Translator via Twilio Functions, WhatsApp, Appwrite & OpenAI

Description

Twilio function that translates language using GPT-4o and responds through the Twilio Programmable Messaging on WhatsApp

Screen_Recording_20240617_172845_WhatsApp.mp4

How it works

  • Twilio Programmable Messaging (WhatsApp Sandbox) and Twilio Functions is used to communicate with the user
  • Appwrite Database is used to store the state of the user through the conversation, and all conversation data is deleted as soon as the translation is sent to the user
  • OpenAI's GPT-4o API is used to translate the text to the specified language



Twilio and AI

To create this chatbot, I used OpenAI's GPT-4o API in a Twilio Function. This function consumes the text to translate, and the target language based on the user's input and returns the translated text.

Additional Prize Categories

  • Twilio Times Two: The project uses Twilio Programmable Messaging (WhatsApp Sandbox) and Twilio Functions.

  • Impactful Innovators: In a far more interconnected world than ever, a tool that simplifies cross-language communication will help bring people from different cultures closer together.

Feedback, Updates, and Testimonials

  • During the process of developing the Twilio Function, I discovered an issue with the max length of environment variables. The issue has already been acknowledged by the Twilio team.

Just finished my submission 🥳

@anthonyjdella, I do have some product feedback. When trying out Twilio Functions, I noticed that the max length of environment variables is set to 255 characters. I was using Appwrite Databases as a part of my project, and the API keys happened to be 256 characters in length. This made it somewhat challenging to use environment variables for that purpose.

  • The project is getting real-world usage and positive user feedback publicly!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .