Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Activity class
- Package:
- @microsoft/agents-activity
Represents an activity in a conversation.
Constructors
| Activity(string) | Creates a new Activity instance. |
Properties
| action | The action associated with the activity. |
| attachmentLayout | The attachment layout of the activity. |
| attachments | The attachments of the activity. |
| callerId | The caller ID of the activity. |
| channelData | The channel-specific data for the activity. |
| channelId | Return the combined channel:subChannel value like agent:email |
| channelIdChannel | Returns the primary channel ID for the activity. |
| channelIdSubChannel | Returns the sub-channel ID for the activity. |
| code | The end-of-conversation code for the activity. |
| conversation | The conversation account associated with the activity. |
| deliveryMode | The delivery mode of the activity. |
| entities | The entities associated with the activity. |
| expiration | The expiration time of the activity. |
| from | The account of the sender of the activity. |
| historyDisclosed | Indicates whether the history is disclosed. |
| id | The unique identifier of the activity. |
| importance | The importance of the activity. |
| inputHint | The input hint for the activity. |
| label | The label for the activity. |
| listenFor | The list of keywords to listen for in the activity. |
| locale | The locale of the activity. |
| localTimestamp | The local timestamp of the activity. |
| localTimezone | The local timezone of the activity. |
| membersAdded | The members added to the conversation. |
| membersRemoved | The members removed from the conversation. |
| name | The name of the activity event. |
| rawExpiration | The raw expiration time of the activity. |
| rawLocalTimestamp | The raw local timestamp of the activity. |
| rawTimestamp | The raw timestamp of the activity. |
| reactionsAdded | The reactions added to the activity. |
| reactionsRemoved | The reactions removed from the activity. |
| recipient | The recipient of the activity. |
| relatesTo | The conversation reference for the activity. |
| replyToId | The ID of the activity being replied to. |
| semanticAction | The semantic action associated with the activity. |
| serviceUrl | The service URL of the activity. |
| speak | The speech text of the activity. |
| suggestedActions | The suggested actions for the activity. |
| summary | The summary of the activity. |
| text | The text content of the activity. |
| textFormat | The text format of the activity. |
| textHighlights | The text highlights in the activity. |
| timestamp | The timestamp of the activity. |
| topicName | The topic name of the activity. |
| type | The type of the activity. |
| value | The value associated with the activity. |
| valueType | The value type of the activity. |
Methods
| applyConversationReference(ConversationReference, boolean) | Applies a conversation reference to the activity. |
| clone() | |
| fromJson(string) | Creates an Activity instance from a JSON string. |
| fromObject(object) | Creates an Activity instance from an object. |
| getAgenticInstanceId() | Gets the agent instance ID from the context if its agentic |
| getAgenticTenantId() | Retrieves the tenant ID associated with the agentic recipient of the activity, if available; otherwise, returns the tenant ID from the conversation. |
| getAgenticUser() | Gets the agentic user (UPN) from the context if it's an agentic request. |
| getContinuationActivity(ConversationReference) | Creates a continuation activity from a conversation reference. |
| getConversationReference() | Gets the conversation reference for the activity. |
| getMentions(Activity) | Gets the mentions in the activity. |
| getReplyConversationReference(string) | Gets the conversation reference for a reply. |
| isAgenticRequest() | Does this activity represent an agentic request? |
| normalizeMentions(boolean) | Normalizes mentions in the activity by removing mention tags and optionally removing recipient mention. |
| parseChannelId(string) | Given a composite channelId like agent:email, return the channel and subChannel. |
| removeMentionText(string) | Removes the mention text for a given ID. |
| removeRecipientMention() | Removes the recipient mention from the activity text. |
| toJsonString((this: any, key: string, value: any) => any, string | number) | Converts the activity to a JSON string. |
Constructor Details
Activity(string)
Creates a new Activity instance.
new Activity(t: string)
Parameters
- t
-
string
The type of the activity.
Property Details
action
The action associated with the activity.
action?: string
Property Value
string
attachmentLayout
The attachment layout of the activity.
attachmentLayout?: string
Property Value
string
attachments
callerId
The caller ID of the activity.
callerId?: string
Property Value
string
channelData
The channel-specific data for the activity.
channelData?: any
Property Value
any
channelId
Return the combined channel:subChannel value like agent:email
undefined | string channelId
Property Value
undefined | string
channelIdChannel
Returns the primary channel ID for the activity.
undefined | string channelIdChannel
Property Value
undefined | string
channelIdSubChannel
Returns the sub-channel ID for the activity.
unknown channelIdSubChannel
Property Value
unknown
code
The end-of-conversation code for the activity.
code?: string
Property Value
string
conversation
The conversation account associated with the activity.
conversation?: ConversationAccount
Property Value
deliveryMode
The delivery mode of the activity.
deliveryMode?: string
Property Value
string
entities
expiration
The expiration time of the activity.
expiration?: string | Date
Property Value
string | Date
from
historyDisclosed
Indicates whether the history is disclosed.
historyDisclosed?: boolean
Property Value
boolean
id
The unique identifier of the activity.
id?: string
Property Value
string
importance
The importance of the activity.
importance?: string
Property Value
string
inputHint
The input hint for the activity.
inputHint?: string
Property Value
string
label
The label for the activity.
label?: string
Property Value
string
listenFor
The list of keywords to listen for in the activity.
listenFor?: string[]
Property Value
string[]
locale
The locale of the activity.
locale?: string
Property Value
string
localTimestamp
The local timestamp of the activity.
localTimestamp?: string | Date
Property Value
string | Date
localTimezone
The local timezone of the activity.
localTimezone?: string
Property Value
string
membersAdded
The members added to the conversation.
membersAdded?: ChannelAccount[]
Property Value
membersRemoved
The members removed from the conversation.
membersRemoved?: ChannelAccount[]
Property Value
name
The name of the activity event.
name?: string
Property Value
string
rawExpiration
The raw expiration time of the activity.
rawExpiration?: string
Property Value
string
rawLocalTimestamp
The raw local timestamp of the activity.
rawLocalTimestamp?: string
Property Value
string
rawTimestamp
The raw timestamp of the activity.
rawTimestamp?: string
Property Value
string
reactionsAdded
The reactions added to the activity.
reactionsAdded?: MessageReaction[]
Property Value
reactionsRemoved
The reactions removed from the activity.
reactionsRemoved?: MessageReaction[]
Property Value
recipient
relatesTo
The conversation reference for the activity.
relatesTo?: ConversationReference
Property Value
replyToId
The ID of the activity being replied to.
replyToId?: string
Property Value
string
semanticAction
The semantic action associated with the activity.
semanticAction?: SemanticAction
Property Value
serviceUrl
The service URL of the activity.
serviceUrl?: string
Property Value
string
speak
The speech text of the activity.
speak?: string
Property Value
string
suggestedActions
The suggested actions for the activity.
suggestedActions?: SuggestedActions
Property Value
summary
The summary of the activity.
summary?: string
Property Value
string
text
The text content of the activity.
text?: string
Property Value
string
textFormat
The text format of the activity.
textFormat?: string
Property Value
string
textHighlights
The text highlights in the activity.
textHighlights?: TextHighlight[]
Property Value
timestamp
The timestamp of the activity.
timestamp?: string | Date
Property Value
string | Date
topicName
The topic name of the activity.
topicName?: string
Property Value
string
type
The type of the activity.
type: string
Property Value
string
value
The value associated with the activity.
value?: unknown
Property Value
unknown
valueType
The value type of the activity.
valueType?: string
Property Value
string
Method Details
applyConversationReference(ConversationReference, boolean)
Applies a conversation reference to the activity.
function applyConversationReference(reference: ConversationReference, isIncoming?: boolean): Activity
Parameters
- reference
- ConversationReference
The conversation reference.
- isIncoming
-
boolean
Whether the activity is incoming.
Returns
The updated activity.
clone()
fromJson(string)
Creates an Activity instance from a JSON string.
static function fromJson(json: string): Activity
Parameters
- json
-
string
The JSON string representing the activity.
Returns
The created Activity instance.
fromObject(object)
Creates an Activity instance from an object.
static function fromObject(o: object): Activity
Parameters
- o
-
object
The object representing the activity.
Returns
The created Activity instance.
getAgenticInstanceId()
Gets the agent instance ID from the context if its agentic
function getAgenticInstanceId(): undefined | string
Returns
undefined | string
agent instance id as string
getAgenticTenantId()
Retrieves the tenant ID associated with the agentic recipient of the activity, if available; otherwise, returns the tenant ID from the conversation.
function getAgenticTenantId(): undefined | string
Returns
undefined | string
The tenant ID of the agentic recipient if present; otherwise, the tenant ID from the conversation. Returns undefined if neither is available.
getAgenticUser()
Gets the agentic user (UPN) from the context if it's an agentic request.
function getAgenticUser(): undefined | string
Returns
undefined | string
getContinuationActivity(ConversationReference)
Creates a continuation activity from a conversation reference.
static function getContinuationActivity(reference: ConversationReference): Activity
Parameters
- reference
- ConversationReference
The conversation reference.
Returns
The created continuation activity.
getConversationReference()
Gets the conversation reference for the activity.
function getConversationReference(): ConversationReference
Returns
The conversation reference.
getMentions(Activity)
getReplyConversationReference(string)
Gets the conversation reference for a reply.
function getReplyConversationReference(replyId: string): ConversationReference
Parameters
- replyId
-
string
The ID of the reply.
Returns
The conversation reference.
isAgenticRequest()
Does this activity represent an agentic request?
function isAgenticRequest(): boolean
Returns
boolean
True if agentic
normalizeMentions(boolean)
Normalizes mentions in the activity by removing mention tags and optionally removing recipient mention.
function normalizeMentions(removeMention?: boolean)
Parameters
- removeMention
-
boolean
Whether to remove the recipient mention from the activity.
parseChannelId(string)
Given a composite channelId like agent:email, return the channel and subChannel.
static function parseChannelId(value: string): [undefined | string, undefined | string]
Parameters
- value
-
string
Returns
[undefined | string, undefined | string]
[channel, subChannel]
removeMentionText(string)
Removes the mention text for a given ID.
function removeMentionText(id: string): string
Parameters
- id
-
string
The ID of the mention to remove.
Returns
string
The updated text.
removeRecipientMention()
Removes the recipient mention from the activity text.
function removeRecipientMention(): string
Returns
string
The updated text.
toJsonString((this: any, key: string, value: any) => any, string | number)
Converts the activity to a JSON string.
function toJsonString(replacer?: (this: any, key: string, value: any) => any, space?: string | number): string
Parameters
- replacer
-
(this: any, key: string, value: any) => any
A function that transforms the results.
- space
-
string | number
Adds indentation, white space, and line break characters to the return-value JSON text.
Returns
string
The JSON string representation of the activity.
