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

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 @@ -24,7 +24,8 @@

class SlackAdapter(BotAdapter, ABC):
"""
BotAdapter that can handle incoming Slack events. Incoming Slack events are deserialized to an Activity that is dispatched through the middleware and bot pipeline.
BotAdapter that can handle incoming Slack events. Incoming Slack events are deserialized to an Activity that is
dispatched through the middleware and bot pipeline.
"""

def __init__(
Expand Down Expand Up @@ -115,7 +116,8 @@ async def delete_activity(

:param context: A TurnContext representing the current incoming message and environment.
:type context: :class:`botbuilder.core.TurnContext`
:param reference: An object in the form "{activityId: `id of message to delete`,conversation: { id: `id of Slack channel`}}".
:param reference: An object in the form "{activityId: `id of message to delete`,conversation: { id: `id of Slack
channel`}}".
:type reference: :class:`botbuilder.schema.ConversationReference`
"""

Expand All @@ -142,10 +144,11 @@ async def continue_conversation(
):
"""
Send a proactive message to a conversation.

.. remarks::

Most channels require a user to initiate a conversation with a bot before the bot can send activities to the user.

Most channels require a user to initiate a conversation with a bot before the bot can send activities to the
user.

:param reference: A reference to the conversation to continue.
:type reference: :class:`botbuilder.schema.ConversationReference`
Expand Down Expand Up @@ -188,7 +191,7 @@ async def process(self, req: Request, logic: Callable) -> Response:
:type req: :class:`aiohttp.web_request.Request`
:param logic: The method to call for the resulting bot turn.
:type logic: :class:`tying.Callable`
:return: The aiohttp Response.
:return: The aiohttp Response.
:rtype: :class:`aiohttp.web_response.Response`
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ class SlackHelper:
def activity_to_slack(activity: Activity) -> SlackMessage:
"""
Formats a BotBuilder Activity into an outgoing Slack message.

:param activity: A BotBuilder Activity object.
:type activity: :class:`botbuilder.schema.Activity`
:return: A Slack message object with {text, attachments, channel, thread ts} and any fields found in activity.channelData.
:return: A Slack message object with {text, attachments, channel, thread ts} and any fields found in
activity.channelData.
:rtype: :class:`SlackMessage`
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(
):
"""
Initializes a new instance of SlackAdapterOptions.

:param slack_verification_token: A token for validating the origin of incoming webhooks.
:type slack_verification_token: str
:param slack_bot_token: A token for a bot to work on a single workspace.
Expand All @@ -34,7 +34,7 @@ def __init__(
async def get_token_for_team(self, team_id: str) -> str:
"""
Receives a Slack team ID and returns the bot token associated with that team. Required for multi-team apps.

:param team_id: The team ID.
:type team_id: str
:raises: :func:`NotImplementedError`
Expand All @@ -43,8 +43,9 @@ async def get_token_for_team(self, team_id: str) -> str:

async def get_bot_user_by_team(self, team_id: str) -> str:
"""
A method that receives a Slack team ID and returns the bot user ID associated with that team. Required for multi-team apps.

A method that receives a Slack team ID and returns the bot user ID associated with that team. Required for
multi-team apps.

:param team_id: The team ID.
:type team_id: str
:raises: :func:`NotImplementedError`
Expand Down
11 changes: 7 additions & 4 deletions libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def top_intent(
:type results: :class:`botbuilder.core.RecognizerResult`
:param default_intent: Intent name to return should a top intent be found, defaults to None.
:type default_intent: str, optional
:param min_score: Minimum score needed for an intent to be considered as a top intent. If all intents in the set are below this threshold then the `defaultIntent` is returned, defaults to 0.0.
:param min_score: Minimum score needed for an intent to be considered as a top intent. If all intents in the set
are below this threshold then the `defaultIntent` is returned, defaults to 0.0.
:type min_score: float, optional
:raises: TypeError
:return: The top scoring intent name.
Expand Down Expand Up @@ -186,9 +187,11 @@ def fill_luis_event_properties(
:type recognizer_result: :class:`botbuilder.core.RecognizerResult`
:param turn_context: Context object containing information for a single turn of conversation with a user.
:type turn_context: :class:`botbuilder.core.TurnContext`
:param telemetry_properties: Additional properties to be logged to telemetry with the LuisResult event, defaults to None.
:param telemetry_properties: Additional properties to be logged to telemetry with the LuisResult event, defaults
to None.
:type telemetry_properties: :class:`typing.Dict[str, str]`, optional
:return: A dictionary sent as "Properties" to :func:`botbuilder.core.BotTelemetryClient.track_event` for the BotMessageSend event.
:return: A dictionary sent as "Properties" to :func:`botbuilder.core.BotTelemetryClient.track_event` for the
BotMessageSend event.
:rtype: `typing.Dict[str, str]`
"""

Expand Down Expand Up @@ -269,7 +272,7 @@ async def _recognize_internal(

if not utterance or utterance.isspace():
recognizer_result = RecognizerResult(
text=utterance
text=utterance, intents={"": IntentScore(score=1.0)}, entities={}
)
else:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def track_pageview(
) -> None:
"""
Send information about the page viewed in the application (a web page for instance).

:param name: the name of the page that was viewed.
:type name: str
:param url: the URL of the page that was viewed.
Expand All @@ -77,7 +77,8 @@ def track_pageview(
:duration: int
:param properties: the set of custom properties the client wants attached to this data item. (defaults to: None)
:type properties: :class:`typing.Dict[str, object]`
:param measurements: the set of custom measurements the client wants to attach to this data item. (defaults to: None)
:param measurements: the set of custom measurements the client wants to attach to this data item. (defaults to:
None)
:type measurements: :class:`typing.Dict[str, object]`
"""
self._client.track_pageview(name, url, duration, properties, measurements)
Expand All @@ -92,13 +93,14 @@ def track_exception(
) -> None:
"""
Send information about a single exception that occurred in the application.

:param exception_type: the type of the exception that was thrown.
:param value: the exception that the client wants to send.
:param trace: the traceback information as returned by :func:`sys.exc_info`.
:param properties: the set of custom properties the client wants attached to this data item. (defaults to: None)
:type properties: :class:`typing.Dict[str, object]`
:param measurements: the set of custom measurements the client wants to attach to this data item. (defaults to: None)
:param measurements: the set of custom measurements the client wants to attach to this data item. (defaults to:
None)
:type measurements: :class:`typing.Dict[str, object]`
"""
self._client.track_exception(
Expand All @@ -113,12 +115,13 @@ def track_event(
) -> None:
"""
Send information about a single event that has occurred in the context of the application.

:param name: the data to associate to this event.
:type name: str
:param properties: the set of custom properties the client wants attached to this data item. (defaults to: None)
:type properties: :class:`typing.Dict[str, object]`
:param measurements: the set of custom measurements the client wants to attach to this data item. (defaults to: None)
:param measurements: the set of custom measurements the client wants to attach to this data item. (defaults to:
None)
:type measurements: :class:`typing.Dict[str, object]`
"""
self._client.track_event(name, properties=properties, measurements=measurements)
Expand All @@ -136,23 +139,26 @@ def track_metric(
) -> NotImplemented:
"""
Send information about a single metric data point that was captured for the application.

:param name: The name of the metric that was captured.
:type name: str
:param value: The value of the metric that was captured.
:type value: float
:param tel_type: The type of the metric. (defaults to: TelemetryDataPointType.aggregation`)
:param count: the number of metrics that were aggregated into this data point. (defaults to: None)
:type count: int
:param min_val: the minimum of all metrics collected that were aggregated into this data point. (defaults to: None)
:param min_val: the minimum of all metrics collected that were aggregated into this data point. (defaults to:
None)
:type min_val: float
:param max_val: the maximum of all metrics collected that were aggregated into this data point. (defaults to: None)
:param max_val: the maximum of all metrics collected that were aggregated into this data point. (defaults to:
None)
:type max_val: float
:param std_dev: the standard deviation of all metrics collected that were aggregated into this data point. (defaults to: None)
:param std_dev: the standard deviation of all metrics collected that were aggregated into this data point.
(defaults to: None)
:type std_dev: float
:param properties: the set of custom properties the client wants attached to this data item. (defaults to: None)
:type properties: :class:`typing.Dict[str, object]`
"""
"""
self._client.track_metric(
name, value, tel_type, count, min_val, max_val, std_dev, properties
)
Expand All @@ -162,7 +168,7 @@ def track_trace(
):
"""
Sends a single trace statement.

:param name: the trace statement.
:type name: str
:param properties: the set of custom properties the client wants attached to this data item. (defaults to: None)
Expand All @@ -186,14 +192,15 @@ def track_request(
):
"""
Sends a single request that was captured for the application.

:param name: The name for this request. All requests with the same name will be grouped together.
:type name: str
:param url: The actual URL for this request (to show in individual request instances).
:type url: str
:param success: True if the request ended in success, False otherwise.
:type success: bool
:param start_time: the start time of the request. The value should look the same as the one returned by :func:`datetime.isoformat`. (defaults to: None)
:param start_time: the start time of the request. The value should look the same as the one returned by
:func:`datetime.isoformat`. (defaults to: None)
:type start_time: str
:param duration: the number of milliseconds that this request lasted. (defaults to: None)
:type duration: int
Expand All @@ -203,7 +210,8 @@ def track_request(
:type http_method: str
:param properties: the set of custom properties the client wants attached to this data item. (defaults to: None)
:type properties: :class:`typing.Dict[str, object]`
:param measurements: the set of custom measurements the client wants to attach to this data item. (defaults to: None)
:param measurements: the set of custom measurements the client wants to attach to this data item. (defaults to:
None)
:type measurements: :class:`typing.Dict[str, object]`
:param request_id: the id for this request. If None, a new uuid will be generated. (defaults to: None)
:type request_id: str
Expand Down Expand Up @@ -236,28 +244,35 @@ def track_dependency(
):
"""
Sends a single dependency telemetry that was captured for the application.

:param name: the name of the command initiated with this dependency call. Low cardinality value.
Examples are stored procedure name and URL path template.
:type name: str
:param data: the command initiated by this dependency call. Examples are SQL statement and HTTP URL with all query parameters.
:param data: the command initiated by this dependency call. Examples are SQL statement and HTTP URL with all
query parameters.
:type data: str
:param type_name: the dependency type name. Low cardinality value for logical grouping of dependencies and interpretation of other fields like commandName and resultCode. Examples are SQL, Azure table, and HTTP. (default to: None)
:param type_name: the dependency type name. Low cardinality value for logical grouping of dependencies and
interpretation of other fields like commandName and resultCode. Examples are SQL, Azure table, and HTTP.
(default to: None)
:type type_name: str
:param target: the target site of a dependency call. Examples are server name, host address. (default to: None)
:type target: str
:param duration: the number of milliseconds that this dependency call lasted. (defaults to: None)
:type duration: int
:param success: true if the dependency call ended in success, false otherwise. (defaults to: None)
:type success: bool
:param result_code: the result code of a dependency call. Examples are SQL error code and HTTP status code. (defaults to: None)
:param result_code: the result code of a dependency call. Examples are SQL error code and HTTP status code.
(defaults to: None)
:type result_code: str
:param properties: the set of custom properties the client wants attached to this data item. (defaults to: None)
:param properties: the set of custom properties the client wants attached to this data item.
(defaults to: None)
:type properties: :class:`typing.Dict[str, object]`
:param measurements: the set of custom measurements the client wants to attach to this data item. (defaults to: None)
:param measurements: the set of custom measurements the client wants to attach to this data item.
(defaults to: None)
:type measurements: :class:`typing.Dict[str, object]`
:param dependency_id: the id for this dependency call. If None, a new uuid will be generated. (defaults to: None)
:type dependency_id: str
:param dependency_id: the id for this dependency call. If None, a new uuid will be generated.
(defaults to: None)
:type dependency_id: str
"""
self._client.track_dependency(
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@


def retrieve_bot_body():
"""
"""
Retrieve the POST body text from temporary cache.

The POST body corresponds to the thread ID and must reside in the cache just for the lifetime of the request.
"""

Expand All @@ -25,9 +25,9 @@ class BotTelemetryMiddleware:
Save off the POST body to later populate bot-specific properties to add to Application Insights.

Example activating MIDDLEWARE in Django settings:

.. code-block:: python

MIDDLEWARE = [
# Ideally add somewhere near top
'botbuilder.applicationinsights.django.BotTelemetryMiddleware',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@


def retrieve_aiohttp_body():
"""
"""
Retrieve the POST body text from temporary cache.

The POST body corresponds with the thread id and should resides in
cache just for lifetime of request.
"""
Expand Down