import { Controller, Post, Body, Get, Query, Param } from '@nestjs/common'; import { Message } from 'src/chatbot/dtos/dialog-message.dto'; import { UserMessageDto } from 'src/chatbot/dtos/user-message.dto'; import { ChatbotService } from 'src/chatbot/chatbot.service'; import { PageContextDto } from 'src/chatbot/dtos/page-context.dto'; import { Access } from 'src/common/decorators/module-access.decorators'; import { ModuleAccessAllowed } from 'src/common/decorators/modules-guard.decorators'; import { Modules as ModulesEnum } from ".prisma/client"; @Controller('chatbot') export class ChatbotController { constructor(private readonly chatbotService: ChatbotService) {} @Post('') @ModuleAccessAllowed(ModulesEnum.chatbot) async testConnection(@Body() body: UserMessageDto, @Access('email') email: string): Promise { return await this.chatbotService.pingExternalApi(body, email); } @Post('context') @ModuleAccessAllowed(ModulesEnum.chatbot) async sendContext(@Body() body: PageContextDto): Promise { const sendPageContext = await this.chatbotService.sendPageContext(body); return sendPageContext; } // Will have to modify later on to accomodate newer versions of User Auth/User type Structure @Post('user') @ModuleAccessAllowed(ModulesEnum.chatbot) async sendUserCredentials(@Access('email') email: string,): Promise { const sendUserContext = await this.chatbotService.sendUserContext(email); return sendUserContext; } }