create-message-kit 1.2.4 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/index.js +40 -27
  2. package/package.json +2 -3
  3. package/templates/agent/.cursorrules +227 -0
  4. package/templates/agent/src/index.ts +16 -25
  5. package/templates/agent/src/prompt.ts +1 -1
  6. package/templates/agent/src/{handlers → skills}/check.ts +5 -4
  7. package/templates/agent/src/{handlers → skills}/cool.ts +1 -1
  8. package/templates/agent/src/{handlers → skills}/info.ts +6 -5
  9. package/templates/agent/src/{handlers → skills}/pay.ts +20 -5
  10. package/templates/agent/src/{handlers → skills}/register.ts +2 -3
  11. package/templates/agent/src/{handlers → skills}/renew.ts +5 -4
  12. package/templates/agent/src/skills/reset.ts +26 -0
  13. package/templates/experimental/.cursorrules +227 -0
  14. package/templates/experimental/.env.example +2 -0
  15. package/templates/{gated → experimental}/package.json +6 -4
  16. package/templates/experimental/src/index.ts +53 -0
  17. package/templates/{gated/src/lib/nft.ts → experimental/src/lib/alchemy.ts} +7 -13
  18. package/templates/experimental/src/lib/minilog.ts +26 -0
  19. package/templates/experimental/src/lib/xmtp.ts +136 -0
  20. package/templates/experimental/src/prompt.ts +24 -0
  21. package/templates/experimental/src/skills/broadcast.ts +39 -0
  22. package/templates/experimental/src/skills/gated.ts +89 -0
  23. package/templates/{agent/src/handlers → experimental/src/skills}/todo.ts +11 -5
  24. package/templates/{agent/src/handlers → experimental/src/skills}/token.ts +1 -1
  25. package/templates/experimental/src/skills/wordle.ts +97 -0
  26. package/templates/gpt/.cursorrules +227 -0
  27. package/templates/gpt/src/index.ts +1 -0
  28. package/templates/agent/src/handlers/game.ts +0 -58
  29. package/templates/agent/src/handlers/reset.ts +0 -19
  30. package/templates/gated/.env.example +0 -3
  31. package/templates/gated/src/index.ts +0 -64
  32. package/templates/gated/src/lib/gated.ts +0 -51
  33. package/templates/gated/src/skills.ts +0 -23
  34. /package/templates/{gated → experimental}/.yarnrc.yml +0 -0
@@ -0,0 +1,227 @@
1
+ # MessageKit Skill Template
2
+
3
+ ## Examples
4
+
5
+ ### Check if a Domain is Available
6
+
7
+ ```typescript
8
+ import { ensUrl } from "../index.js";
9
+ import { XMTPContext } from "@xmtp/message-kit";
10
+ import type { Skill } from "@xmtp/message-kit";
11
+
12
+ // Define Skill
13
+ export const checkDomain: Skill[] = [
14
+ {
15
+ skill: "/check [domain]",
16
+ handler: handler,
17
+ examples: ["/check vitalik.eth", "/check fabri.base.eth"],
18
+ description: "Check if a domain is available.",
19
+ params: {
20
+ domain: {
21
+ type: "string",
22
+ },
23
+ },
24
+ },
25
+ ];
26
+
27
+ // Handler Implementation
28
+ export async function handler(context: XMTPContext) {
29
+ const {
30
+ message: {
31
+ content: {
32
+ params: { domain },
33
+ },
34
+ },
35
+ } = context;
36
+
37
+ const data = await context.getUserInfo(domain);
38
+
39
+ if (!data?.address) {
40
+ let message = `Looks like ${domain} is available! Here you can register it: ${ensUrl}${domain} or would you like to see some cool alternatives?`;
41
+ return {
42
+ code: 200,
43
+ message,
44
+ };
45
+ } else {
46
+ let message = `Looks like ${domain} is already registered!`;
47
+ await context.executeSkill("/cool " + domain);
48
+ return {
49
+ code: 404,
50
+ message,
51
+ };
52
+ }
53
+ }
54
+
55
+ ### Generate a payment request
56
+
57
+ ```typescript
58
+ import { XMTPContext } from "@xmtp/message-kit";
59
+ import type { Skill } from "@xmtp/message-kit";
60
+
61
+ // Define Skill
62
+ export const paymentRequest: Skill[] = [
63
+ {
64
+ skill: "/pay [amount] [token] [username] [address]",
65
+ examples: [
66
+ "/pay 10 vitalik.eth",
67
+ "/pay 1 usdc to 0xc9925662D36DE3e1bF0fD64e779B2e5F0Aead964",
68
+ ],
69
+ description:
70
+ "Send a specified amount of a cryptocurrency to a destination address. \nWhen tipping, you can assume it's 1 USDC.",
71
+ handler: handler,
72
+ params: {
73
+ amount: {
74
+ default: 10,
75
+ type: "number",
76
+ },
77
+ token: {
78
+ default: "usdc",
79
+ type: "string",
80
+ values: ["eth", "dai", "usdc", "degen"], // Accepted tokens
81
+ },
82
+ username: {
83
+ default: "",
84
+ type: "username",
85
+ },
86
+ address: {
87
+ default: "",
88
+ type: "address",
89
+ },
90
+ },
91
+ },
92
+ ];
93
+
94
+ // Handler Implementation
95
+ export async function handler(context: XMTPContext) {
96
+ const {
97
+ message: {
98
+ content: {
99
+ params: { amount, token, username, address },
100
+ },
101
+ },
102
+ } = context;
103
+ let receiverAddress = address;
104
+ if (username) {
105
+ receiverAddress = (await context.getUserInfo(username))?.address;
106
+ }
107
+ if (address) {
108
+ // Prioritize address over username
109
+ receiverAddress = address;
110
+ }
111
+
112
+ await context.requestPayment(amount, token, receiverAddress);
113
+ }
114
+ ```
115
+
116
+
117
+ ## Types
118
+
119
+ ```typescript
120
+ import { XMTPContext } from "../lib/xmtp.js";
121
+ import { ClientOptions, GroupMember } from "@xmtp/node-sdk";
122
+ import { ContentTypeId } from "@xmtp/content-type-primitives";
123
+
124
+ export type MessageAbstracted = {
125
+ id: string;
126
+ sent: Date;
127
+ content: {
128
+ text?: string | undefined;
129
+ reply?: string | undefined;
130
+ previousMsg?: string | undefined;
131
+ react?: string | undefined;
132
+ content?: any | undefined;
133
+ params?: any | undefined;
134
+ reference?: string | undefined;
135
+ skill?: string | undefined;
136
+ };
137
+ version: "v2" | "v3";
138
+ sender: AbstractedMember;
139
+ typeId: string;
140
+ };
141
+ export type GroupAbstracted = {
142
+ id: string;
143
+ sync: () => Promise<void>;
144
+ addMembers: (addresses: string[]) => Promise<void>;
145
+ addMembersByInboxId: (inboxIds: string[]) => Promise<void>;
146
+ send: (content: string, contentType?: ContentTypeId) => Promise<string>;
147
+ isAdmin: (inboxId: string) => boolean;
148
+ isSuperAdmin: (inboxId: string) => boolean;
149
+ admins: string[];
150
+ superAdmins: string[];
151
+ createdAt: Date;
152
+ members: GroupMember[];
153
+ };
154
+ export type SkillResponse = {
155
+ code: number;
156
+ message: string;
157
+ data?: any;
158
+ };
159
+
160
+ export type SkillHandler = (
161
+ context: XMTPContext,
162
+ ) => Promise<SkillResponse | void>;
163
+
164
+ export type Handler = (context: XMTPContext) => Promise<void>;
165
+
166
+ export type RunConfig = {
167
+ // client options from XMTP client
168
+ client?: ClientOptions;
169
+ // private key to be used for the client, if not, default from env
170
+ privateKey?: string;
171
+ // if true, the init log message with messagekit logo and stuff will be hidden
172
+ experimental?: boolean;
173
+ // hide the init log message with messagekit logo and stuff
174
+ hideInitLogMessage?: boolean;
175
+ // if true, attachments will be enabled
176
+ attachments?: boolean;
177
+ // if true, member changes will be enabled, like adding members to the group
178
+ memberChange?: boolean;
179
+ // skills to be used
180
+ agent?: Agent;
181
+ // model to be used
182
+ gptModel?: string;
183
+ };
184
+ export interface SkillParamConfig {
185
+ default?: string | number | boolean;
186
+ type:
187
+ | "number"
188
+ | "string"
189
+ | "username"
190
+ | "quoted"
191
+ | "address"
192
+ | "prompt"
193
+ | "url";
194
+ plural?: boolean;
195
+ values?: string[]; // Accepted values for the parameter
196
+ }
197
+
198
+ export interface Frame {
199
+ title: string;
200
+ buttons: { content: string; action: string; target: string }[];
201
+ image: string;
202
+ }
203
+ export interface Agent {
204
+ name: string;
205
+ description: string;
206
+ tag: string;
207
+ skills: Skill[];
208
+ }
209
+ export interface Skill {
210
+ skill: string;
211
+ handler?: SkillHandler | undefined;
212
+ adminOnly?: boolean;
213
+ description: string;
214
+ examples: string[];
215
+ params: Record<string, SkillParamConfig>;
216
+ }
217
+
218
+ export interface AbstractedMember {
219
+ inboxId: string;
220
+ address: string;
221
+ accountAddresses: string[];
222
+ installationIds?: string[];
223
+ }
224
+
225
+ export type MetadataValue = string | number | boolean;
226
+ export type Metadata = Record<string, MetadataValue | MetadataValue[]>;
227
+ ```
@@ -0,0 +1,2 @@
1
+ KEY= # the private key of the wallet
2
+ OPENAI_API_KEY= # sk-proj-...
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "gated",
2
+ "name": "experimental",
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "scripts": {
@@ -9,11 +9,13 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@xmtp/message-kit": "workspace:*",
12
- "alchemy-sdk": "^3.4.3",
13
- "express": "^4.19.2"
12
+ "alchemy-sdk": "^3.0.0",
13
+ "express": "^4.19.2",
14
+ "node-fetch": "^3.3.2",
15
+ "resend": "^4.0.1"
14
16
  },
15
17
  "devDependencies": {
16
- "@types/express": "^4",
18
+ "@types/express": "^4.17.20",
17
19
  "@types/node": "^20.14.2",
18
20
  "typescript": "^5.4.5"
19
21
  },
@@ -0,0 +1,53 @@
1
+ import {
2
+ run,
3
+ agentReply,
4
+ replaceVariables,
5
+ XMTPContext,
6
+ Agent,
7
+ xmtpClient,
8
+ V3Client,
9
+ } from "@xmtp/message-kit";
10
+ import fs from "fs";
11
+ import { systemPrompt } from "./prompt.js";
12
+ import { token } from "./skills/token.js";
13
+ import { todo } from "./skills/todo.js";
14
+ import { gated, startGatedGroupServer } from "./skills/gated.js";
15
+ import { broadcast } from "./skills/broadcast.js";
16
+ import { wordle } from "./skills/wordle.js";
17
+
18
+ export const agent: Agent = {
19
+ name: "Experimental Agent",
20
+ tag: "@bot",
21
+ description: "An experimental agent with a lot of skills.",
22
+ skills: [
23
+ ...token,
24
+ ...(process?.env?.RESEND_API_KEY ? todo : []),
25
+ ...(process?.env?.ALCHEMY_SDK ? gated : []),
26
+ ...broadcast,
27
+ ...wordle,
28
+ ],
29
+ };
30
+
31
+ // [!region gated]
32
+ const { client } = await xmtpClient({
33
+ hideInitLogMessage: true,
34
+ });
35
+
36
+ startGatedGroupServer(client);
37
+ // [!endregion gated]
38
+
39
+ run(
40
+ async (context: XMTPContext) => {
41
+ const {
42
+ message: { sender },
43
+ agent,
44
+ } = context;
45
+
46
+ let prompt = await replaceVariables(systemPrompt, sender.address, agent);
47
+
48
+ //This is only used for to update the docs.
49
+ fs.writeFileSync("example_prompt.md", prompt);
50
+ await agentReply(context, prompt);
51
+ },
52
+ { agent },
53
+ );
@@ -5,28 +5,22 @@ const settings = {
5
5
  network: Network.BASE_MAINNET, // Use the appropriate network
6
6
  };
7
7
 
8
- export async function verifiedRequest(
8
+ export async function checkNft(
9
9
  walletAddress: string,
10
- groupId: string
10
+ collectionSlug: string,
11
11
  ): Promise<boolean> {
12
- console.log("new-request", {
13
- groupId,
14
- walletAddress,
15
- });
16
-
17
12
  const alchemy = new Alchemy(settings);
18
13
  try {
19
14
  const nfts = await alchemy.nft.getNftsForOwner(walletAddress);
20
- const collectionSlug = "XMTPeople"; // The slug for the collection
21
15
 
22
16
  const ownsNft = nfts.ownedNfts.some(
23
17
  (nft: any) =>
24
- nft.contract.name.toLowerCase() === collectionSlug.toLowerCase()
25
- );
26
- console.log(
27
- `NFTs owned on ${Network.BASE_MAINNET}:`,
28
- nfts.ownedNfts.length
18
+ nft.contract.name.toLowerCase() === collectionSlug.toLowerCase(),
29
19
  );
20
+ // console.log(
21
+ // `NFTs owned on ${Network.BASE_MAINNET}:`,
22
+ // nfts.ownedNfts.length,
23
+ // );
30
24
  console.log("is the nft owned: ", ownsNft);
31
25
  return ownsNft as boolean;
32
26
  } catch (error) {
@@ -0,0 +1,26 @@
1
+ import fetch from "node-fetch";
2
+
3
+ export async function sendLog(title: string, description: string) {
4
+ const response = await fetch("https://api.minilog.dev/v1/logs/testlog", {
5
+ method: "POST",
6
+ headers: {
7
+ "Content-Type": "application/json",
8
+ Authorization: "Bearer pthsm38sccpux5acriqish7isz5inet7q73ef7br",
9
+ },
10
+ body: JSON.stringify({
11
+ application: "myapp-1",
12
+ severity: "DEBUG",
13
+ data: title,
14
+ metadata: {
15
+ title,
16
+ description,
17
+ },
18
+ }),
19
+ });
20
+ console.log(response);
21
+ if (!response.ok) {
22
+ console.error("Failed to send log:", response.statusText);
23
+ } else {
24
+ console.log("Log sent successfully");
25
+ }
26
+ }
@@ -0,0 +1,136 @@
1
+ import { isOnXMTP, V3Client, V2Client } from "@xmtp/message-kit";
2
+
3
+ export async function createGroup(
4
+ client: V3Client,
5
+ senderAddress: string,
6
+ clientAddress: string,
7
+ ) {
8
+ try {
9
+ let senderInboxId = "";
10
+ await client.conversations.sync();
11
+ const conversations = await client.conversations.list();
12
+ console.log("Conversations", conversations.length);
13
+ const group = await client?.conversations.newGroup([
14
+ senderAddress,
15
+ clientAddress,
16
+ ]);
17
+ console.log("Group created", group?.id);
18
+ const members = await group.members();
19
+ const senderMember = members.find((member) =>
20
+ member.accountAddresses.includes(senderAddress.toLowerCase()),
21
+ );
22
+ if (senderMember) {
23
+ senderInboxId = senderMember.inboxId;
24
+ console.log("Sender's inboxId:", senderInboxId);
25
+ } else {
26
+ console.log("Sender not found in members list");
27
+ }
28
+ await group.addSuperAdmin(senderInboxId);
29
+ console.log(
30
+ "Sender is superAdmin",
31
+ await group.isSuperAdmin(senderInboxId),
32
+ );
33
+ await group.send(`Welcome to the new group!`);
34
+ await group.send(`You are now the admin of this group as well as the bot`);
35
+ return group;
36
+ } catch (error) {
37
+ console.log("Error creating group", error);
38
+ return null;
39
+ }
40
+ }
41
+
42
+ export async function removeFromGroup(
43
+ groupId: string,
44
+ client: V3Client,
45
+ v2client: V2Client,
46
+ senderAddress: string,
47
+ ): Promise<{ code: number; message: string }> {
48
+ try {
49
+ let lowerAddress = senderAddress.toLowerCase();
50
+ const { v2, v3 } = await isOnXMTP(client, v2client, lowerAddress);
51
+ console.warn("Checking if on XMTP: v2", v2, "v3", v3);
52
+ if (!v3)
53
+ return {
54
+ code: 400,
55
+ message: "You don't seem to have a v3 identity ",
56
+ };
57
+ const conversation =
58
+ await client.conversations.getConversationById(groupId);
59
+ console.warn("removing from group", conversation?.id);
60
+ await conversation?.sync();
61
+ await conversation?.removeMembers([lowerAddress]);
62
+ console.warn("Removed member from group");
63
+ await conversation?.sync();
64
+ const members = await conversation?.members();
65
+ console.warn("Number of members", members?.length);
66
+
67
+ let wasRemoved = true;
68
+ if (members) {
69
+ for (const member of members) {
70
+ let lowerMemberAddress = member.accountAddresses[0].toLowerCase();
71
+ if (lowerMemberAddress === lowerAddress) {
72
+ wasRemoved = false;
73
+ break;
74
+ }
75
+ }
76
+ }
77
+ return {
78
+ code: wasRemoved ? 200 : 400,
79
+ message: wasRemoved
80
+ ? "You have been removed from the group"
81
+ : "Failed to remove from group",
82
+ };
83
+ } catch (error) {
84
+ console.log("Error removing from group", error);
85
+ return {
86
+ code: 400,
87
+ message: "Failed to remove from group",
88
+ };
89
+ }
90
+ }
91
+ export async function addToGroup(
92
+ groupId: string,
93
+ client: V3Client,
94
+ address: string,
95
+ ): Promise<{ code: number; message: string }> {
96
+ try {
97
+ let lowerAddress = address.toLowerCase();
98
+ const { v2, v3 } = await isOnXMTP(client, null, lowerAddress);
99
+ if (!v3)
100
+ return {
101
+ code: 400,
102
+ message: "You don't seem to have a v3 identity ",
103
+ };
104
+ const group = await client.conversations.getConversationById(groupId);
105
+ console.warn("Adding to group", group?.id);
106
+ await group?.sync();
107
+ //DON'T TOUCH THIS LINE
108
+ await group?.addMembers([lowerAddress]);
109
+ console.warn("Added member to group");
110
+ await group?.sync();
111
+ const members = await group?.members();
112
+ console.warn("Number of members", members?.length);
113
+
114
+ if (members) {
115
+ for (const member of members) {
116
+ let lowerMemberAddress = member.accountAddresses[0].toLowerCase();
117
+ if (lowerMemberAddress === lowerAddress) {
118
+ console.warn("Member exists", lowerMemberAddress);
119
+ return {
120
+ code: 200,
121
+ message: "You have been added to the group",
122
+ };
123
+ }
124
+ }
125
+ }
126
+ return {
127
+ code: 400,
128
+ message: "Failed to add to group",
129
+ };
130
+ } catch (error) {
131
+ return {
132
+ code: 400,
133
+ message: "Failed to add to group",
134
+ };
135
+ }
136
+ }
@@ -0,0 +1,24 @@
1
+ export const systemPrompt = `
2
+ Your are helpful and playful experimental agent called {agent_name} that lives inside a messaging app called Converse.
3
+
4
+ {rules}
5
+
6
+ {user_context}
7
+
8
+ {skills}
9
+
10
+ ## Scenarios
11
+ 1. Missing commands in responses
12
+ **Issue**: Sometimes responses are sent without the required command.
13
+ **Example**:
14
+ Incorrect:
15
+ > "Looks like vitalik.eth is registered! What about these cool alternatives?"
16
+ Correct:
17
+ > "Looks like vitalik.eth is registered! What about these cool alternatives?
18
+ > /cool vitalik.eth"
19
+
20
+ Incorrect:
21
+ > Here is a summary of your TODOs. I will now send it via email.
22
+ Correct:
23
+ > /todo
24
+ `;
@@ -0,0 +1,39 @@
1
+ import { XMTPContext, Skill } from "@xmtp/message-kit";
2
+
3
+ export const broadcast: Skill[] = [
4
+ {
5
+ skill: "/send",
6
+ adminOnly: true,
7
+ handler: handler,
8
+ examples: ["/send Hello everyone, the event is starting now!"],
9
+ description: "Send updates to all subscribers.",
10
+ params: {
11
+ message: {
12
+ type: "prompt",
13
+ },
14
+ },
15
+ },
16
+ ];
17
+
18
+ async function handler(context: XMTPContext) {
19
+ const {
20
+ message: {
21
+ content: {
22
+ params: { message },
23
+ },
24
+ },
25
+ } = context;
26
+
27
+ const fakeSubscribers = ["0x93E2fc3e99dFb1238eB9e0eF2580EFC5809C7204"];
28
+ await context.send("This is how your message will look like:");
29
+ await context.send(message);
30
+ const emailResponse = await context.awaitResponse(
31
+ "Are you sure you want to send this broadcast?\nType 'yes' to confirm.",
32
+ ["yes", "no"],
33
+ );
34
+ if (emailResponse === "yes") {
35
+ await context.send("Sending broadcast...");
36
+ await context.sendTo(message, fakeSubscribers);
37
+ await context.send("Broadcast sent!");
38
+ }
39
+ }
@@ -0,0 +1,89 @@
1
+ import { XMTPContext, Skill, V3Client } from "@xmtp/message-kit";
2
+ import { createGroup } from "../lib/xmtp.js";
3
+ import express from "express";
4
+ import { checkNft } from "../lib/alchemy.js";
5
+ import { addToGroup } from "../lib/xmtp.js";
6
+ export const gated: Skill[] = [
7
+ {
8
+ skill: "/create",
9
+ examples: ["/create"],
10
+ handler: handler,
11
+ adminOnly: true,
12
+ params: {},
13
+ description: "Create a new group.",
14
+ },
15
+ ];
16
+
17
+ async function handler(context: XMTPContext) {
18
+ const {
19
+ message: {
20
+ sender,
21
+ content: { skill },
22
+ },
23
+ client,
24
+ } = context;
25
+
26
+ if (skill === "create") {
27
+ const group = await createGroup(
28
+ client,
29
+ sender.address,
30
+ client.accountAddress,
31
+ );
32
+
33
+ await context.send(
34
+ `Group created!\n- ID: ${group?.id}\n- Group Frame URL: https://converse.xyz/group/${group?.id}: \n- This url will deelink to the group inside Converse\n- Once in the other group you can share the invite with your friends.`,
35
+ );
36
+ return;
37
+ } else {
38
+ await context.send(
39
+ "👋 Welcome to the Gated Bot Group!\nTo get started, type /create to set up a new group. 🚀\nThis example will check if the user has a particular nft and add them to the group if they do.\nOnce your group is created, you'll receive a unique Group ID and URL.\nShare the URL with friends to invite them to join your group!",
40
+ );
41
+ }
42
+ }
43
+
44
+ export function startGatedGroupServer(client: V3Client) {
45
+ async function addWalletToGroup(
46
+ walletAddress: string,
47
+ groupId: string,
48
+ ): Promise<string> {
49
+ const verified = true; //await checkNft(walletAddress, "XMTPeople");
50
+ if (!verified) {
51
+ console.log("User cant be added to the group");
52
+ return "not verified";
53
+ } else {
54
+ try {
55
+ const added = await addToGroup(groupId, client, walletAddress);
56
+ if (added.code === 200) {
57
+ console.log(`Added wallet address: ${walletAddress} to the group`);
58
+ return "success";
59
+ } else {
60
+ return added.message;
61
+ }
62
+ } catch (error: any) {
63
+ console.log(error.message);
64
+ return "error";
65
+ }
66
+ }
67
+ }
68
+
69
+ // Endpoint to add wallet address to a group from an external source
70
+ const app = express();
71
+ app.use(express.json());
72
+ app.post("/add-wallet", async (req, res) => {
73
+ try {
74
+ const { walletAddress, groupId } = req.body;
75
+ const result = await addWalletToGroup(walletAddress, groupId);
76
+ res.status(200).send(result);
77
+ } catch (error: any) {
78
+ res.status(400).send(error.message);
79
+ }
80
+ });
81
+ // Start the servfalcheer
82
+ const PORT = process.env.PORT || 3000;
83
+ const url = process.env.URL || `http://localhost:${PORT}`;
84
+ app.listen(PORT, () => {
85
+ console.warn(
86
+ `Use this endpoint to add a wallet to a group indicated by the groupId\n${url}/add-wallet <body: {walletAddress, groupId}>`,
87
+ );
88
+ });
89
+ }
@@ -4,7 +4,7 @@ import type { Skill } from "@xmtp/message-kit";
4
4
 
5
5
  const resend = new Resend(process.env.RESEND_API_KEY); // Replace with your Resend API key
6
6
 
7
- export const registerSkill: Skill[] = [
7
+ export const todo: Skill[] = [
8
8
  {
9
9
  skill: "/todo",
10
10
  handler: handler,
@@ -30,7 +30,7 @@ export async function handler(context: XMTPContext) {
30
30
  let intents = 2;
31
31
  while (intents > 0) {
32
32
  const emailResponse = await context.awaitResponse(
33
- "Please provide your email address to receive the TODO summary:",
33
+ "Please provide your email address to receive the to-dos summary:",
34
34
  );
35
35
  email = emailResponse;
36
36
 
@@ -52,14 +52,20 @@ export async function handler(context: XMTPContext) {
52
52
  return;
53
53
  }
54
54
  try {
55
- if (typeof previousMsg === "string") {
55
+ let { reply } = await context.textGeneration(
56
+ email,
57
+ "Make this summary concise and to the point to be sent in an email.\n msg: " +
58
+ previousMsg,
59
+ "You are an expert at summarizing to-dos. Return in format html and just the content inside the body tag. Dont return `html` or `body` tags",
60
+ );
61
+ if (typeof reply === "string") {
56
62
  let content = {
57
63
  from: "bot@mail.coin-toss.xyz",
58
64
  to: email,
59
65
  subject: "Your summary from Converse",
60
66
  html: `
61
- <h3>Your TODO Summary</h3>
62
- <p>${previousMsg.replace(/\n/g, "<br>")}</p>
67
+ <h3>Your Converse Summary</h3>
68
+ <p>${reply}</p>
63
69
  `,
64
70
  };
65
71
  await resend.emails.send(content);