@daolmedo/openclaw-twilio-whatsapp 1.1.13 → 1.1.16

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.
Files changed (2) hide show
  1. package/dist/index.js +25 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -194,8 +194,11 @@ var twilioWhatsappPlugin = {
194
194
  };
195
195
 
196
196
  // src/http-routes.ts
197
+ import { readFile } from "node:fs/promises";
198
+ import path from "node:path";
197
199
  import { dispatchInboundDirectDmWithRuntime } from "openclaw/plugin-sdk/direct-dm";
198
200
  import { saveMediaBuffer } from "openclaw/plugin-sdk/media-runtime";
201
+ import { transcribeOpenAiCompatibleAudio } from "openclaw/plugin-sdk/media-understanding";
199
202
 
200
203
  // src/webhook.ts
201
204
  import twilio2 from "twilio";
@@ -375,10 +378,29 @@ function registerTwilioWhatsappHttpRoutes(api) {
375
378
  const firstAudio = resolvedMedia.find((m) => m.contentType.startsWith("audio/"));
376
379
  if (firstAudio) {
377
380
  try {
378
- const { text } = await api.runtime.mediaUnderstanding.transcribeAudioFile({
379
- filePath: firstAudio.path,
381
+ const cfgAny = stored.cfg;
382
+ const agentId = cfgAny.bindings?.find(
383
+ (b) => b.match?.channel === "twilio-whatsapp" && b.match?.accountId === stored.accountId
384
+ )?.agentId;
385
+ const agentDir = cfgAny.agents?.list?.find(
386
+ (a) => a.id === agentId
387
+ )?.agentDir;
388
+ const auth = await api.runtime.modelAuth.resolveApiKeyForProvider({
389
+ provider: "openai",
380
390
  cfg: api.config,
381
- mime: firstAudio.contentType
391
+ agentDir
392
+ });
393
+ if (!auth.apiKey) throw new Error("No OpenAI API key available for audio transcription");
394
+ const audioBuffer = await readFile(firstAudio.path);
395
+ const { text } = await transcribeOpenAiCompatibleAudio({
396
+ buffer: audioBuffer,
397
+ fileName: path.basename(firstAudio.path),
398
+ mime: firstAudio.contentType,
399
+ apiKey: auth.apiKey,
400
+ model: "gpt-4o-mini-transcribe",
401
+ defaultBaseUrl: "https://api.openai.com/v1",
402
+ defaultModel: "gpt-4o-mini-transcribe",
403
+ timeoutMs: 12e4
382
404
  });
383
405
  console.log("[twilio-whatsapp] Transcription result:", text);
384
406
  bodyForAgent = text || messageText || "<media:audio>";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daolmedo/openclaw-twilio-whatsapp",
3
- "version": "1.1.13",
3
+ "version": "1.1.16",
4
4
  "description": "Twilio WhatsApp channel plugin for OpenClaw (Cody ISV)",
5
5
  "type": "module",
6
6
  "exports": {