שתף דרך


הודע לסוכנים

חשוב

עליך להיות חלק מתוכנית התצוגה המקדימה של Frontier כדי לקבל גישה מוקדמת ל - Microsoft Agent 365. Frontier מחברת אתכם ישירות עם החידושים האחרונים של Microsoft בתחום הבינה המלאכותית. קבל תכונות פורצות דרך מעשיות, שתף את התובנות שלך עם צוותי מוצרים ועזור לעצב את עתיד הבינה המלאכותית. תצוגות מקדימות של Frontier כפופות לתנאי התצוגה המקדימה הקיימים של הסכמי הלקוחות שלך. כאשר תכונות אלה עדיין בפיתוח, הזמינות והיכולות שלהן עשויות להשתנות עם הזמן.'

מודול ההודעות מאפשר למפתחים לבנות סוכנים ה יכולים להגיב לאירועים ולהודעות מיישומי Microsoft 365. עם תמיכה בהודעות, סוכנים יכולים לקבל ולעבד התראות כאשר משתמשים מקיימים איתם אינטראקציה באמצעות דואר אלקטרוני, הערות מסמך או תרחישים שיתופיים אחרים.

זרימת עבודה של הודעות

פעל בהתאם לזרימת עבודה זו כדי לאפשר הודעות עבור היישום של סוכן הבינה המלאכותית:

  1. התקן חבילות הודעות.

  2. ייבוא רכיבי הודעה

    • ייבוא מחלקות התראה ומטפלי הודעות
    • ייבוא סוגי פעילויות ומזהי ערוצים
  3. רשום מטפלים בהודעות

    • שימוש בשיטות של מטפל בהודעות כדי לרשום נתיבים
    • קביעת תצורה של מטפלים עבור סוגי הודעות ספציפיים (לדוגמה: דואר אלקטרוני, Word, Excel, PowerPoint)
  4. עבד הודעות בקוד סוכן

    • הסוכן מקבל הודעות מיישומי Microsoft 365
    • טיפול בהודעות נכנסות והגיב כראוי

סוגי הודעות

ה- SDK Agents 365 תומך בסוגי ההודעות הבאים:

סוג הודעה תיאור מזהה ערוץ-משנה
דואר אלקטרוני הסוכן מקבל הודעת דואר אלקטרוני שבה הם מוזכרים או ממוענים email
Word סוכן מוזכר בהערה במסמך Word word
Excel הסוכן מוזכר בהערה במסמך Excel excel
PowerPoint סוכן מוזכר בהערה במסמך PowerPoint powerpoint
אירועי מחזור חיים הודעות מחזור חיים של סוכן (זהות משתמש נוצרה, צירוף עומס עבודה, מחיקת משתמש) לא רלוונטי

אירועי מחזור חיים של סוכן

אירועי מחזור חיים של סוכן מאפשרים לסוכן שלך להגיב לאירועי מערכת ספציפיים הקשורים לניהול זהות סוכן של משתמשים. ה- SDK תומך כעת בשלושה אירועי מחזור חיים:

סוג האירוע מזהה אירוע תיאור
זהות משתמש נוצרה agenticUserIdentityCreated מופעל בעת יצירת זהות משתמש סוכן
הטמעת עומס עבודה מעודכנת agenticUserWorkloadOnboardingUpdated מופעל כאשר מצב קליטת עומס העבודה של המשתמש הפעיל מתעדכן
משתמש נמחק agenticUserDeleted מופעל כאשר זהות משתמש סוכן נמחקת

אירועים אלה מאפשרים לסוכנים לבצע משימות אתחול, פעולות ניקוי או ניהול מצבים בתגובה לשינויי מחזור החיים של המשתמש.

הוספת הודעות לנציג שלך

בצע שלבים אלה כדי לאפשר טיפול בהודעות בסוכן הקיים שלך:

ייבוא רכיבי הודעה

הוסף פעולות ייבוא אלה לקובץ הסוכן שלך:

from microsoft_agents_a365 import AgentApplication
from microsoft_agents_a365.notifications import (
    AgentNotification,
    AgentNotificationActivity,
    NotificationTypes
)
from microsoft_agents.activity import ChannelId
from microsoft_agents.hosting.core import Authorization, TurnContext
  • AgentApplication: מחלקת בסיס לבניית יישומי Agent365; מספק פונקציונליות עיקרית עבור פעילויות ניתוב, ניהול מצב ובקשות עיבוד
  • AgentNotification: מחלקה לרישום מנגנוני טיפול בהודעות עם שיטות דקורטור. מספק on_agent_notification(), on_email(), on_word(), ודקורטורים אחרים לנוחות
  • AgentNotificationActivity: עוטף המכיל נתוני הודעות שנותחו עם מאפיינים מוקלדים כמו email_notification ו-wpx_comment_notification, אשר כוללים מטה-נתונים ספציפיים להודעות (מזהים, פרטי שיחה, הפניות למסמכים)
  • NotificationTypes: Enum של סוגי הודעות נתמכים (EMAIL_NOTIFICATION, WPX_COMMENT, AGENT_LIFECYCLE)
  • ChannelId: משמש לציון ערוצי הודעות (לדוגמה, ChannelId(channel="agents", sub_channel="*"))
  • הרשאה: הקשר הרשאה לעיבוד הודעות
  • TurnContext: השיחה הנוכחית סובבת הקשר מ- SDK של הסוכנים

רשום מטפלים בהודעות בסוכן שלך

הוסף מטפלים בהודעות לאתחול של הסוכן שלך:

class YourAgent(AgentApplication):
    def __init__(self, app):
        # Create notification handler
        agent_notification = AgentNotification(app)
        
        # Register handler for all notifications
        @agent_notification.on_agent_notification(
            ChannelId(channel="agents", sub_channel="*")
        )
        async def handle_all_notifications(context, state, notification):
            # Route based on notification type
            if notification.notification_type == NotificationTypes.EMAIL_NOTIFICATION:
                await self.handle_email_notification(context, state, notification)
            elif notification.notification_type == NotificationTypes.WPX_COMMENT:
                await self.handle_comment_notification(context, state, notification)
            else:
                await context.send_activity('Notification type not yet implemented.')

יישום מטפלים בהודעות ספציפיות

הוסף שיטות מטפל עבור כל סוג הודעה:

class YourAgent(AgentApplication):
    # ... __init__ from above ...
    
    async def handle_email_notification(self, context, state, notification):
        """Handle email notifications"""
        email = notification.email_notification
        
        if not email:
            await context.send_activity('No email data found')
            return
        
        # Process the email
        await context.send_activity(
            f'Received email notification. Email ID: {email.id}'
        )
        
        # Your email processing logic here
    
    async def handle_comment_notification(self, context, state, notification):
        """Handle document comment notifications"""
        comment = notification.wpx_comment_notification
        
        if not comment:
            await context.send_activity('No comment data found')
            return
        
        # Process the comment
        await context.send_activity(
            f'Received comment notification. Document ID: {comment.document_id}'
        )
        
        # Your comment processing logic here

מטפלים מיוחדים בהודעות

לאחר הגדרת ניתוב ההודעה הבסיסי, השתמש בשיטות מטפל מיוחדות לפקד פרטני יותר. שיטות אלה מאפשרות לך:

  • רישום מטפלים מרובים עבור אותו סוג הודעה
  • הגדרת עדיפות המטפלים עם דירוג
  • קביעת תצורה של אימות אוטומטי לכל מטפל

הערה

ברוב מקרי השימוש, תבנית המטפל הכללית מספיקה. השתמש במטפלים מיוחדים אלה כאשר אתה זקוק לניתוב מתקדם או למטפלים מרובים עבור אותו סוג הודעה.

מטפל מיוחד עבור כל ההודעות

רשום מטפלים נוספים שמעבדים את כל סוגי ההודעות:

from microsoft_agents_a365.notifications import (
    AgentNotification,
    NotificationTypes
)
from microsoft_agents.activity import ChannelId

# Create notification handler
agent_notification = AgentNotification(app)

# Register handler for all notifications
@agent_notification.on_agent_notification(
    ChannelId(channel="agents", sub_channel="*")
)
async def handle_all_notifications(context, state, notification):
    if notification.notification_type == NotificationTypes.EMAIL_NOTIFICATION:
        if notification.email_notification:
            await context.send_activity(f"Received email: {notification.email_notification.id}")
    elif notification.notification_type == NotificationTypes.WPX_COMMENT:
        if notification.wpx_comment_notification:
            await context.send_activity(f"Received comment: {notification.wpx_comment_notification.comment_id}")

מטפל מיוחד עבור הודעות דואר אלקטרוני

רשום מטפלים נוספים באופן ספציפי עבור הודעות דואר אלקטרוני:

from microsoft_agents_a365.notifications import AgentNotification
from microsoft_agents.activity import ChannelId, AgentSubChannel

# Create notification handler
agent_notification = AgentNotification(app)

# Use the convenience method for email notifications
@agent_notification.on_email()
async def handle_email(context, state, notification):
    email = notification.email_notification
    
    if not email:
        await context.send_activity('No email found')
        return
    
    # Process the email
    email_id = email.id
    conversation_id = email.conversation_id
    
    # Send response
    await context.send_activity('Thank you for your email!')

מטפלים מיוחדים עבור הערות מסמך

רשום מטפלים נוספים עבור הודעות תגובה של Word, Excel ו- PowerPoint:

from microsoft_agents_a365.notifications import AgentNotification

# Create notification handler
agent_notification = AgentNotification(app)

# Use convenience methods for document notifications
@agent_notification.on_word()
async def handle_word(context, state, notification):
    comment = notification.wpx_comment_notification
    
    if comment:
        document_id = comment.document_id
        comment_id = comment.comment_id
        await context.send_activity(f'Processing Word comment: {comment_id}')

@agent_notification.on_excel()
async def handle_excel(context, state, notification):
    comment = notification.wpx_comment_notification
    
    if comment:
        await context.send_activity('Processing Excel comment')

@agent_notification.on_powerpoint()
async def handle_powerpoint(context, state, notification):
    comment = notification.wpx_comment_notification
    
    if comment:
        await context.send_activity('Processing PowerPoint comment')

מטפלים מיוחדים לאירועי מחזור חיים

רשום מטפלים נוספים עבור אירועי מחזור חיים של סוכן כגון יצירת זהות משתמש, צירוף עומס עבודה ומחיקה של משתמשים:

from microsoft_agents_a365.notifications import AgentNotification

# Create notification handler
agent_notification = AgentNotification(app)

# Handle all lifecycle events
@agent_notification.on_agent_lifecycle_notification("*")
async def handle_lifecycle(context, state, notification):
    lifecycle_notification = notification.agent_lifecycle_notification
    if lifecycle_notification:
        event_type = lifecycle_notification.lifecycle_event_type
        
        if event_type == "agenticUserIdentityCreated":
            await context.send_activity('User identity created')
        elif event_type == "agenticUserWorkloadOnboardingUpdated":
            await context.send_activity('Workload onboarding completed')
        elif event_type == "agenticUserDeleted":
            await context.send_activity('User identity deleted')

תצורה מתקדמת

סעיף זה עוסק באפשרויות תצורה מתקדמות לכוונון המטפלים בהודעות. תצורות אלה מאפשרות לך לשלוט בסדר הביצוע של המטפל, לנהל דרישות אימות ולטב את עיבוד ההודעות עבור תרחישים מורכבים.

קדימות ודירוג של המטפל

בעת שימוש במטפלים מיוחדים מרובים, באפשרותך לציין את סדר העדיפות באמצעות ערכי דירוג. ערכי דירוג נמוך יותר מציינים עדיפות גבוהה יותר:

from microsoft_agents_a365.notifications import AgentNotification
from microsoft_agents.activity import ChannelId, AgentSubChannel

# Create notification handler
agent_notification = AgentNotification(app)

# Higher priority handler (processed first)
@agent_notification.on_email(rank=100)
async def high_priority_email(context, state, notification):
    # Handle with high priority
    pass

# Lower priority handler (processed after higher priority)
@agent_notification.on_email(rank=200)
async def low_priority_email(context, state, notification):
    # Handle with lower priority
    pass

מטפלים באימות

קבע תצורה של מנגנונים להתחברות אוטומטית עבור הודעות הדורשות אימות:

from microsoft_agents_a365.notifications import AgentNotification
from microsoft_agents.activity import ChannelId, AgentSubChannel

# Create notification handler
agent_notification = AgentNotification(app)

# Handler with automatic authentication
@agent_notification.on_email(auto_sign_in_handlers=['agentic'])
async def authenticated_email(context, state, notification):
    # Authentication is handled automatically
    pass

בדיקה וניטור

בדוק את הסוכן שלך עם הודעות

לאחר הטמעת מטפלים בהודעות, בדוק את הסוכן שלך כדי לוודא שהוא מקבל ומ מעבד סוגי הודעות שונים כהלכה. פעל בהתאם למדריך הבדיקה כדי להגדיר את הסביבה שלך, ולאחר מכן התמקד בעיקר במקטע בדוק עם פעילויות של הודעות כדי לאמת את ההודעות שלך באמצעות אימות סוכן.

ניטור טיפול בהודעות

נטר את הטיפול בהודעות של הסוכן שלך על-ידי הוספת יכולות של יכולת התבוננות. עקוב אחר עיבוד הודעות, זמני תגובה ותעריפי שגיאות כדי להבין את ביצועי הסוכן. קבל מידע נוסף על יישום מעקב וניטור