recently I was trying to create a chatbot using dialogflow. I had setup and trained the dialogflow agent as intended. After this, I created a backend. Although, it was in its initial step for testing purposes. I was just making sure that the agent is hitting the backend or not. I created the backend using fast api. I tried by giving some input to the agent. Basically it is a food ordering chatbot. I am getting this error everytime when i gave order id.
Note: I created a tunnel via ngrok for https request.
I was testing a “track.order – context: ongoing-tracking” intent whether it is receiving the request or not in the backend. I just wanted to expect something like this when the user gave order id:
received ==track.order - ongoing-tracking== in the backend
But I am getting:
Default response: Not available
Also getting this fulfillment status in json response:
Webhook call failed. Error: Failed to parse webhook JSON response: Expect message object but got: null.
Fulfillment response:
{}
Fulfillment Request:
{
"responseId": "5b7e5f8f-0f03-442d-b57b-6ecc96d49237-8d7c4bc4",
"queryResult": {
"queryText": "45",
"parameters": {
"order_id": 45
},
"allRequiredParamsPresent": true,
"fulfillmentMessages": [
{
"text": {
"text": [
""
]
}
}
],
"outputContexts": [
{
"name": "projects/zara-restro-bot-9kaw/agent/sessions/410a07bb-14a7-1b4e-e0ec-207c145cef2a/contexts/ongoing-tracking",
"lifespanCount": 1,
"parameters": {
"order_id": 45,
"order_id.original": "45"
}
}
],
"intent": {
"name": "projects/zara-restro-bot-9kaw/agent/intents/caa8cbd8-a75a-48dd-aa61-92b050f15fc4",
"displayName": "track.order - context: ongoing-tracking"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"webhook_latency_ms": 574
},
"languageCode": "en",
"sentimentAnalysisResult": {
"queryTextSentiment": {
"score": 0.1,
"magnitude": 0.1
}
}
},
"webhookStatus": {
"code": 3,
"message": "Webhook call failed. Error: Failed to parse webhook JSON response: Expect message object but got: null."
}
}
Raw Api Response:
{
"responseId": "5b7e5f8f-0f03-442d-b57b-6ecc96d49237-8d7c4bc4",
"queryResult": {
"queryText": "45",
"parameters": {
"order_id": 45
},
"allRequiredParamsPresent": true,
"fulfillmentMessages": [
{
"text": {
"text": [
""
]
}
}
],
"outputContexts": [
{
"name": "projects/zara-restro-bot-9kaw/agent/sessions/410a07bb-14a7-1b4e-e0ec-207c145cef2a/contexts/ongoing-tracking",
"lifespanCount": 1,
"parameters": {
"order_id": 45,
"order_id.original": "45"
}
}
],
"intent": {
"name": "projects/zara-restro-bot-9kaw/agent/intents/caa8cbd8-a75a-48dd-aa61-92b050f15fc4",
"displayName": "track.order - context: ongoing-tracking"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"webhook_latency_ms": 574
},
"languageCode": "en",
"sentimentAnalysisResult": {
"queryTextSentiment": {
"score": 0.1,
"magnitude": 0.1
}
}
},
"webhookStatus": {
"code": 3,
"message": "Webhook call failed. Error: Failed to parse webhook JSON response: Expect message object but got: null."
}
}
My backend fast api code is:
from fastapi import FastAPI
from fastapi import Request
from fastapi.responses import JSONResponse
app = FastAPI()
@app.post("/")
async def handle_request(request: Request):
payload = await request.json()
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"
})