FANA LLM v0.2.9 - Feedback and Sentiment Mechanism for Telegram Groups


Objectives:

  • Data-Driven Insights: Analyze customer and team interactions and provide valuable insights to help you make informed business decisions.

  • Sentiment Monitor: Analyze customer and team for positive or negative sentiment

  • Summarise, and suggest action plans, next steps and more

  • Expand the use cases and the conversational AI capabilities of the FANA LLM on messaging applications

  • Implement a daily feedback mechanism to provide teams with personalized communication

  • Ensure the AI will reply only with specific triggers and remove the need for a "/" at the bot command

    // Only respond to messages that start with 'Hey fana'
    if (text.includes('Hey fana')) {

Technology Used:

  • Node.js as the primary programming language

  • Express.js as the web framework

  • Axios for making API requests

  • Telegram Bot API for integrating with Telegram messenger

    // Function to make the query
    async function query(data) {
        console.log('Entering query function');
        try {
            const response = await axios.post(API_URL, data, {
                headers: {
                    Authorization: `Bearer ${process.env.API_TOKEN}`,
                    'Content-Type': 'application/json',
                },
            });
            console.log('Query successful');
            return response.data;
        } catch (error) {
            console.error('Error in the query:', error.message);
            throw error;
        }
    }
  • Redis for storing and retrieving message history

  • Cron job scheduler for scheduling daily feedback

New Features:

  • Improved Telegram integration AI capabilities using advanced natural language processing (NLP) techniques

  • Daily feedback mechanism that provides users with personalized summaries and action plans

    // Function to send daily feedback
    async function sendDailyFeedback() {
        console.log('Entering sendDailyFeedback function');
    
        try {
            // Send a command to the backend to generate the feedback
            const result = await query({ question: 'generate daily feedback' }); // Use the entire text as the query
            console.log('Query result:', result);
    
            // Extract the text from the JSON response
            const responseText = result.text || 'Could not retrieve response text';
            console.log('Response text:', responseText);
    
            // Log for outgoing message
            console.log(`Response: ${responseText}`);
    
            // Send the response to multiple Telegram chats
            const chatIds = ['-chatIdHere', '-chatIdHere'];
            for (const chatId of chatIds) {
                await axios.post(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage`, {
                    chat_id: chatId,
                    text: responseText,
                    parse_mode: 'Markdown', // Add this parameter to enable Markdown parsing
                });
                console.log(`Sent response to Telegram chat ${chatId}`);
            }
        } catch (error) {
            // Handle errors
            console.error('Error sending daily feedback:', error.message);
        }
    }
    
    
    // Schedule the daily feedback
    cron.schedule('0 12 * * *', sendDailyFeedback);
    console.log('Scheduled daily feedback to run at 12:00 UTC every day');
  • Enhanced error handling and logging for improved system reliability

    console.log('Entering query function');
    console.log('Entering handleTelegramMessage function');
    console.log('Entering sendDailyFeedback function');
    console.log('Scheduled daily feedback to run at 12:00 UTC every day');

Bug Fixes:

  • Fixed issue with query processing that caused errors in response generation

  • Fixed issue with message history storage that caused data loss

  • Improved performance of the system by optimizing database queries

Known Issues:

  • None

Future Development:

  • Integrate with additional messaging platforms (e.g. WhatsApp, Slack)

  • Build a RAG system for chat_history leveraging embeddings and cosine similarity

  • Enhance the conversational AI capabilities with more advanced NLP techniques


Last updated