Skip to content

[Bug]: Python SDK can not work in M365 Copilot platform #2326

@frankqianms

Description

@frankqianms

Language

Python

Version

latest

Description

Using SDK to create a basic chat bot and add neccessary scopes in manifest.json to sideload the bot in M365 Copilot. Try to conversation with the bot agent, get the error.

[on_turn_error] unhandled error: 'text'
Traceback (most recent call last):
  File "c:\Users\frankqian\TeamsApps\test11\.venv\Lib\site-packages\botbuilder\core\bot_adapter.py", line 174, in run_pipeline
    return await self._middleware.receive_activity_with_status(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\frankqian\TeamsApps\test11\.venv\Lib\site-packages\botbuilder\core\middleware_set.py", line 69, in receive_activity_with_status
    return await self.receive_activity_internal(context, callback)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\frankqian\TeamsApps\test11\.venv\Lib\site-packages\botbuilder\core\middleware_set.py", line 79, in receive_activity_internal
    return await callback(context)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\frankqian\TeamsApps\test11\.venv\Lib\site-packages\teams\app.py", line 745, in on_turn
    await self._start_long_running_call(context, self._on_turn)
  File "c:\Users\frankqian\TeamsApps\test11\.venv\Lib\site-packages\teams\app.py", line 903, in _start_long_running_call
    return await func(context)
           ^^^^^^^^^^^^^^^^^^^
  File "c:\Users\frankqian\TeamsApps\test11\.venv\Lib\site-packages\teams\app.py", line 751, in _on_turn
    self._remove_mentions(context)
  File "c:\Users\frankqian\TeamsApps\test11\.venv\Lib\site-packages\teams\app.py", line 786, in _remove_mentions
    context.activity.text = context.remove_recipient_mention(context.activity)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\frankqian\TeamsApps\test11\.venv\Lib\site-packages\botbuilder\core\turn_context.py", line 392, in remove_recipient_mention
    return TurnContext.remove_mention_text(activity, activity.recipient.id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\frankqian\TeamsApps\test11\.venv\Lib\site-packages\botbuilder\core\turn_context.py", line 401, in remove_mention_text
    escape(mention.additional_properties["text"]),
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'text'

Reproduction Steps

repro-noresponse-in-copilot.mp4
1.clone the bot repo from this link.https://github.com/frankqianms/basic-py
2.open the project using Teams Toolkit in vs code.
3.input neccessary api_key, deployment model name, endpoint in .env.local.user 
4.launch debug with “Debug in Teams(Desktop)”
5.in Teams Copilot channel, try to start converstion
6.get the error
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    PythonChange/fix applies to Python. If all three, use the 'JS & dotnet & Python' labelbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions