Goal:
Show how to use Elevenlabs to convert text messages into voice messages to make interactions with AI agents more natural and fun.
Scope of application:
This approach is suitable for anyone who wants to revitalize communication with users through AI bots by adding voice responses instead of text ones. It is especially useful for businesses that use chatbots in messengers to improve the user experience.
Tools:
Go to n8n and create automation, or go to your own one you're working on
Add a node HTTP
Open it and go to settings:
Choose a method POST
In the URL section, type: https://api.elevenlabs.io/v1/text-to-speech/ + The ID of the voice you need, for example https://api.elevenlabs.io/v1/text-to-speech/0BcDz9UPwL3MpsnTeUlO
To select the voice you need, go to Elevenlabs in the library section and there will be a +Add button to the right of the voice, after clicking on it, the voice will be added to your My Voices section
In My Voices, to the right of the voice, click View
And copy the ID
Then in n8n:
Activate Send Headers
Create two fields with parameters
and fill them out like this:
1 Name: Content-type
Value: application/json
2 Name: xi-api-key
Value: (Your API key)
To find the API key, go back to Elevenlabs
Click on My Account and select API Keys
And click Create API Key
Copy the key and paste it into the node parameter in n8n
Then activate Send Body
Body content type et Specify body leave it as it is.
Now create two parameters as well
1 Name: text
Value: {{$json.output}} or use Schema mode to add output data from the node you need by dragging and dropping the data block
2 Name: model_id
Value: eleven_multilingual_v2
As a result, the HTTP Request block should look like this:
Next is the next block after HTTP. Create, for example, Telegram and select the SendAudio action
Connect credentials, insert your chat ID and set up the block to receive binary data.
To do this, turn on the slider Binary file
And in Input Binary Field: data (the name of the binary file that you will receive after processing by Elevenlabs, usually data)
Also, in Additional Fields, click on Add Field and choose File name
In this field, enter the full name of the binary file along with its format, namely data.mpeg
It's done.
Now I will be sending audio messages to Telegram. You can also integrate any other messenger supported by n8n.