Merge branch 'main' of git.targo.ca:Targo/targo_backend

This commit is contained in:
Matthieu Haineault 2026-01-15 08:47:40 -05:00
commit f85c11f780
4 changed files with 13 additions and 21 deletions

View File

@ -13,8 +13,8 @@ export class ChatbotController {
@Post('')
@ModuleAccessAllowed(ModulesEnum.chatbot)
async testConnection(@Body() body: UserMessageDto): Promise<Message> {
return await this.chatbotService.pingExternalApi(body);
async testConnection(@Body() body: UserMessageDto, @Access('email') email: string): Promise<Message> {
return await this.chatbotService.pingExternalApi(body, email);
}
@Post('context')

View File

@ -8,35 +8,26 @@ import { Message } from 'src/chatbot/dtos/dialog-message.dto';
@Injectable()
export class ChatbotService {
constructor(private readonly httpService: HttpService) { }
sessionId: string;
sessionId: string = 'testing';
async pingExternalApi(body: UserMessageDto): Promise<Message> {
const response = await firstValueFrom(
this.httpService.post(
'https://n8nai.targo.ca/webhook/984c578e-59c7-4ca1-97f8-e225fd2acf01',
{ userInput: body.userInput, userId: this.sessionId },
),
);
const cleanText =
Array.isArray(response.data) && response.data[0]?.output
? response.data[0].output
: JSON.stringify(response);
async pingExternalApi(body: UserMessageDto, email: string): Promise<Message> {
const { data } = await firstValueFrom(this.httpService.post('https://n8nai.targo.ca/webhook/chatty-Mcbot', { userInput: body.userInput, userId: email, sessionId: this.sessionId }));
console.log(data);
return {
text: cleanText,
text: data[0].output,
sent: false,
};
}
async sendPageContext(body: PageContextDto) {
const response = await firstValueFrom(
const { data } = await firstValueFrom(
this.httpService.post(
'https://n8nai.targo.ca/webhook/984c578e-59c7-4ca1-97f8-e225fd2acf01',
'https://n8nai.targo.ca/webhook/chatty-Mcbot',
{ features: body, userId: this.sessionId, userInput: '' },
),
);
return response.data;
return data;
}
// Will have to modify later on to accomodate newer versions of User Auth/User type Structure
@ -47,7 +38,7 @@ export class ChatbotService {
const response = await firstValueFrom(
this.httpService.post(
'https://n8nai.targo.ca/webhook/984c578e-59c7-4ca1-97f8-e225fd2acf01',
'https://n8nai.targo.ca/webhook/chatty-Mcbot',
{
userId: this.sessionId,
userInput: '',

View File

@ -56,7 +56,7 @@ async function bootstrap() {
// Enable CORS
app.enableCors({
origin: ['http://10.100.251.2:9011', 'http://10.100.251.2:9012', 'http://10.100.251.2:9013', 'http://localhost:9000', 'https://app.targo.ca', 'https://staging.app.targo.ca'],
origin: ['http://10.100.251.2:9011', 'http://10.100.251.2:9012', 'http://10.100.251.2:9013', 'http://localhost:9000', 'https://app.targo.ca', 'https://app2.targo.ca','https://staging.app.targo.ca'],
credentials: true,
});

View File

@ -33,6 +33,7 @@ export class GetTimesheetsOverviewService {
//loads the timesheets related to the fetched pay-period
let rows = await this.loadTimesheets(employee_id.data, period.period_start, period.period_end);
console.log(rows);
//Normalized dates from pay-period strings
const normalized_start = toDateFromString(period.period_start);