-
Notifications
You must be signed in to change notification settings - Fork 2
Send Email Notification on Chatbot Answer Change #421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d942657
7fbf392
31447de
eca8b32
11eeef3
6110ee7
0003ee1
9569e98
824bd79
cf46dad
c41c2ef
980bd5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -395,6 +395,26 @@ export class APIClient { | |
| docId: string, | ||
| ): Promise<{ success: boolean }> => | ||
| this.req('DELETE', `/api/v1/chatbot/document/${courseId}/${docId}`), | ||
| notifyAnswerUpdate: async ( | ||
| courseId: number, | ||
| vectorStoreId: string, | ||
| body: { | ||
| oldAnswer: string | ||
| newAnswer: string | ||
| oldQuestion?: string | ||
| newQuestion?: string | ||
| }, | ||
|
Comment on lines
+401
to
+406
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace with NotifyUpdatedChatbotAnswerParams that you've created |
||
| ): Promise<{ | ||
| recipients: number | ||
| totalRecipients: number | ||
| unsubscribedRecipients: number | ||
| }> => | ||
| this.req( | ||
| 'POST', | ||
| `/api/v1/chatbot/question/${courseId}/${vectorStoreId}/notify`, | ||
| undefined, | ||
| body, | ||
| ), | ||
| uploadDocument: async ( | ||
| courseId: number, | ||
| body: FormData, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ import { | |
| OrganizationChatbotSettings, | ||
| OrganizationChatbotSettingsDefaults, | ||
| OrganizationRole, | ||
| NotifyUpdatedChatbotAnswerParams, | ||
| Role, | ||
| UpdateChatbotProviderBody, | ||
| UpdateChatbotQuestionParams, | ||
|
|
@@ -378,6 +379,29 @@ export class ChatbotController { | |
| // } | ||
|
|
||
| // resets all chatbot data for the course. Unused | ||
|
|
||
| // staff-only: send notification email to all students who asked this question | ||
| // Body must include oldAnswer and newAnswer, and can optionally include question changes for context | ||
| @Post('question/:courseId/:vectorStoreId/notify') | ||
| @UseGuards(CourseRolesGuard) | ||
| @Roles(Role.PROFESSOR, Role.TA) | ||
| async notifyUpdatedAnswer( | ||
| @Param('courseId', ParseIntPipe) courseId: number, | ||
| @Param('vectorStoreId') vectorStoreId: string, | ||
| @Body() body: NotifyUpdatedChatbotAnswerParams, | ||
| @User({ courses: true }) user: UserModel, | ||
| ): Promise<{ | ||
| recipients: number; | ||
| totalRecipients: number; | ||
| unsubscribedRecipients: number; | ||
| }> { | ||
|
Comment on lines
+393
to
+397
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turn this return type into an object NotifyUpdatedAnswerResponse and place it inside common/index.ts. Modify the |
||
| return await this.chatbotService.notifyUpdatedAnswer( | ||
| courseId, | ||
| vectorStoreId, | ||
| body, | ||
| user, | ||
| ); | ||
| } | ||
| // @Get('resetCourse/:courseId') | ||
| // @UseGuards(CourseRolesGuard) | ||
| // @Roles(Role.PROFESSOR, Role.TA) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import { CacheModule } from '@nestjs/cache-manager'; | |
| import { ChatbotDataSourceService } from './chatbot-datasource/chatbot-datasource.service'; | ||
| import { ChatbotDataSourceModule } from './chatbot-datasource/chatbot-datasource.module'; | ||
| import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions'; | ||
| import { MailService } from 'mail/mail.service'; | ||
|
|
||
| @Module({ | ||
| controllers: [ChatbotController], | ||
|
|
@@ -21,7 +22,12 @@ export class ChatbotModule { | |
| CacheModule.register(), | ||
| ChatbotDataSourceModule.forRoot(connectionOptions), | ||
| ], | ||
| providers: [ChatbotService, ChatbotApiService, ChatbotSettingsSubscriber], | ||
| providers: [ | ||
| ChatbotService, | ||
| ChatbotApiService, | ||
| ChatbotSettingsSubscriber, | ||
| MailService, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh interesting, i guess you didn't need to add |
||
| ], | ||
| }; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh neat I didn't know you could use the spread operator when deconstructing an object