python使用Microsoft团队bot发送pdf文件

2024-09-29 07:24:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要为发送pdf文件创建选项。现在我做的是,如果在聊天发送@bot send pdf中,然后发送下面的基本测试卡代码

async def on_message_activity(self, turn_context: TurnContext):
    self._add_conversation_reference(turn_context.activity)
    if " send pdf" in  turn_context.activity.text:
        cardAtt = self.thumbnail_card()
        msg_activity = MessageFactory.attachment(cardAtt)
        await turn_context.send_activity(msg_activity)
    else:
        return await turn_context.send_activity(
            f"You sent : {turn_context.activity.text}"
            )
def thumbnail_card(self) -> Attachment:
  card = ThumbnailCard()
  card.images = [ThumbnailUrl(url="https://pypi.org/static/images/logo-large.72ad8bf1.svg")]
  card.title = "Bot builder sample card"
  card.subtitle = "SDK Version 4.9"
  card.text = "Thumbnail card is the one of the card type in Bot Framework"
  return CardFactory.thumbnail_card(card)

是否可以更改缩略图卡以在聊天室中发送pdf文件,并允许用户下载?在manifest.json文件中,我允许"supportsFiles": true, 你知道怎么做吗?它不是很多信息如何发送pdf文件与微软机器人。所以也许你能帮我


Tags: 文件textinselfsendpdfdefcontext
2条回答

我认为一般的指导原则不是实际发送文件,而是向文件发送链接——它支持更好的组织文档/记录管理,例如,让文档保留在SharePoint中,让您只需在缩略图卡(或其他)中发送指向文档的链接。当然,该文件可以托管在其他地方(例如Azure Blob)

这是要发送pdf的sample, 你能试试这个吗

相关问题 更多 >