将 dialogflow voicebot 连接到 twilio 号码

connecting dialogflow voicebot to twilio number

我是 dialogflow 和 twilio 的菜鸟。我正在尝试将我的 dialogflow 机器人连接到 Twilio 号码。 我有一个 twilio 号码,我正在使用 dialogflow small talk 意图集。

将 dialogflow(语音)机器人连接到带有语音(不是短信或聊天消息)的 twilio 号码的步骤是什么?

在 twilio 方面,我找到了这段代码 从烧瓶导入烧瓶 from twilio.twiml.voice_response import Gather, Redirect, VoiceResponse, Say app = Flask(名称)

@app.route("/answer", methods=['GET', 'POST'])
def answer_call():
    """Respond to incoming phone calls with a brief message."""
    # Start our TwiML response
    response = VoiceResponse()

    # Read a message aloud to the caller

    gather = Gather(input='speech',action='some_url')
    gather.say('Welcome to Paradise, please tell us why you\'re calling')
    response.append(gather)

    return str(response)

if __name__ == "__main__":
    app.run(debug=True)

1) 我知道我应该将我的 dialogflow 机器人的 url 放入 action 参数中。我对吗?

2) 如果是,我在哪里可以找到这个 url?与此有关吗? => https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/v2/projects.agent.sessions/detectIntent

3) 那么,会话名称是什么?

我正在尝试使用右边的框"Try this API":但是无论我写什么字符串,收到的输出都是: "name does not match pattern: /^projects/[^/]+/agent/sessions/[^/]+/contexts/[^/]+$/"

如前所述,我是一个新手,所以如果对以上内容有任何见解,我们将不胜感激! 非常感谢您!

这里是 Twilio 开发人员布道师。

我没有直接使用 Dialogflow 和 Twilio 语音(我更喜欢将语音与 Twilio Autopilot 连接,因为它开箱即用)。但是我知道 Twilio Voice 和 Dialogflow 之间没有直接连接。

虽然你走在正确的轨道上。使用 <Gather> will capture the user's speech and translate it to text (actually using Google's Cloud Speech API). That text will be sent to your action URL as the SpeechResult. You can't connect that directly to your Dialogflow API endpoint because Dialogflow will expect the parameter to be different and Twilio will expect the result to be TwiML.

相反,您需要在自己的服务器上设置操作端点,检索 SpeechResult,然后将其发送到 Dialogflow 以获得结果。您可能会发现通过安装 Dialogflow Python client and using it to send the request (check out the documentation here)可以更轻松地与 Dialogflow API 交互。一旦您从 Dialogflow 获得结果,您就可以使用它来构建 TwiML 以创建一个新的 <Gather> 用于进一步的输入,或者只是一个 <Say> 到 return 的响应。

让我知道这是否为您指明了正确的方向。