【问题标题】:Chating with your microsoft bot framework via Postman通过 Postman 与您的 microsoft bot 框架聊天
【发布时间】:2020-03-02 16:26:41
【问题描述】:

我对 Bot Framework 很陌生,正在探索解决方案。

我正在尝试在 android 应用程序(以及之后的 python 烧瓶应用程序)中使用 microsoft bot 框架作为 API 调用。为此,我想弄清楚如何向我的机器人发送消息并通过邮递员

接收答案

现在,我的机器人已在团队和网络聊天中启动并运行。我正在使用 bot 服务来利用 microsoft bot 框架。我的应用在 Heroku 上运行,而机器人托管在 Azure 上。

我已经检查了 bot 服务上的直线通道,但 这是为网络聊天返回一个 iframe,我想通过 python、java 等以编程方式发送我的消息作为 api 调用

我还检查了有关 v3 bot 框架的 stackoverflow 问题,并尝试了以下方法: How to connect my python bot to microsoft bot connector

Send message from Postman to Microsoft Bot

https://pypi.org/project/botframework-connector/

1° 在第二个 stackoverflow url 之后,我可以访问我的不记名令牌:

{
   "token_type": "Bearer",
   "expires_in": 3600,
   "ext_expires_in": 3600,
   "access_token": "eyJ0eXAiOiJKV1QiL***********************************ObNWg"
}

2° 然后为邮递员提供带有此 url https://directline.botframework.com/v3/directline/conversations/ 的不记名令牌

还有这个 json 原始正文:

{
    "type": "message",
    "from": {
        "id": "user1"
    },
    "text": "hello"
}

这是返回:

{
  "error": {
    "code": "BadArgument",
    "message": "Missing token or secret"
  }
}

如前所述,我是新手,因此对上述内容的任何见解将不胜感激!

【问题讨论】:

    标签: botframework postman


    【解决方案1】:

    好吧,没关系,我正在寻找的答案可在本教程中找到: https://thewebspark.com/2018/04/15/directlineapi-testing-with-custom-client-and-postman-microsoft-bot-framework/.

    它在我这边工作得很好。

    1) 您在Bearer <token> 上使用您的直接线路令牌,在https://directline.botframework.com/v3/directline/conversations 上使用POST 请求。

    你会得到一个新的令牌和一个 conversation_ID

    2)然后你在https://directline.botframework.com/v3/directline/conversations/conversation_ID/activities上使用GET请求

    您的新令牌为Bearer <token> 和你的 json 身体:

    {
        "type": "message",
        "from": {
            "id": "user1"
        },
        "text": "hello"
    }
    

    就是这样!

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多