इसके माध्यम से साझा किया गया


एजेंटों को सूचित करें

महत्त्वपूर्ण

Microsoft Agent 365 तक शीघ्र पहुँच प्राप्त करने के लिए आपको Frontier पूर्वावलोकन प्रोग्राम का भाग बनने की आवश्यकता है. फ्रंटियर आपको सीधे Microsoft के नवीनतम AI नवाचारों से जोड़ता है। फ्रंटियर पूर्वावलोकन आपके ग्राहक समझौतों की मौजूदा पूर्वावलोकन शर्तों के अधीन हैं। चूंकि ये सुविधाएँ अभी भी विकास में हैं, इसलिए उनकी उपलब्धता और क्षमताएं समय के साथ बदल सकती हैं।

अधिसूचना मॉड्यूल डेवलपर्स को ऐसे एजेंट बनाने में सक्षम बनाता है जो Microsoft 365 अनुप्रयोगों की घटनाओं और सूचनाओं का जवाब दे सकते हैं। सूचनाओं के समर्थन के साथ, एजेंट अलर्ट प्राप्त कर सकते हैं और संसाधित कर सकते हैं जब उपयोगकर्ता ईमेल, दस्तावेज़ टिप्पणियों या अन्य सहयोगी परिदृश्यों के माध्यम से उनके साथ बातचीत करते हैं।

सूचनाएं वर्कफ़्लो

अपने एआई एजेंट एप्लिकेशन के लिए सूचनाएं सक्षम करने के लिए इस वर्कफ़्लो का पालन करें:

  1. अधिसूचना पैकेज स्थापित करें।

  2. सूचना घटकों को आयात करें

    • सूचना कक्षाएं और हैंडलर आयात करें
    • गतिविधि प्रकार और चैनल पहचानकर्ता आयात करें
  3. अधिसूचना हैंडलर पंजीकृत करें

    • मार्गों को पंजीकृत करने के लिए सूचना हैंडलर विधियों का उपयोग करें
    • विशिष्ट सूचना प्रकारों के लिए हैंडलर कॉन्फ़िगर करें (उदाहरण के लिए: ईमेल, Word, Excel, PowerPoint)
  4. एजेंट कोड में प्रक्रिया सूचनाएं

    • एजेंट Microsoft 365 अनुप्रयोगों से सूचनाएं प्राप्त करता है
    • आने वाली सूचनाओं को संभालें और उचित रूप से प्रतिक्रिया दें

सूचना प्रकार

एजेंट 365 SDK निम्न सूचना प्रकारों का समर्थन करता है:

सूचना प्रकार विवरण उप-चैनल आईडी
email: "", एजेंट को एक ईमेल प्राप्त होता है जहां उनका उल्लेख या पता किया जाता है email
शब्द Word दस्तावेज़ में एक टिप्पणी में एजेंट का उल्लेख किया गया है word
Excel एजेंट का उल्लेख एक्सेल दस्तावेज़ में एक टिप्पणी में किया गया है excel
पावरपॉइंट एजेंट का उल्लेख PowerPoint दस्तावेज़ में एक टिप्पणी में किया गया है powerpoint
जीवनचक्र घटनाएँ एजेंट जीवनचक्र सूचनाएं (उपयोगकर्ता पहचान बनाई गई, कार्यभार ऑनबोर्डिंग, उपयोगकर्ता हटा दिया गया) N/A

एजेंट जीवनचक्र की घटनाएं

एजेंट जीवनचक्र ईवेंट आपके एजेंट को एजेंट उपयोगकर्ता पहचान प्रबंधन से संबंधित विशिष्ट सिस्टम घटनाओं का जवाब देने में सक्षम बनाते हैं। SDK टूल फ़िलहाल तीन जीवनचक्र इवेंट का समर्थन करता है:

ईवेंट का प्रकार इवेंट ID विवरण
उपयोगकर्ता पहचान बनाई गई agenticUserIdentityCreated ट्रिगर तब होता है जब कोई एजेंट उपयोगकर्ता पहचान बनाई जाती है
कार्यभार ऑनबोर्डिंग अपडेट किया गया agenticUserWorkloadOnboardingUpdated ट्रिगर तब होता है जब किसी एजेंट उपयोगकर्ता का कार्यभार ऑनबोर्डिंग स्थिति अपडेट की जाती है
उपयोगकर्ता हटा दिया गया agenticUserDeleted ट्रिगर तब होता है जब कोई agentic उपयोगकर्ता पहचान हटा दी जाती है

ये ईवेंट एजेंट को उपयोगकर्ता जीवनचक्र परिवर्तनों के प्रत्युत्तर में प्रारंभ कार्य, क्लीनअप ऑपरेशन या स्थिति प्रबंधन करने की अनुमति देते हैं।

अपने एजेंट को सूचनाएं जोड़ें

अपने मौजूदा एजेंट में सूचना हैंडलिंग सक्षम करने के लिए इन चरणों का पालन करें:

सूचना घटकों को आयात करें

इन आयातों को अपनी एजेंट फ़ाइल में जोड़ें:

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 अधिसूचना-विशिष्ट मेटाडेटा (आईडी, वार्तालाप विवरण, दस्तावेज़ संदर्भ) शामिल होते हैं
  • अधिसूचना प्रकार: समर्थित अधिसूचना प्रकारों का एनम (,EMAIL_NOTIFICATIONWPX_COMMENT , AGENT_LIFECYCLE)
  • ChannelId: अधिसूचना चैनल निर्दिष्ट करने के लिए उपयोग किया जाता है (उदाहरण के लिए, ChannelId(channel="agents", sub_channel="*"))
  • प्राधिकरण: सूचनाओं को संसाधित करने के लिए प्राधिकरण संदर्भ
  • टर्नकॉन्टेक्स्ट: वर्तमान वार्तालाप एजेंट एसडीके से संदर्भ बदल देता है

अपने एजेंट में अधिसूचना संचालकों को पंजीकृत करें

अपने एजेंट के आरंभीकरण में सूचना हैंडलर जोड़ें:

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

परीक्षण और निगरानी करें

सूचनाओं के साथ अपने एजेंट का परीक्षण करें

अधिसूचना हैंडलर लागू करने के बाद, यह सुनिश्चित करने के लिए अपने एजेंट का परीक्षण करें कि यह विभिन्न अधिसूचना प्रकारों को सही ढंग से प्राप्त करता है और संसाधित करता है। अपने परिवेश को सेट करने के लिए परीक्षण मार्गदर्शिका का पालन करें, फिर मुख्य रूप से एजेंट प्रमाणीकरण का उपयोग करके अपनी सूचनाओं को सत्यापित करने के लिए अधिसूचना गतिविधियों के साथ परीक्षण अनुभाग पर ध्यान केंद्रित करें

अधिसूचना प्रबंधन की निगरानी करें

अवलोकन क्षमताओं को जोड़कर अपने एजेंट की अधिसूचना हैंडलिंग की निगरानी करें। एजेंट के प्रदर्शन को समझने के लिए अधिसूचना प्रसंस्करण, प्रतिक्रिया समय और त्रुटि दरों को ट्रैक करें। ट्रेसिंग और मॉनिटरिंग को लागू करने के बारे में अधिक जानें