Text to Context Converter

Test this app for free
107
import logging
import os
from app_init import create_initialized_flask_app
from shared_resources import twilio_client

# Flask app creation should be done by create_initialized_flask_app to avoid circular dependency problems.
app = create_initialized_flask_app()

# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

if __name__ == "__main__":
    logger.info("Starting the application...")
    app.run(host='0.0.0.0', port=8080, debug=True)
    logger.info("Application stopped.")
    logger.info("Application stopped.")
Get full code

Created: | Last Updated:

App that converts user-provided text into contextual analysis using ChatGPT, returning results in a JSON format.

Here's a step-by-step guide on how to use the Text to Context Converter template:

Introduction

The Text to Context Converter is a powerful tool that analyzes user-provided text and generates contextual insights using ChatGPT. This template creates a web application with both a user interface and a WhatsApp integration, allowing users to input text and receive detailed analysis results.

Getting Started

  1. Click "Start with this Template" to begin using the Text to Context Converter in your Lazy project.

Setting Up Environment Secrets

Before running the app, you need to set up the following environment secrets:

  1. Navigate to the Environment Secrets tab in the Lazy Builder.
  2. Add the following secrets:
  3. TWILIO_ACCOUNT_SID: Your Twilio Account SID
  4. TWILIO_AUTH_TOKEN: Your Twilio Auth Token
  5. TWILIO_WHATSAPP_NUMBER: Your Twilio WhatsApp number

To obtain these values:

  1. Sign up for a Twilio account at https://www.twilio.com/ if you haven't already.
  2. Log in to your Twilio Console.
  3. Find your Account SID and Auth Token on the dashboard.
  4. To get a WhatsApp number, navigate to "Messaging" > "Try it out" > "Send a WhatsApp message" and follow the instructions to set up a WhatsApp Sandbox.

Testing the App

  1. Click the "Test" button in the Lazy Builder interface to deploy and run the application.
  2. Wait for the deployment process to complete.

Using the Web Interface

Once the app is deployed, you'll receive a server link to access the web interface. Here's how to use it:

  1. Open the provided link in your web browser.
  2. You'll see a text area where you can enter the text you want to analyze.
  3. Type or paste your text into the text area.
  4. Click the "Analyze" button to submit your text for analysis.
  5. The results will appear below the form, including a summary, context, key points, and urgency level.

Using the WhatsApp Integration

To use the WhatsApp integration:

  1. Add the Twilio WhatsApp Sandbox number to your contacts.
  2. Send a message to this number with the text you want to analyze.
  3. The bot will respond with the analysis results, including summary, context, key points, and urgency level.

Integrating the App

If you want to integrate this app into your own service or frontend, you can use the provided API endpoint:

  1. Use the /analyze endpoint to submit text for analysis.
  2. Send a POST request to https://your-app-url/analyze with the following JSON payload:

json { "text": "Your text to analyze goes here" }

  1. The API will respond with a JSON object containing the analysis results:

json { "summary": "A brief summary of the text", "context": "The context of the text", "key_points": ["Key point 1", "Key point 2", "Key point 3"], "urgency": "low|medium|high" }

You can also programmatically send WhatsApp messages using the /send_whatsapp endpoint:

  1. Send a POST request to https://your-app-url/send_whatsapp with the following JSON payload:

json { "to_number": "+1234567890", "message": "Your message here" }

  1. The API will respond with a success message and the Twilio message SID if the message was sent successfully.

By following these steps, you'll have a fully functional Text to Context Converter app that can analyze text through a web interface, WhatsApp, and API endpoints.

Technologies

Streamline CSS Development with Lazy AI: Automate Styling, Optimize Workflows and More Streamline CSS Development with Lazy AI: Automate Styling, Optimize Workflows and More
Enhance HTML Development with Lazy AI: Automate Templates, Optimize Workflows and More Enhance HTML Development with Lazy AI: Automate Templates, Optimize Workflows and More

Similar templates