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

Aditya Oberai @adityaoberai

About: Loves everything hackathons and communities ❤

Location:
India
Joined:
Oct 6, 2019

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

Publish Date: Jun 16 '24
38 13

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!

Comments 13 total

  • Sojin Samuel
    Sojin SamuelJun 16, 2024

    Wonderful contribution adi :)

    • Aditya Oberai
      Aditya OberaiJun 16, 2024

      Thank you!

      • Sojin Samuel
        Sojin SamuelJun 16, 2024

        You're welcome, you might like my extended version of this same whatsapp chatbot:
        How to create a whatsapp chatbot with custom knowledge base (with twilio, supabase)

        • Aditya Oberai
          Aditya OberaiJun 17, 2024

          I did extend the application to save and check state using Appwrite

      • chintanonweb
        chintanonwebJun 17, 2024

        I don't have idea for two way communication in twilio whatsapp and how to confuigure function for response can you please guide me!

        • Sojin Samuel
          Sojin SamuelJun 17, 2024

          Are you planning to use twilio functions instead of tunneling via ngrok?

          aditya has already given the open source example for a serverless function you can easily migrate it. but if you face any difficulties feel free to reach out.

          Make sure to read about:
          Twilio functions (Implement very basic ones first), Twilio code exchange has starter examples.
          How to use the sandbox environment, and implement webhooks for a 2 way conversation have already listed on my article.

          Can't wait to see what you come up with and best of luck with @twilio1 challenge.

  • Tonic
    TonicJun 17, 2024

    i came for the source code and i wasnt disappointed. thank you !

    • Aditya Oberai
      Aditya OberaiJun 17, 2024

      NGL, it's a bit janky at the moment (need to add proper error handling and all 😆)

      But I will be improving it going further and writing some content on how to build this sort of a tool 😌

  • Devarshi Shimpi
    Devarshi ShimpiJun 19, 2024

    Well made!

  • Neurabot
    NeurabotJun 25, 2024

    Innovative and exciting.

Add comment