Merge branch 'main' of git.targo.ca:Targo/targo_backend
This commit is contained in:
commit
f85c11f780
|
|
@ -13,8 +13,8 @@ export class ChatbotController {
|
||||||
|
|
||||||
@Post('')
|
@Post('')
|
||||||
@ModuleAccessAllowed(ModulesEnum.chatbot)
|
@ModuleAccessAllowed(ModulesEnum.chatbot)
|
||||||
async testConnection(@Body() body: UserMessageDto): Promise<Message> {
|
async testConnection(@Body() body: UserMessageDto, @Access('email') email: string): Promise<Message> {
|
||||||
return await this.chatbotService.pingExternalApi(body);
|
return await this.chatbotService.pingExternalApi(body, email);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('context')
|
@Post('context')
|
||||||
|
|
|
||||||
|
|
@ -8,35 +8,26 @@ import { Message } from 'src/chatbot/dtos/dialog-message.dto';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ChatbotService {
|
export class ChatbotService {
|
||||||
constructor(private readonly httpService: HttpService) { }
|
constructor(private readonly httpService: HttpService) { }
|
||||||
sessionId: string;
|
sessionId: string = 'testing';
|
||||||
|
|
||||||
async pingExternalApi(body: UserMessageDto): Promise<Message> {
|
async pingExternalApi(body: UserMessageDto, email: string): Promise<Message> {
|
||||||
const response = await firstValueFrom(
|
const { data } = await firstValueFrom(this.httpService.post('https://n8nai.targo.ca/webhook/chatty-Mcbot', { userInput: body.userInput, userId: email, sessionId: this.sessionId }));
|
||||||
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);
|
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
return {
|
return {
|
||||||
text: cleanText,
|
text: data[0].output,
|
||||||
sent: false,
|
sent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendPageContext(body: PageContextDto) {
|
async sendPageContext(body: PageContextDto) {
|
||||||
const response = await firstValueFrom(
|
const { data } = await firstValueFrom(
|
||||||
this.httpService.post(
|
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: '' },
|
{ 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
|
// 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(
|
const response = await firstValueFrom(
|
||||||
this.httpService.post(
|
this.httpService.post(
|
||||||
'https://n8nai.targo.ca/webhook/984c578e-59c7-4ca1-97f8-e225fd2acf01',
|
'https://n8nai.targo.ca/webhook/chatty-Mcbot',
|
||||||
{
|
{
|
||||||
userId: this.sessionId,
|
userId: this.sessionId,
|
||||||
userInput: '',
|
userInput: '',
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ async function bootstrap() {
|
||||||
|
|
||||||
// Enable CORS
|
// Enable CORS
|
||||||
app.enableCors({
|
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,
|
credentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ export class GetTimesheetsOverviewService {
|
||||||
|
|
||||||
//loads the timesheets related to the fetched pay-period
|
//loads the timesheets related to the fetched pay-period
|
||||||
let rows = await this.loadTimesheets(employee_id.data, period.period_start, period.period_end);
|
let rows = await this.loadTimesheets(employee_id.data, period.period_start, period.period_end);
|
||||||
|
console.log(rows);
|
||||||
|
|
||||||
//Normalized dates from pay-period strings
|
//Normalized dates from pay-period strings
|
||||||
const normalized_start = toDateFromString(period.period_start);
|
const normalized_start = toDateFromString(period.period_start);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user