Trouble sending audio from Telegram to Replicate API

I know there’s been mentions of an issue with sending both binary and json data with HTTP request, but I’m not sure if that’s still an issue or not. There are lots of mentions of a new HTTP request node coming, but I’m not sure where the release notes exist etc.

Describe the issue/error/question

Trying to send an audio file from Telegram to Whisper hosted on for transcription.

What is the error message (if any)?

    "body": {
      "detail": "Failed to parse request body as JSON: invalid character 'O' looking for beginning of value"
    "headers": {
      "date": "Mon, 30 Jan 2023 10:30:14 GMT",
      "content-type": "application/json",
      "content-length": "104",
      "connection": "close",
      "via": "1.1 google",
      "cf-cache-status": "DYNAMIC",
      "report-to": "{\"endpoints\":[{\"url\":\"https:\\/\\/\\/report\\/v3?s=4VSknP%2FrLO6uFyylO7wMXIx91Dr9zz%2FwjIhRO1IicLKZqmDvVmGCdlm8oOf%2Fd%2BdDSQ1m6BbpLSJioBwihH7El5JUlRJ6iuuvRRTOj3Q4Y37kasMYVvPo%2Frhtmz12uF1Alw0S\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
      "nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
      "strict-transport-security": "max-age=15552000",
      "server": "cloudflare",
      "cf-ray": "791987f5bd56ec8c-SEA"
    "statusCode": 400,
    "statusMessage": "Bad Request"

Please share the workflow

Share the output returned by the last node

Didn’t get that far.

Information on your n8n setup

  • **n8n version:0.212.1
  • **Database you’re using (default: SQLite):Postgres
  • Running n8n with the execution process [own(default), main]:
  • **Running n8n via [Docker, npm,, desktop app]:Docker on Railway

Hey @smellsworth,

That looks like the API you are talking to might be having a hard time with what you are sending, Looking at the API docs quickly I couldn’t see anything for sending a file but I did see that they expect JSON to be send

  "version": "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
  "input": {
    "text": "Alice"

I suspect if they support binary data being sent you would need to send something like…

  "version": "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
  "input": {
    "file": binary-data-here

But that would depend on the API.

1 Like

Thanks Jon, I’m using this whisper model: openai/whisper – API reference

Based on what I’m seeing on that page, I thought they are expecting an actual file:
CleanShot 2023-02-01 at 09.17.05

But based on the Docker example, it looks like they are expecting a URL to file.

curl http://localhost:5000/predictions -X POST -H "Content-Type: application/json" \
  -d '{"input": {
    "audio": "https://url/to/file",
    "model": "...",
    "transcription": "...",
    "translate": "...",
    "language": "...",
    "temperature": "...",
    "patience": "...",
    "suppress_tokens": "...",
    "initial_prompt": "...",
    "condition_on_previous_text": "...",
    "temperature_increment_on_fallback": "...",
    "compression_ratio_threshold": "...",
    "logprob_threshold": "...",
    "no_speech_threshold": "..."

Is it possible for me to pass a URL from downloading the file with the Telegram get:file node?

Hey @smellsworth,

It doesn’t look like Telegram returns a public URL so you might need to upload the file to temporary storage somewhere like S3 then pass that URL to the service and delete the file.

1 Like

Got it. Theoretically, if I saved a file to the n8n file system, e.g. write a spreadsheet file etc. Is there a way to get the file URL at that point? Maybe one of the js expressions?

Just to close this loop, I figured out how to make it work using data URLs instead of having to host the file somewhere. If anyone else ends up struggling with this, here you go:

  1. Get file from Telegram Node, with download true.
  2. Move Binary Data to JSON
  3. Then use data URLs to send to Replicate with the HTTP Request Node
    CleanShot 2023-02-13 at 12.04.40
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.