如何使用python和bot fram创建一个简单的skype机器人

2024-09-26 22:07:57 发布

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

我正在尝试使用python在skype中创建一个非常简单的bot和botframework。 以下是我所做的步骤。在

  • 在资源中创建了一个频道机器人程序。在

enter image description here

  • 创建了一个简单的pythonweb服务,使用flask从bot接收消息。通过ngrok公开它,并在消息传递端点中添加了相同的内容。在

enter image description here

  • 我从webchat测试了bot,在pythonwebservice中得到了一个json

    {
    "recipient": {
    "id": "txBot@b0X6R31x6uQ", 
    "name": "txBot"
     }, 
    "from": {
    "id": "1xFUIEqdQfv", 
    "name": "You"
     }, 
     "entities": [
        {
        "supportsTts": true, 
        "supportsListening": true, 
        "type": "ClientCapabilities", 
        "requiresBotState": true
        }
     ], 
    "locale": "en", 
    "timestamp": "2018-11-22T13:00:42.9086958Z", 
    "channelId": "webchat", 
    "channelData": {
    "clientActivityId": "1542891640077.5912976099256072.0"
    }, 
    "conversation": {
        "id": "b5b52b9e464b4e958b1219dadedfffce"
    }, 
    "serviceUrl": "https://webchat.botframework.com/", 
    "text": "hello from test", 
    "textFormat": "plain", 
    "type": "message", 
    "id": "b5b52b9e464b4e958b1219dadedfffce|0000002"
    }
    
  • 我能够处理这个json,并能够将本例中的用户输入“hello from test”发送到我的webservice。

我想做的是从python返回相同的web聊天机器人。在

我也参考了下面的教程。我可以张贴回应回来,但我没有得到它在机器人。在

后端python代码如下

^{pr2}$

我得到的答复是200一旦我张贴回应,但没有得到回应在webchat。 这是我在python代码中得到的响应

{
  "id":"b5b52b9e464b4e958b1219dadedfffce|0000003"
}

这里怎么了?完全没有反应

enter image description here

得到了这个实现的参考。 https://chatbotslife.com/microsoft-bot-framework-on-a-bottle-13fdcc3e04e


Tags: namefromhttpsidjsontruetypebot

热门问题