@daolmedo/openclaw-twilio-whatsapp 1.1.6 → 1.1.7
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/dist/index.js +20 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -176,9 +176,8 @@ var twilioWhatsappPlugin = {
|
|
|
176
176
|
|
|
177
177
|
// src/http-routes.ts
|
|
178
178
|
import { dispatchInboundDirectDmWithRuntime } from "openclaw/plugin-sdk/direct-dm";
|
|
179
|
-
import {
|
|
180
|
-
|
|
181
|
-
} from "openclaw/plugin-sdk/media-runtime";
|
|
179
|
+
import { saveMediaBuffer } from "openclaw/plugin-sdk/media-runtime";
|
|
180
|
+
import { transcribeFirstAudio } from "openclaw/plugin-sdk/media-understanding";
|
|
182
181
|
|
|
183
182
|
// src/webhook.ts
|
|
184
183
|
import twilio2 from "twilio";
|
|
@@ -354,6 +353,23 @@ function registerTwilioWhatsappHttpRoutes(api) {
|
|
|
354
353
|
MediaUrls: resolvedMedia.map((m) => m.path),
|
|
355
354
|
MediaTypes: resolvedMedia.map((m) => m.contentType)
|
|
356
355
|
} : {};
|
|
356
|
+
let bodyForAgent = messageText || void 0;
|
|
357
|
+
const hasAudio = resolvedMedia.some((m) => m.contentType.startsWith("audio/"));
|
|
358
|
+
if (hasAudio) {
|
|
359
|
+
try {
|
|
360
|
+
const transcript = await transcribeFirstAudio({
|
|
361
|
+
ctx: {
|
|
362
|
+
MediaPaths: resolvedMedia.map((m) => m.path),
|
|
363
|
+
MediaTypes: resolvedMedia.map((m) => m.contentType)
|
|
364
|
+
},
|
|
365
|
+
cfg: stored.cfg
|
|
366
|
+
});
|
|
367
|
+
bodyForAgent = transcript || messageText || "<media:audio>";
|
|
368
|
+
} catch (err) {
|
|
369
|
+
console.error("[twilio-whatsapp] Audio transcription failed:", err);
|
|
370
|
+
bodyForAgent = messageText || "<media:audio>";
|
|
371
|
+
}
|
|
372
|
+
}
|
|
357
373
|
const stopTyping = fields.messageSid ? startTypingKeepalive({
|
|
358
374
|
accountSid: account.accountSid,
|
|
359
375
|
authToken: account.authToken,
|
|
@@ -372,7 +388,7 @@ function registerTwilioWhatsappHttpRoutes(api) {
|
|
|
372
388
|
recipientAddress,
|
|
373
389
|
conversationLabel,
|
|
374
390
|
rawBody: messageText,
|
|
375
|
-
bodyForAgent
|
|
391
|
+
bodyForAgent,
|
|
376
392
|
messageId: fields.messageSid,
|
|
377
393
|
timestamp: Date.now(),
|
|
378
394
|
commandAuthorized: true,
|