async detectIntentSimpleEvent()

in ts/src/util/cx-client.ts [73:105]


  async detectIntentSimpleEvent(
    eventName: string,
    sessionID: string,
    channel?: string,
    payload?: JsonObject,
    languageCode: string = this.defaultLanguageCode,
    sessionTTLSeconds: number | undefined = this.defaultSessionTTL
  ) {
    const sessionPath = this.getSessionPath(sessionID);
    const request: google.cloud.dialogflow.cx.v3.IDetectIntentRequest & {
      queryParams: object;
    } = {
      session: sessionPath,
      queryParams: {
        channel,
      },
      queryInput: {
        event: {
          event: eventName,
        },
        languageCode,
      },
    };
    if (payload) {
      request.queryParams.payload = jsonToStruct(payload);
    }
    if (sessionTTLSeconds) {
      request.queryParams.sessionTtl = {seconds: sessionTTLSeconds};
    }

    const [response] = await this.client.detectIntent(request);
    return response.queryResult?.responseMessages;
  }