Use voice notifications or voice captchas using an API

Updated at:

Voice notifications and voice captchas are sent as phone calls to specified numbers. You can call API operations to send voice notifications or voice captchas.

Usage notes

  • Use text-to-speech (TTS) templates and voice notification files only after they are approved.

  • For the same combination of qualification information and number purpose, the following throttling limits apply to calls made to the same number: 1 call per minute, 5 calls per hour, and 20 calls per 24 hours. The 24-hour period starts from the first successful call. Use this feature responsibly. For more information about throttling, see Throttling rules.

Preparations

Workflow

image

Step 1: Prepare the call content

Important

When you upload a voice file using an API, the exclusive pattern is used by default. If you plan to use the common pattern to initiate a voice call using an API, go to the Voice Service console to apply for call content. For more information, see Create a voice template.

Call content includes TTS templates and voice files. You must apply for call content and wait for it to be approved before you can initiate voice calls. You can apply for content and query the review status in the console.

  • TTS templates: You cannot create TTS templates by calling an API operation. You must create them in the Voice Service console. For more information, see Create a voice template.

  • Voice files: You can upload voice files using an API, a software development kit (SDK), or the console. For more information about how to upload files using an API or an SDK, see Upload a voice file using an API.

    Note

    After you upload a voice file, you can call the QueryVoiceFileAuditInfo operation to query the review status. If the file fails the review, check the failure reason and upload the file again.

Step 2: Initiate a voice call

Based on your requirements, call the appropriate API operation to send a voice notification or a voice captcha. Before you call the operation, carefully read the parameter descriptions.

General API operations

API operations for the exclusive pattern only

  • SingleCallByVoice: Sends a voice notification from a voice notification file to a specified number.

  • SingleCallByTts: Sends a voice captcha or a text-to-speech (TTS) voice notification to a specified number.

  1. Create a voice call task - CreateCallTask: Creates TTS, voice notification, and voice captcha tasks for multiple called numbers using a service instance.

  2. Execute a voice call task - ExecuteCallTask: Starts a voice call task that you created.

Step 3: Query call details

General API operations

API operations for the exclusive pattern only

  • Use an API operation: Call the QueryCallDetailByCallId operation. Use the CallId returned in Step 2 to query the details of the sent voice notification or voice captcha.

  • Use receipt messages: You can use a message queue or the HTTP batch push mode to receive call records and status information from Voice Service. For more information, see Introduction to receipt messages and configuration flow.

ListCallTaskDetail: Use the task ID that is returned in Step 2 to view the details for the specified task.

References