I’m working with Google’s Agent Builder and trying to implement function calling. The issue is that when I test my agent in the Agent Builder console, everything works perfectly. I can see the function call data in the response.
{
"responseData": {
"userQuery": "check temperature in London",
"locale": "en",
"messages": [
{
"origin": "BOT_AGENT",
"functionCall": {
"functionId": "<function-id>",
"methodName": "fetch-temperature",
"parameters": {
"city": "London"
}
}
}
]
}
}
But when I use the same agent through Dialogflow Messenger on my website, the function call information is completely missing from the API response.
{
"responseData": {
"userQuery": "check temperature in London",
"locale": "en",
"messages": [
{}
]
}
}
This causes my application to break because it’s expecting the function call details to execute the proper code. Has anyone encountered this difference between the testing environment and the actual Messenger integration? Why would the same agent behave differently?
I ran into this exact problem about six months ago and it drove me crazy for weeks. The root cause is that Dialogflow Messenger has different response formatting compared to the Agent Builder console. The Messenger integration strips out certain technical details like function call metadata to simplify the client-side implementation. What worked for me was implementing a webhook fulfillment that captures the function call information before it gets filtered out by the Messenger layer. In your webhook, you can detect when a function call is triggered and handle the execution server-side, then return the processed result as a regular text response to the Messenger. Alternatively, you might want to consider using the Dialogflow ES/CX API directly instead of relying on the Messenger widget if you need access to the raw function call data. The trade-off is more complex implementation but you get full control over the response structure. This inconsistency between testing and production environments is unfortunately a known limitation that Google hasn’t addressed yet.
yeah this is super frustrating! dialogflow messenger basically sanitizes the responses for security reasons. try checking the network tab in dev tools - sometimes the function data is there but gets stripped before reaching your js. quick workaround is using postMessage events to catch the raw data before processing.
Been dealing with this mess for years. Google basically treats the Messenger widget like a consumer chat interface, so it filters out all the backend stuff including function calls.
What I ended up doing was building a middleware layer that sits between your frontend and Dialogflow. Instead of calling the agent directly through Messenger, I route everything through my own API endpoint first.
The flow looks like this:
User types in Messenger → Your API catches it → Calls Dialogflow API directly → Gets full response with function data → Executes function → Returns clean response to Messenger
Takes maybe a day to set up but gives you complete control. Plus you can log everything properly and handle errors better.
Another option is ditching Messenger entirely and using the REST API with a custom chat interface. More work upfront but way more reliable for production apps that need function calling.