You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Dialogflow V2beta1中区分文本/音频来源及不同终端机器人

Got it, I've run into this exact issue before when migrating from Dialogflow V1 to V2beta1. The good news is there's a reliable way to distinguish between audio-based (Alexa/Google Home) and text-based bots, even though the old numeric message enum from V1 is gone.

How to Distinguish Bot Types in Dialogflow V2beta1

  • Check the originalDetectIntentRequest.source field
    This string field directly identifies the originating platform. For example:

    • "google" for Google Assistant devices (including audio-only ones like Google Home)
    • "alexa" for Alexa-enabled voice devices
    • "dialogflowMessenger", "slack", "telegram" (text mode) for text-based bots that support Rich Responses
  • Dig into originalDetectIntentRequest.payload for granular device details
    For audio platforms, the payload adds context to confirm device capabilities:

    • For Google Assistant, look for payload.surface.capabilities — if it includes actions.capabilities.AUDIO_OUTPUT, you can be sure it's an audio-only device that can't render Rich Responses.
    • Alexa's payload follows the Alexa Skills Kit request format, with fields like request.type (e.g., "LaunchRequest") that clearly signal voice-first interactions.
  • Build response logic with source mapping
    Add a simple check in your webhook code to categorize platforms and serve appropriate responses:

    const isAudioOnlyBot = (source) => {
      return ["google", "alexa"].includes(source);
    };
    
    const supportsRichResponses = (source) => {
      return ["dialogflowMessenger", "slack", "telegram"].includes(source);
    };
    

    Use these functions to skip Rich Responses for audio bots, and include them for text-based platforms.

Key Note

V2beta1 replaces V1's numeric message enum with platform-specific string sources and payloads. It's more verbose, but it gives you finer control over different device types beyond just audio vs text.

内容的提问来源于stack exchange,提问作者Jefftopia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:48:45