You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Nexmo用户验证API中禁用文本转语音功能?

How to Disable Text-to-Speech for Nexmo Verify API

Hey there! To turn off the text-to-speech (TTS) fallback in your Nexmo Verify API request, you just need to specify a workflow ID that limits verification to SMS only. Let's adjust your code to make that happen:

Modified Code

const nexmo = require("./nexmo");
let requestId = null; // Switched to let since we're reassigning this value
module.exports = function sendVerificationCode( recipient ) {
  return new Promise((resolve, reject) => {
    nexmo.verify.request({ 
      number: recipient, 
      brand: 'Verification',
      workflow_id: 1 // This forces SMS-only verification, disabling TTS entirely
    }, function(err, result) {
      if (err) {
        return reject(err); // Properly reject the Promise when an error occurs
      }
      if (result.status === 0) {
        requestId = result.request_id;
        resolve(requestId); // Resolve with the request ID on success
      } else {
        reject(new Error(`Verification request failed: ${result.error_text}`));
      }
    });
  });
};

Key Changes Explained

  • workflow_id: 1: This parameter tells the Nexmo Verify API to use the SMS-only workflow. By default, the API might fall back to TTS if SMS delivery hits issues, but setting this ID ensures only SMS is used—completely disabling the text-to-speech mechanism.
  • Fixed Promise Handling: I updated your Promise logic to properly resolve on success and reject when errors occur or the request returns a non-zero status code. Your original code wasn't triggering these, which could lead to unhandled Promise states.

Quick Workflow ID Reference (For Future Use)

If you ever need to switch verification methods later, here are the common workflow IDs:

  • 1: SMS only (what you need now)
  • 2: TTS only
  • 3: SMS first, then TTS after a delay
  • 4: TTS first, then SMS after a delay

内容的提问来源于stack exchange,提问作者Caren Divinagracia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:58:36