LinkedinMonitor / chatbot_prompts.py
GuglielmoTor's picture
Update chatbot_prompts.py
b75ee17 verified
raw
history blame
6.34 kB
# chatbot_prompts.py
import logging
def get_initial_insight_and_suggestions(plot_id: str, plot_label: str, plot_data_summary: str = None):
"""
Generates an initial insight (now including a data summary) and suggested questions for a given plot.
Args:
plot_id (str): The unique identifier for the plot.
plot_label (str): The display label for the plot.
plot_data_summary (str, optional): A textual summary of the data for the plot.
Returns:
tuple: (initial_chat_message_dict, list_of_suggestion_strings)
"""
logging.info(f"Generating initial insight for plot_id: {plot_id}, label: {plot_label}")
# logging.debug(f"Data summary for initial insight of '{plot_label}':\n{plot_data_summary}")
base_persona = "As an expert in Employer Branding and LinkedIn social media strategy, here's an insight on your "
insight_text = f"{base_persona}**{plot_label}**:\n\n"
# Include the data summary if available
if plot_data_summary and plot_data_summary.strip() and "No data summary available" not in plot_data_summary and "Error generating data summary" not in plot_data_summary and "Accesso negato" not in plot_data_summary:
insight_text += f"Here is a snapshot of the data for your '{plot_label}' chart:\n```text\n{plot_data_summary}\n```\n\n"
else:
insight_text += f"Currently, no specific data snapshot is available for '{plot_label}' to include here. General insights apply.\n\n"
# Default suggestions - these can be made more dynamic later if needed
suggestions = [
f"What are the key drivers for {plot_label.lower()} based on the data?",
f"How can I improve my {plot_label.lower()} according to these trends?",
f"What does good performance look like for {plot_label.lower()}?"
]
# Customize insights and suggestions per plot_id
# These specific insights can now refer to the data summary provided above.
if plot_id == "followers_count":
insight_text += ("Tracking your 'Numero di Follower nel Tempo' is crucial. A steady increase, as potentially shown in the data snapshot, indicates growing brand reach and influence. "
"If you observe stagnation or decline, it might be time to review your content strategy, posting frequency, or engagement tactics with your target audience. "
"Consider running campaigns or promoting your LinkedIn page on other channels.")
suggestions = [
"Based on the follower data, what was our peak growth period?",
"How often should I post to maximize follower growth according to LinkedIn best practices?",
"What content typically resonates most with potential followers on LinkedIn?"
]
elif plot_id == "engagement_rate":
insight_text += ("Your 'Tasso di Engagement nel Tempo' is a vital indicator of how compelling your audience finds your content. Higher rates, reflected in the data, signify that your posts are sparking meaningful interactions. "
"If engagement is low, re-evaluate content relevance, the types of media used, and the clarity of your calls to action. Experiment with questions, polls, and interactive content.")
suggestions = [
"What does the engagement trend tell us about recent content performance?",
"What types of posts typically get the highest engagement on LinkedIn?",
"Can you give me examples of strong calls to action for LinkedIn posts?"
]
elif plot_id == "reach_over_time":
insight_text += ("The 'Copertura nel Tempo' (Reach) shows how many unique LinkedIn members are seeing your posts. Expanding reach is fundamental for brand awareness. "
"If this metric is flat or declining in the provided data, explore content sharing strategies, encourage employees to share company posts, utilize relevant hashtags, and consider targeted LinkedIn advertising.")
suggestions = [
"What does the reach data suggest about our content visibility?",
"What are effective organic strategies to increase post reach on LinkedIn?",
"How do hashtags and tagging strategies impact reach on LinkedIn?"
]
elif plot_id == "impressions_over_time":
insight_text += ("'Visualizzazioni nel Tempo' (Impressions) indicates the total number of times your posts have been seen. "
"High impressions are good, but also analyze them in conjunction with engagement (check the engagement rate chart) to ensure visibility translates to interaction.")
suggestions = [
"How do current impressions compare to previous periods based on the data?",
"What's the difference between reach and impressions, and which is more important?",
"Does LinkedIn's algorithm favor certain types of content for impressions?"
]
elif plot_id == "comments_sentiment":
insight_text += ("Analyzing the 'Ripartizione Commenti per Sentiment' provides qualitative insights. The data snapshot should show the distribution. "
"A high volume of positive sentiment is ideal. Pay close attention to neutral and negative comments to understand concerns or areas for improvement.")
suggestions = [
"What does the sentiment breakdown indicate about audience perception?",
"How can I encourage more positive comments on my posts?",
"What's the best way to respond to negative comments effectively?"
]
else: # Default fallback for other plots
insight_text += (f"This chart on '{plot_label}' provides valuable data. Analyzing its trends, peaks, and troughs, as seen in the snapshot, can help you refine your LinkedIn strategy. "
f"Look for patterns and correlate them with your activities or external events to understand performance drivers.")
# Ensure exactly 3 suggestions
while len(suggestions) < 3:
suggestions.append(f"Tell me more about the trends in the {plot_label.lower()} data.")
if len(suggestions) > 3:
suggestions = suggestions[:3]
initial_chat_message = {"role": "assistant", "content": insight_text.strip()}
return initial_chat_message, suggestions