无法使用 webhook 将 Dialogflow 连接到 fastapi 后端和 ngrok

问题描述 投票:0回答:1

我无法理解为什么它无法使用 webhook 与后端连接。这是我的 fastapi 代码:

@app.post("/")
async def handle_request(request: Request):
    # Retrieve the JSON data from the request
    payload = await request.json()

    # Extract the necessary information from the payload
    #based on the structure of the WebhookRequest from Dialogflow
    intent = payload['queryResult']['intent']['displayName']
    parameters = payload['queryResult']['parameters']
    output_contexts = payload['queryResult']['outputContexts']

    if intent == "track.order - context: ongoing-tracking":
        return JSONResponse(content={
            "fulfillmentText": f"Received =={intent}== in the backend. "
        })

错误发生在我在对话框流中创建的意图“track.order - context: Continuous-tracking”中。

我已将 HTTP 转换为 HTTPS,并且我还使用了最近的 HTTPS URL,但仍然

我正在尝试从dialogflow向我的rest API发出webhook请求,该API在python fastapi和ngrok中运行。但它不起作用。

我在意图中使用实现

track.order - context: ongoing-tracking
,并且我应该收到实现消息“已在后端接收=={intent}==”。相反,我收到的是默认意图消息。

backend dialogflow-es webhooks
1个回答
-1
投票

尝试将 ngrok 链接粘贴到履行 URL 中 或访问此链接获取帮助 https://youtu.be/2e5pQqBvGco?si=6moAGIBh6h5y_1GN

我不知道确切的时间戳,但这会对您有所帮助。 我的正在工作

© www.soinside.com 2019 - 2024. All rights reserved.