How to handle feedback for a bot built with Teams Toolkit and teams-ai library in Python

Andrea ESPOSITO 5 Reputation points
2025-03-11T08:54:06.1233333+00:00

Hi,

I'm building a Chatbot with Teams Toolkit SDK for Visual Studio Code and teams-ai library in Python.

The Chatbot uses Azure AI Search to achieve the "Chat with your data" functionalities. I enabled the feedback_loop within the AI Options.

bot_app = Application[TurnState](
    ApplicationOptions(
        bot_app_id=config.APP_ID,
        storage=storage,
        adapter=TeamsAdapter(config),
        ai=AIOptions(planner=planner, enable_feedback_loop=True, feedback_loop_type='default'),
    )
)

By the default handler the "like" and "dislike" button are shown, the feedback also is recorded but I can't link the feedback to the message that the feeback is related to. This how i get feedback data as now:

@bot_app.feedback_loop()
async def feedback_loop(_context: TurnContext, _state: TurnState, feedback_loop_data: FeedbackLoopData):
    # Add custom feedback process logic here.
    print(_context.activity)
    print('--')
    print(_context.turn_state)
    print('--')
    print(feedback_loop_data)
    print('--')
    print(f"Your feedback is:\n{json.dumps(asdict(feedback_loop_data), indent=4)}")

When the event submitButton is handled this is what i have within _context:

{'additional_properties': {}, 'type': 'invoke', 'id': 'b5e915fc-1b2d-42c4-83eb-c53e939eb507', 'timestamp': datetime.datetime(2025, 3, 10, 15, 49, 44, 739000, tzinfo=
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,644 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.