input: Write a function to create a simple chatbot using Python and Dialogflow that can answer questions about the current days of the week, and ensure the chatbot handles a basic REST API using Flask. The function should generate a session_id if not provided and use Dialogflow to detect the intent and respond with the appropriate text.
  assert detect_intent_text('What is today?', 'session123') == 'Today is Tuesday.'
  assert detect_intent_text('Which day is it today?', 'session456') == 'Today is Tuesday.'
  assert detect_intent_text('', 'session789') == ''
output: def detect_intent_text(text, session_id=None):
      if not session_id:
          session_id = str(uuid.uuid4())
      session_client = dialogflow.SessionsClient()
      session = session_client.session_path(project_id, session_id)
      text_input = dialogflow.types.TextInput(text=text, language_code='en')
      query_input = dialogflow.types.QueryInput(text=text_input)
      response = session_client.detect_intent(session=session, query_input=query_input)
      return response.query_result.fulfillment_text