in ts/src/util/cx-client.ts [39:71]
async detectIntentSimple(
text: 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,
payload,
},
queryInput: {
text: {
text,
},
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;
}