call-me-cloud-mcp 1.0.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +79 -4
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -116,6 +116,20 @@ async function main() {
|
|
|
116
116
|
required: ['call_id', 'message'],
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
|
+
{
|
|
120
|
+
name: 'send_message',
|
|
121
|
+
description: 'Send a WhatsApp message to the user. Use when a phone call is not appropriate or when the user prefers text. Waits for user response.',
|
|
122
|
+
inputSchema: {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties: {
|
|
125
|
+
message: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
description: 'The message to send via WhatsApp.',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
required: ['message'],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
119
133
|
],
|
|
120
134
|
};
|
|
121
135
|
});
|
|
@@ -125,22 +139,71 @@ async function main() {
|
|
|
125
139
|
try {
|
|
126
140
|
if (request.params.name === 'initiate_call') {
|
|
127
141
|
const { message } = request.params.arguments as { message: string };
|
|
128
|
-
const result = await apiCall('/api/call', { message }) as {
|
|
142
|
+
const result = await apiCall('/api/call', { message }) as {
|
|
143
|
+
callId: string;
|
|
144
|
+
response: string;
|
|
145
|
+
contactMode?: 'voice' | 'whatsapp';
|
|
146
|
+
whatsappSessionWindow?: {
|
|
147
|
+
expiresAt: number;
|
|
148
|
+
minutesRemaining: number;
|
|
149
|
+
status: 'active' | 'expiring_soon' | 'expired';
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
let responseText = `Call initiated successfully.\n\nCall ID: ${result.callId}`;
|
|
154
|
+
|
|
155
|
+
// Add contact mode information if present
|
|
156
|
+
if (result.contactMode) {
|
|
157
|
+
responseText += `\nContact mode: ${result.contactMode}`;
|
|
158
|
+
|
|
159
|
+
// Add WhatsApp session window info if in WhatsApp mode
|
|
160
|
+
if (result.contactMode === 'whatsapp' && result.whatsappSessionWindow) {
|
|
161
|
+
const { minutesRemaining, status } = result.whatsappSessionWindow;
|
|
162
|
+
responseText += `\nWhatsApp session: ${Math.round(minutesRemaining)} minutes remaining`;
|
|
163
|
+
|
|
164
|
+
if (status === 'expiring_soon') {
|
|
165
|
+
responseText += ` (expires soon - switch to template messages after expiry)`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
responseText += `\n\nUser's response:\n${result.response}\n\nUse continue_call to ask follow-ups or end_call to hang up.`;
|
|
129
171
|
|
|
130
172
|
return {
|
|
131
173
|
content: [{
|
|
132
174
|
type: 'text',
|
|
133
|
-
text:
|
|
175
|
+
text: responseText,
|
|
134
176
|
}],
|
|
135
177
|
};
|
|
136
178
|
}
|
|
137
179
|
|
|
138
180
|
if (request.params.name === 'continue_call') {
|
|
139
181
|
const { call_id, message } = request.params.arguments as { call_id: string; message: string };
|
|
140
|
-
const result = await apiCall(`/api/call/${call_id}/continue`, { message }) as {
|
|
182
|
+
const result = await apiCall(`/api/call/${call_id}/continue`, { message }) as {
|
|
183
|
+
response: string;
|
|
184
|
+
contactMode?: 'voice' | 'whatsapp';
|
|
185
|
+
whatsappSessionWindow?: {
|
|
186
|
+
expiresAt: number;
|
|
187
|
+
minutesRemaining: number;
|
|
188
|
+
status: 'active' | 'expiring_soon' | 'expired';
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
let responseText = `User's response:\n${result.response}`;
|
|
193
|
+
|
|
194
|
+
// Add WhatsApp session window warning if expiring soon
|
|
195
|
+
if (result.contactMode === 'whatsapp' && result.whatsappSessionWindow) {
|
|
196
|
+
const { minutesRemaining, status } = result.whatsappSessionWindow;
|
|
197
|
+
|
|
198
|
+
if (status === 'expiring_soon') {
|
|
199
|
+
responseText += `\n\n⚠️ WhatsApp session expiring in ${Math.round(minutesRemaining)} minutes. Consider wrapping up or asking user to reply to extend window.`;
|
|
200
|
+
} else if (status === 'expired') {
|
|
201
|
+
responseText += `\n\n⚠️ WhatsApp session expired. Future messages require approved templates.`;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
141
204
|
|
|
142
205
|
return {
|
|
143
|
-
content: [{ type: 'text', text:
|
|
206
|
+
content: [{ type: 'text', text: responseText }],
|
|
144
207
|
};
|
|
145
208
|
}
|
|
146
209
|
|
|
@@ -162,6 +225,18 @@ async function main() {
|
|
|
162
225
|
};
|
|
163
226
|
}
|
|
164
227
|
|
|
228
|
+
if (request.params.name === 'send_message') {
|
|
229
|
+
const { message } = request.params.arguments as { message: string };
|
|
230
|
+
const result = await apiCall('/api/message', { message }) as { messageId: string; response: string };
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
content: [{
|
|
234
|
+
type: 'text',
|
|
235
|
+
text: `WhatsApp message sent.\n\nMessage ID: ${result.messageId}\n\nUser's response:\n${result.response}`,
|
|
236
|
+
}],
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
165
240
|
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
166
241
|
} catch (error) {
|
|
167
242
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|