【问题标题】:How can i send api requests and get the answers using boto3?如何使用 boto3 发送 api 请求并获得答案?
【发布时间】:2017-12-23 09:15:39
【问题描述】:

我已经在 Lex 上构建了我的机器人。

我正在尝试在 python 上与之交互,发送请求(句子)并解析答案。

为此,我现在花了一些时间阅读和重读这些文档:https://boto3.readthedocs.io/en/latest/reference/services/lex-runtime.html#LexRuntimeService.Client.generate_presigned_url

但我似乎不明白如何发送这些请求,以及哪个函数实际上会给我来自机器人的答案。

【问题讨论】:

    标签: boto3 chatbot amazon-lex


    【解决方案1】:

    你试过post_text()方法吗?

    import boto3 
    client = boto3.client('lex-runtime')
    response = client.post_text(
        botName='string',
        botAlias='string',
        userId='string',
        sessionAttributes={
            'string': 'string'
        },
        requestAttributes={
            'string': 'string'
        },
        inputText='string'
    ) 
    

    此函数将为您提供机器人的答案,并将其存储在response 变量中。
    在 Lambda 函数中编写代码并授予访问 Lex 的权限。

    希望对您有所帮助。

    【讨论】:

    • 你需要填写值来代替'string'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-29
    • 2012-10-02
    • 2016-11-30
    • 1970-01-01
    • 1970-01-01
    • 2012-09-13
    相关资源
    最近更新 更多