首页 文章

他们对api.ai中触发的后续事件数量有任何限制吗?

提问于
浏览
0

我正在尝试使用多个后续事件来解决我的案例的对话流5秒响应时间限制 . 在用户输入之后,机器人必须使用api获取一些数据,这目前大约需要20-25秒 .

这是我的python webhook代码:

def makeWebhookResult(req):
flag = 0 
if req.get("queryResult").get("action")=="status":
    time.sleep(3.5)
    if flag == 0:

        return{
            "followupEventInput": {
            "name": "ContinueEvent1",
            "parameters": {
                "Status":"201"
                }
            }
        }
    else:
        return{
            "fulfillmentText":"This works",
    }
elif req.get("queryResult").get("action")=="status1":
    if flag == 0:
        time.sleep(3.5)

        return{
            "followupEventInput": {
            "name": "ContinueEvent2",
            "parameters": {
                "Status":"202"
                }
            }
        }
    else:
        return{
            "fulfillmentText":"This works in the last loop",
    }
elif req.get("queryResult").get("action")=="status2":
    time.sleep(3.5)
    if flag == 0:
        return{
            "followupEventInput": {
            "name": "ContinueEvent3",
            "parameters": {
                "Status":"203"
                }
            }
        }
    else:
        return{
            "fulfillmentText":"This works in the last loop",
    }
elif req.get("queryResult").get("action")=="status3":
    time.sleep(3.5)
    if flag == 0:
        return{
            "followupEventInput": {
            "name": "ContinueEvent4",
            "parameters": {
                "Status":"204"
                }
            }
        }
    else:
        return{
            "fulfillmentText":"This works in the last loop",
    }
elif req.get("queryResult").get("action")=="status4":
    time.sleep(3.5)
    if flag == 0:
        return{
            "followupEventInput": {
            "name": "ContinueEvent2",
            "parameters": {
                "Status":"205"
                }
            }
        }
    else:
        return{
            "fulfillmentText":"This works in the last loop",
    }



elif req.get("queryResult").get("action") == 'Check_vendor:
    time.sleep(3.5)
    '''
    Here i will call my api and get the response and set the flag variable.

    '''
    return{
        "followupEventInput": {
        "name": "ContinueEvent",
        "parameters": {
            "Status":"200"
        }

在这里,我的主要意图是'Check_vendor',它会点击我的api并获取参数 . 因此,为了参与api.ai,我会触发一个后续事件,作为回应将触及另一个后续事件 .

直到''ContinueEvent2''我的后续活动正在进行中 . 但是在该对话框流不触发ContinueEvent3之后,它将以ContinueEvent2的响应进行响应 .

那么Followup事件的数量有限制吗?

在这样做时,我遇到了两个参数:

"diagnosticInfo": {
  "accumulated_webhook_latency_ms": 11598,
  "webhook_latency_ms": 3777
},

这里的cumulative_webhook_latency_ms是什么?

先感谢您

1 回答

  • 0

    最好将时间花在优化服务上 . 20-25秒很多!
    谈话应该看起来像两个人之间的自然 . 您需要摆脱构建webapp或移动应用程序等聊天机器人的习惯,并显示等待消息或进度条 .

    添加多个事件可能会延迟服务延迟,但可能会严重影响用户体验 .

    • 确定用例服务 .

    • 使用静态数据开发Dialogflow代理 .

    • 进行用户体验分析,一旦接受FREEZE流程 .

    • 开发后端以支持新要求 . 这可能需要一些返工,因为您的服务状况不佳!

    • 一旦完成整合并测试 .

相关问题