You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
654 B

from google.cloud import dialogflow_v2beta1 as dialogflow
from dotenv import load_dotenv
load_dotenv()
async def detect_intent_text(project_id, session_id, text, language_code):
session_client = dialogflow.SessionsClient()
session = session_client.session_path(project_id, session_id)
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)
if response.query_result.intent.is_fallback:
return None
return response.query_result.fulfillment_text