Is their any limit on number of followup event triggered in api.ai?

人走茶凉 提交于 2020-04-18 08:41:18

问题


I am trying to solve the dialog flow 5 sec response time limit for my case using multiple followup events. After the user input, the bot has to fetch some data using an api, which is currently taking around 20-25 sec.

This is my python webhook code:

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"
        }

Here my Main intent is 'Check_vendor', Which will hit my api and get the parameter. So to engage the api.ai I trigger a followup event which in response will hit another follow-up event.

Till ''ContinueEvent2'' my followup events are working. But after that dialogflow doesn't trigger the ContinueEvent3, it responds with the response of ContinueEvent2.

So is there any limit on the number of Followup event ?

While doing this I came across 2 parameters:

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

What is accumulated_webhook_latency_ms over here ?

Thank you in advance


回答1:


Better to invest your time in optimizing your service. 20-25 sec is a lot!
The conversation should look like natural like between two humans. You need to get out of the habit of building chatbots like webapp or mobile app and to show waiting messages or progress bars.

Adding multiple events may fulfill the service delay but it may drastically affect the user experience.

  • Decide a use case to serve.
  • Develop a Dialogflow agent using static data.
  • Do your UX analysis and once accepted FREEZE the flow.
  • Develop your backend to support new requirements. This may require some rework as your services are not in a good state!
  • Once done integrate all and test.



回答2:


Recently, i have similar use case where i had to process a workflow triggered by webhook request from dialogflow and send back the result. The execution of this workflow almost took 40-50 sec. I have also use the exact same approach of calling intent again-n-again by employ followUpEventInput. I figure out that at max we can call 3 follow up event. So, at max we can engage our request to 15 sec (5 sec per request * 3 request). There is not much documentation related to it. So, better we figure out some other solution maybe using slot-filling or any other logic.



来源:https://stackoverflow.com/questions/51921780/is-their-any-limit-on-number-of-followup-event-triggered-in-api-ai

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!