Teams Bot Framework 建议的操作

问题描述 投票:0回答:0

我有以下代码,用 Python 和 Bot Framework v4 SDK 编写。每当我使用 suggestedActions 键入“test”时,如何让机器人生成带有建议操作的按钮?

我能够从示例中重现运行:https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/08.suggested-actions

但是当我尝试将它移植到我的机器人时它不起作用,示例代码如下。我的错误可能是由于我对异步如何工作的误解?

class MyBot(ActivityHandler):
    async def on_message_activity(self, turn_context: TurnContext):

    [code truncated]
            elif re.search('TEST', str(turn_context.activity.text).upper()):
                      
            print('test...')
            return await self._send_suggested_actions(turn_context)   
   [code truncated]

     async def _send_suggested_actions(self, turn_context: TurnContext):
        reply = MessageFactory.suggested_actions(
        SuggestedActions(
            actions=[
                CardAction(title="Help", type=ActionTypes.im_back, value="help"),
                CardAction(title="Plant", type=ActionTypes.im_back, value="menu"),
            ],
        )
    )
        await turn_context.send_activity(reply)

python asynchronous botframework microsoft-teams chatbot
© www.soinside.com 2019 - 2024. All rights reserved.