我可以为 python 获得一个完整的简单 DialogFlow 示例(当前版本 v2)吗?

Can I get a complete simple DialogFlow example (of the current version v2) for python?

我试过使用一些旧教程,但我真正需要的只是一个完整的示例,我可以修改它以满足我的需要。

只是 python 中使用 DialogFlow 的示例(或 c++,尽管这需要重做我目前所做的)?只是一个简单的接口,DialogFlow 接受一个字符串并发回一个字符串?

您可以关注quickstart

def detect_intent_texts(project_id, session_id, texts, language_code):
    """Returns the result of detect intent with texts as inputs.

    Using the same `session_id` between requests allows continuation
    of the conversation."""
    import dialogflow_v2 as dialogflow
    session_client = dialogflow.SessionsClient()

    session = session_client.session_path(project_id, session_id)
    print('Session path: {}\n'.format(session))

    for text in texts:
        text_input = dialogflow.types.TextInput(
            text=text, language_code=language_code)

        query_input = dialogflow.types.QueryInput(text=text_input)

        response = session_client.detect_intent(
            session=session, query_input=query_input)

        print('=' * 20)
        print('Query text: {}'.format(response.query_result.query_text))
        print('Detected intent: {} (confidence: {})\n'.format(
            response.query_result.intent.display_name,
            response.query_result.intent_detection_confidence))
        print('Fulfillment text: {}\n'.format(
            response.query_result.fulfillment_text))

def main():
    project_id = 'PROJECT-ID-HERE'
    session_id = 'SESSION-ID-HERE'
    texts = ['reserve a meeting room for six people']
    language_code = 'en-US'

    detect_intent_texts(project_id, session_id, texts, language_code)

main()

文本应该是字符串的可迭代(列表、元组等)。

您还应该已经通过身份验证——我建议使用带有 json 密钥的服务帐户,因为它非常容易上手。有个很好的例子here.