Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from collections.abc import Awaitable, Callable, Iterable
from typing import Any, TypeVar

from microsoft_agents.activity import ChannelId
from microsoft_agents.activity import Activity, ChannelId
from microsoft_agents.hosting.core import TurnContext
from microsoft_agents.hosting.core.app.state import TurnState
from .models.agent_notification_activity import AgentNotificationActivity, NotificationTypes
from .models.agent_subchannel import AgentSubChannel
from .models.agent_lifecycle_event import AgentLifecycleEvent
from .models.email_response import EmailResponse

TContext = TypeVar("TContext", bound=TurnContext)
TState = TypeVar("TState", bound=TurnState)
Expand Down Expand Up @@ -181,3 +182,23 @@ def _normalize_lifecycleevent(value: str | AgentLifecycleEvent | None) -> str:
return ""
resolved = value.value if isinstance(value, AgentLifecycleEvent) else str(value)
return resolved.lower().strip()

@staticmethod
def create_email_response_activity(
activity: Activity, email_response_html_body: str
) -> Activity:
Comment thread
joratz marked this conversation as resolved.
Outdated
"""Create a reply Activity with an EmailResponse entity.

Args:
activity: The source activity to create a reply from.
email_response_html_body: The HTML content for the email response.

Returns:
A reply Activity with the EmailResponse entity attached.
"""
working_activity = activity.create_reply()
email_response = EmailResponse(html_body=email_response_html_body)
if working_activity.entities is None:
working_activity.entities = []
working_activity.entities.append(email_response)
return working_activity
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
from typing import Literal
Comment thread
joratz marked this conversation as resolved.
Comment thread
joratz marked this conversation as resolved.
from microsoft_agents.activity.activity import Activity
from microsoft_agents.activity.entity import Entity
Comment thread
joratz marked this conversation as resolved.


class EmailResponse(Entity):
type: Literal["emailResponse"] = "emailResponse"
html_body: str = ""

@staticmethod
def create_email_response_activity(email_response_html_body: str) -> Activity:
Comment thread
joratz marked this conversation as resolved.
"""Create a new Activity with an EmailResponse entity.

Args:
email_response_html_body: The HTML content for the email response.

Returns:
A new Activity instance with type='message' and the EmailResponse entity attached.
"""
working_activity = Activity(type="message")
email_response = EmailResponse(html_body=email_response_html_body)
if working_activity.entities is None:
working_activity.entities = []
working_activity.entities.append(email_response)
return working_activity
Loading