Send a query to the dialogflow agent, and return the query result.
@param {string} projectId The project to be used
334905
async function runSample(projectId = 'your-project-id') {
  // A unique identifier for the given session
  const sessionId = uuid.v4();

  // Create a new session
  const sessionClient = new dialogflow.SessionsClient();
  const sessionPath = sessionClient.sessionPath(projectId, sessionId);

  // The text query request.
  const request = {
    session: sessionPath,
    queryInput: {
      text: {
        // The query to send to the dialogflow agent
        text: 'hello',
        // The language used by the client (en-US)
        languageCode: 'en-US',
      },
    },
  };

  // Send request and log result
  const responses = await sessionClient.detectIntent(request);
  console.log('Detected intent');
  const result = responses[0].queryResult;
  console.log(`  Query: ${result.queryText}`);
  console.log(`  Response: ${result.fulfillmentText}`);
  if (result.intent) {
    console.log(`  Intent: ${result.intent.displayName}`);
  } else {
    console.log(`  No intent matched.`);
  }
}
976981
def detect_intent_with_texttospeech_response(project_id, session_id, texts,
                                             language_code):
    """"""
    import dialogflow_v2beta1 as dialogflow
    session_client = dialogflow.SessionsClient()

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

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

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

        # Set the query parameters with sentiment analysis
        output_audio_config = dialogflow.types.OutputAudioConfig(
            audio_encoding=dialogflow.enums.OutputAudioEncoding
            .OUTPUT_AUDIO_ENCODING_LINEAR_16)

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

        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))
        # The response's audio_content is binary.
        with open('output.wav', 'wb') as out:
            out.write(response.output_audio)
            print('Audio content written to file "output.wav"')
316678
private void processProjectID()
   {
      if (m_projectID == null)
      {
         List<Row> rows = getRows("project", null, null);
         if (!rows.isEmpty())
         {
            Row row = rows.get(0);
            m_projectID = row.getInteger("proj_id");
         }
      }
   }
933668
def get_project_by_id(self, project_id):
        
        return self._create_item_response(
            self.data_service.get_project_by_id(project_id),
            Project)
1188207
function receiveMessageWithApiai(messageText, senderID, event) {
    var trequest = apiaiapp.textRequest(messageText, {
        sessionId: senderID
    });
    trequest.on('response', function(response) {
      
        var message = janis.convertFromApiaiResponseToMessage(response);
        var messageData = {
            recipient: {
                id: senderID
            },
            message: message
        }
        callSendAPI(messageData);

        if (response.result.action == "human") {
            // send a janis alert to your slack channel
            // that the user could use assistance
            janis.assistanceRequested(event);
        } else if (response.result.action == "input.unknown" ||
            (response.result.metadata.intentId == null && response.result.fulfillment.speech == "")) {
            //associate an action in api.ai with your fallback intents so you can catch them.
            //in this example, "input.unknown" is the action set in api.ai on the Default Fallback Intent.
          
            //capture conversational ‘dead-ends’ 
            //and send janis an alert to your slack channel
            janis.logUnknownIntent(event);
        }
    });
    trequest.on('error', function(error) {
        console.log(error);
        //capture conversational ‘dead-ends’ 
        //and send janis an alert to your slack channel
        janis.logUnkownIntent(event);
        sendTextMessage(senderID, error.message);
    });
    trequest.end();
}
42786
def get_project(self, project_id):
        ''''''
        project_response = self.get_request('projects/%s' % project_id)
        return Project(self, project_response['project'])
514011
def get_project(self, project_id):
        
        return youtrack.Project(self._get("/admin/project/" + urlquote(project_id)), self)
1245946
@InternalApi
  public com.google.bigtable.admin.v2.CreateAppProfileRequest toProto(String projectId) {
    String name = NameUtil.formatInstanceName(projectId, instanceId);

    return proto.setParent(name).build();
  }
813975
public IndexResponse sendData(String jsonSource, String index, String type,
            String id) {
        return indexQuery(buildIndexRequest(jsonSource, index, type, id));
    }
606144
function (data, id) {
            if (!data || !this.projectPath) {
                return;
            }

            if (data[this.projectPath] && (data[this.projectPath][id] !== undefined)) {
                return data[this.projectPath][id];
            }
            return;
        }
366126
public function query($projectId, QueryRequest $postBody, $optParams = array()) {
      $params = array('projectId' => $projectId, 'postBody' => $postBody);
      $params = array_merge($params, $optParams);
      $data = $this->__call('query', array($params));
      if ($this->useObjects()) {
        return new QueryResponse($data);
      } else {
        return $data;
      }
    }
872388
private void ajaxScheduleCronFlow(final HttpServletRequest req,
      final HashMap<String, Object> ret, final User user) throws ServletException {
    final String projectName = getParam(req, "projectName");
    final String flowName = getParam(req, "flow");

    final Project project = this.projectManager.getProject(projectName);

    if (project == null) {
      ret.put(PARAM_MESSAGE, "Project " + projectName + " does not exist");
      ret.put(PARAM_STATUS, STATUS_ERROR);
      return;
    }
    final int projectId = project.getId();

    if (!hasPermission(project, user, Type.SCHEDULE)) {
      ret.put(PARAM_STATUS, STATUS_ERROR);
      ret.put(PARAM_MESSAGE, "Permission denied. Cannot execute " + flowName);
      return;
    }

    final Flow flow = project.getFlow(flowName);
    if (flow == null) {
      ret.put(PARAM_STATUS, STATUS_ERROR);
      ret.put(PARAM_MESSAGE, "Flow " + flowName + " cannot be found in project "
          + projectName);
      return;
    }

    if (flow.isLocked()) {
      ret.put(PARAM_STATUS, STATUS_ERROR);
      ret.put(PARAM_MESSAGE, "Flow " + flowName + " in project " + projectName + " is locked.");
      return;
    }

    final boolean hasFlowTrigger;
    try {
      hasFlowTrigger = this.projectManager.hasFlowTrigger(project, flow);
    } catch (final Exception ex) {
      logger.error(ex);
      ret.put(PARAM_STATUS, STATUS_ERROR);
      ret.put(PARAM_MESSAGE, String.format("Error looking for flow trigger of flow: %s.%s ",
          projectName, flowName));
      return;
    }

    if (hasFlowTrigger) {
      ret.put(PARAM_STATUS, STATUS_ERROR);
      ret.put(PARAM_MESSAGE, String.format("<font color=\"red\"> Error: Flow %s.%s is already "
              + "associated with flow trigger, so schedule has to be defined in flow trigger config </font>",
          projectName, flowName));
      return;
    }

    final DateTimeZone timezone = DateTimeZone.getDefault();
    final DateTime firstSchedTime = getPresentTimeByTimezone(timezone);

    String cronExpression = null;
    try {
      if (hasParam(req, "cronExpression")) {
        // everything in Azkaban functions is at the minute granularity, so we add 0 here
        // to let the expression to be complete.
        cronExpression = getParam(req, "cronExpression");
        if (azkaban.utils.Utils.isCronExpressionValid(cronExpression, timezone) == false) {
          ret.put(PARAM_ERROR,
              "This expression <" + cronExpression + "> can not be parsed to quartz cron.");
          return;
        }
      }
      if (cronExpression == null) {
        throw new Exception("Cron expression must exist.");
      }
    } catch (final Exception e) {
      ret.put(PARAM_ERROR, e.getMessage());
    }

    final long endSchedTime = getLongParam(req, "endSchedTime",
        Constants.DEFAULT_SCHEDULE_END_EPOCH_TIME);
    try {
      // Todo kunkun-tang: Need to verify if passed end time is valid.
    } catch (final Exception e) {
      ret.put(PARAM_ERROR, "Invalid date and time: " + endSchedTime);
      return;
    }

    ExecutionOptions flowOptions = null;
    try {
      flowOptions = HttpRequestUtils.parseFlowOptions(req);
      HttpRequestUtils.filterAdminOnlyFlowParams(this.userManager, flowOptions, user);
    } catch (final Exception e) {
      ret.put(PARAM_ERROR, e.getMessage());
    }

    // Because either cronExpression or recurrence exists, we build schedule in the below way.
    final Schedule schedule = this.scheduleManager
        .cronScheduleFlow(-1, projectId, projectName, flowName,
            "ready", firstSchedTime.getMillis(), endSchedTime, firstSchedTime.getZone(),
            DateTime.now().getMillis(), firstSchedTime.getMillis(),
            firstSchedTime.getMillis(), user.getUserId(), flowOptions,
            cronExpression);

    logger.info("User '" + user.getUserId() + "' has scheduled " + "["
        + projectName + flowName + " (" + projectId + ")" + "].");
    this.projectManager.postProjectEvent(project, EventType.SCHEDULE,
        user.getUserId(), "Schedule " + schedule.toString()
            + " has been added.");

    ret.put(PARAM_STATUS, STATUS_SUCCESS);
    ret.put(PARAM_SCHEDULE_ID, schedule.getScheduleId());
    ret.put(PARAM_MESSAGE, projectName + "." + flowName + " scheduled.");
  }
25326
public Observable<Project> getProjectAsync(UUID projectId) {
        return getProjectWithServiceResponseAsync(projectId).map(new Func1<ServiceResponse<Project>, Project>() {
            @Override
            public Project call(ServiceResponse<Project> response) {
                return response.body();
            }
        });
    }
143173
function fetchProject(projectId) {
	return cocoonSDK.ProjectAPI.get(projectId)
	.catch((error) => {
		console.error("Project with ID: " + projectId + " couldn't be fetched.");
		console.trace(error);
		throw error;
	});
}
1186930
@ObjectiveCName("registerGooglePushWithProjectId:withToken:")
    public void registerGooglePush(long projectId, String token) {
        modules.getPushesModule().registerGooglePush(projectId, token);
    }
817727
async function createSessionEntityType(
  projectId,
  sessionId,
  entityValues,
  entityTypeDisplayName,
  entityOverrideMode
) {
  // Imports the Dialogflow library
  const dialogflow = require('dialogflow');

  // Instantiates clients
  const sessionEntityTypesClient = new dialogflow.SessionEntityTypesClient();

  const sessionPath = sessionEntityTypesClient.sessionPath(
    projectId,
    sessionId
  );
  const sessionEntityTypePath = sessionEntityTypesClient.sessionEntityTypePath(
    projectId,
    sessionId,
    entityTypeDisplayName
  );

  // Here we use the entity value as the only synonym.
  const entities = [];
  entityValues.forEach(entityValue => {
    entities.push({
      value: entityValue,
      synonyms: [entityValue],
    });
  });

  const sessionEntityTypeRequest = {
    parent: sessionPath,
    sessionEntityType: {
      name: sessionEntityTypePath,
      entityOverrideMode: entityOverrideMode,
      entities: entities,
    },
  };

  const [response] = await sessionEntityTypesClient.createSessionEntityType(
    sessionEntityTypeRequest
  );
  console.log('SessionEntityType created:');
  console.log(response);
}
156099
function compileProjectWithId(projectId) {
	return fetchProject(projectId)
	.then(compileProject)
	.catch((error) => {
		console.trace(error);
		throw error;
	});
}