Skip to content

Commit f9eaf1c

Browse files
committed
refactor: type-safe applyFormatting
1 parent 14474ed commit f9eaf1c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/api/integrations/chatbot/typebot/services/typebot.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ import axios from 'axios';
99
import { BaseChatbotService } from '../../base-chatbot.service';
1010
import { OpenaiService } from '../../openai/services/openai.service';
1111

12+
interface RichTextNode {
13+
text?: string;
14+
type?: string;
15+
children?: RichTextNode[];
16+
bold?: boolean;
17+
italic?: boolean;
18+
underline?: boolean;
19+
url?: string;
20+
}
21+
1222
export class TypebotService extends BaseChatbotService<TypebotModel, any> {
1323
private openaiService: OpenaiService;
1424

@@ -196,9 +206,8 @@ export class TypebotService extends BaseChatbotService<TypebotModel, any> {
196206
/**
197207
* Apply rich text formatting for TypeBot messages
198208
*/
199-
private applyFormatting(element: any): string {
200-
if (typeof element === 'string') return element;
201-
if (!element) return '';
209+
private applyFormatting(element: string | RichTextNode | undefined): string {
210+
if (!element || typeof element === 'string') return element || '';
202211

203212
let text = '';
204213

0 commit comments

Comments
 (0)