Skip to content

Commit 121f29a

Browse files
committed
feat(root): use JSX syntax for agent Card components
Switch support-agent from function-call API to JSX with per-file @jsxImportSource pragma. Set jsx to react-jsx in tsconfig. Made-with: Cursor
1 parent 0424b09 commit 121f29a

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

packages/novu/src/commands/init/templates/app-agent/ts/README-template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ npm run dev
1212

1313
2. Connect a chat platform in the [Novu Dashboard](https://dashboard.novu.co).
1414

15-
3. Replace the demo handler in `app/novu/agents/support-agent.ts` with your LLM call.
15+
3. Replace the demo handler in `app/novu/agents/support-agent.tsx` with your LLM call.
1616

1717
Your agent is served at `/api/novu` and handles incoming messages via the Novu Bridge protocol.
1818

@@ -23,7 +23,7 @@ app/
2323
api/novu/route.ts → Bridge endpoint serving your agent
2424
novu/agents/
2525
index.ts → Agent exports
26-
support-agent.ts → Your agent handler (edit this!)
26+
support-agent.tsx → Your agent handler (edit this!)
2727
page.tsx → Landing page
2828
```
2929

packages/novu/src/commands/init/templates/app-agent/ts/app/novu/agents/support-agent.ts renamed to packages/novu/src/commands/init/templates/app-agent/ts/app/novu/agents/support-agent.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @jsxImportSource @novu/framework */
12
import { agent, Card, CardText, Actions, Button } from '@novu/framework';
23

34
export const supportAgent = agent('support-agent', {
@@ -8,17 +9,14 @@ export const supportAgent = agent('support-agent', {
89
if (isFirstMessage) {
910
ctx.metadata.set('topic', 'unknown');
1011
await ctx.reply(
11-
Card({
12-
title: "Hi, I'm Support Agent",
13-
children: [
14-
CardText('How can I help you today?'),
15-
Actions([
16-
Button({ id: 'topic-billing', label: 'Billing question', value: 'billing' }),
17-
Button({ id: 'topic-technical', label: 'Technical issue', value: 'technical' }),
18-
Button({ id: 'topic-other', label: 'Something else', value: 'other' }),
19-
]),
20-
],
21-
})
12+
<Card title="Hi, I'm Support Agent">
13+
<CardText>How can I help you today?</CardText>
14+
<Actions>
15+
<Button id="topic-billing" label="Billing question" value="billing" />
16+
<Button id="topic-technical" label="Technical issue" value="technical" />
17+
<Button id="topic-other" label="Something else" value="other" />
18+
</Actions>
19+
</Card>
2220
);
2321

2422
return;

packages/novu/src/commands/init/templates/app-agent/ts/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function Home() {
1313
<h2>Get started</h2>
1414
<ol>
1515
<li>
16-
Edit your agent in <code className={styles.code}>app/novu/agents/support-agent.ts</code>
16+
Edit your agent in <code className={styles.code}>app/novu/agents/support-agent.tsx</code>
1717
</li>
1818
<li>
1919
Connect a chat platform in the{' '}

packages/novu/src/commands/init/templates/app-agent/ts/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"moduleResolution": "bundler",
1111
"resolveJsonModule": true,
1212
"isolatedModules": true,
13-
"jsx": "preserve",
13+
"jsx": "react-jsx",
1414
"incremental": true,
1515
"plugins": [
1616
{

0 commit comments

Comments
 (0)