Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.14.6 CloudAdapter fails to send Typing Activity in Teams #2040

Closed
joshualwhite opened this issue Nov 21, 2023 · 4 comments · Fixed by #2057
Closed

4.14.6 CloudAdapter fails to send Typing Activity in Teams #2040

joshualwhite opened this issue Nov 21, 2023 · 4 comments · Fixed by #2057
Assignees
Labels
bug Indicates an unexpected problem or an unintended behavior.

Comments

@joshualwhite
Copy link

Version

botbuilder-core 4.14.6
botbuilder-integration-aiohttp 4.14.6
botbuilder-schema 4.14.6

Describe the bug

I am unable to send typing indicators with the ShowTypingMiddleware middleware, turn_context.send_activity, and
turn_context.send_activities.

To Reproduce

Create a bot

cfg = DefaultConfig()
adapter = CloudAdapter(ConfigurationBotFrameworkAuthentication(cfg))
bot = Bot()

define on_message_activity
From documentation

    async def on_message_activity(self, turn_context: TurnContext):  # pylint: disable=unused-argument
        if turn_context.activity.text == "wait":
            return await turn_context.send_activities([
                Activity(
                    type=ActivityTypes.typing
                ),
                Activity(
                    type="delay",
                    value=3000
                ),
                Activity(
                    type=ActivityTypes.message,
                    text="Finished Typing"
                )
            ])
        else:
            return await turn_context.send_activity(
                f"You said {turn_context.activity.text}.  Say 'wait' to watch me type."
            )

Publish in azure, set up MS Teams channel.

send 'wait' via Microsoft Teams

stacktrace:

Traceback (most recent call last):
  File "path-to-virtual-env/lib/python3.10/site-packages/botbuilder/core/bot_adapter.py", line 174, in run_pipeline
    return await self._middleware.receive_activity_with_status(
  File "path-to-virtual-env/lib/python3.10/site-packages/botbuilder/core/middleware_set.py", line 69, in receive_activity_with_status
    return await self.receive_activity_internal(context, callback)
  File "path-to-virtual-env/lib/python3.10/site-packages/botbuilder/core/middleware_set.py", line 79, in receive_activity_internal
    return await callback(context)
  File "path-to-virtual-env/lib/python3.10/site-packages/botbuilder/core/activity_handler.py", line 70, in on_turn
    await self.on_message_activity(turn_context)
  File "/home/josh/ctrlstack/babelfish/askbot/microsoft-teams/src/bot.py", line 78, in on_message_activity
    return await turn_context.send_activities([
  File "path-to-virtual-env/lib/python3.10/site-packages/botbuilder/core/turn_context.py", line 225, in send_activities
    return await self._emit(self._on_send_activities, output, logic())
  File "path-to-virtual-env/lib/python3.10/site-packages/botbuilder/core/turn_context.py", line 303, in _emit
    return await logic
  File "path-to-virtual-env/lib/python3.10/site-packages/botbuilder/core/turn_context.py", line 220, in logic
    responses = await self.adapter.send_activities(self, output)
  File "path-to-virtual-env/lib/python3.10/site-packages/botbuilder/core/cloud_adapter_base.py", line 103, in send_activities
    response = response or ResourceResponse(activity.id or "")

Expected behavior

the typing indicator for 3 seconds.

@joshualwhite joshualwhite added bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team. labels Nov 21, 2023
@c2js
Copy link

c2js commented Nov 22, 2023

I encounter similar bug, it get trigger when deployed the bot to teams, run in emulator is fine.
the problem is position "*" in __init__function (class ResourceResponse(Model): in _models_py3.py , make it the id must be call as keyword, but the caller in cloud_adapter_base.py:103 doesn't specific the keyword for the parameter. response = response or ResourceResponse(activity.id or "")

class ResourceResponse(Model):
    """A response containing a resource ID.

    :param id: Id of the resource
    :type id: str
    """

    _attribute_map = {"id": {"key": "id", "type": "str"}}

    def __init__(self, *, id: str = None, **kwargs) -> None:
        super(ResourceResponse, self).__init__(**kwargs)
        self.id = id

cloud_adapter_base.py

response = response or ResourceResponse(activity.id or "")

Suggest to update all callers include cloud_adapter_base.py to include the "id="
eg:

response = response or ResourceResponse(id=activity.id or "")

@LGDoor
Copy link

LGDoor commented Nov 23, 2023

Same issue encountered.

@tracyboehrer tracyboehrer changed the title 4.14.6 CloudAdapter fails to send Typing Activity 4.14.6 CloudAdapter fails to send Typing Activity in Teams Dec 5, 2023
@tracyboehrer tracyboehrer removed the needs-triage The issue has just been created and it has not been reviewed by the team. label Dec 6, 2023
@aacebo
Copy link
Collaborator

aacebo commented Dec 14, 2023

I encounter similar bug, it get trigger when deployed the bot to teams, run in emulator is fine. the problem is position "*" in __init__function (class ResourceResponse(Model): in _models_py3.py , make it the id must be call as keyword, but the caller in cloud_adapter_base.py:103 doesn't specific the keyword for the parameter. response = response or ResourceResponse(activity.id or "")

class ResourceResponse(Model):
    """A response containing a resource ID.

    :param id: Id of the resource
    :type id: str
    """

    _attribute_map = {"id": {"key": "id", "type": "str"}}

    def __init__(self, *, id: str = None, **kwargs) -> None:
        super(ResourceResponse, self).__init__(**kwargs)
        self.id = id

cloud_adapter_base.py

response = response or ResourceResponse(activity.id or "")

Suggest to update all callers include cloud_adapter_base.py to include the "id=" eg:

response = response or ResourceResponse(id=activity.id or "")

nice catch! I created a PR to fix the occurrences I found #2057

@CiraciNicolo
Copy link

When this will be released? It is a blocker issue for us, is there a roadmap or release date?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or an unintended behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants