Skip to content

Send widget voice recordings to topics as voice messages - #108

Open
mysubcult wants to merge 1 commit into
LiveHelperChat:masterfrom
mysubcult:feat/widget-voice-as-voice
Open

mysubcult wants to merge 1 commit into
LiveHelperChat:masterfrom
mysubcult:feat/widget-voice-as-voice

Conversation

@mysubcult

Copy link
Copy Markdown
Contributor

Problem. A voice message recorded in the chat widget is uploaded as record.mp3, so the operator gets it in the Telegram topic through sendAudio — as a music file with a player and a file name, not as a voice message.

Change.

  • Files uploaded by the widget's voice recorder (record.mp3, audio/mpeg) are sent with sendVoice (Bot API accepts OGG/Opus, MP3 and M4A there).
  • Optional voice_record.convert_command ({file_orig}, {file_dest}) makes an OGG/Opus copy first, so the message looks like one recorded in Telegram. Example in settings.ini.default.php: ffmpeg -nostdin -loglevel error -y -i {file_orig} -c:a libopus -b:a 64k -ac 1 -application voip {file_dest}. Empty by default — the MP3 is sent as it is.
  • The copy lives in a temporary directory and is removed right after the upload handle is opened; the chat file is not changed.
  • If Telegram refuses sendVoice, the recording is sent with sendAudio as before.
  • voice_record.send_as_voice => false keeps the old behaviour.

How to check.

  1. Enable visitor voice messages (Settings → Files → sound messages), open a chat in a department with a Telegram operator topic.
  2. Record and send a voice message in the widget.
  3. Before: an audio file record.mp3 in the topic. After: a voice message (with convert_command set — waveform, speed, transcription like a native one).

🤖 Generated with Claude Code

The widget uploads a recorded voice message as record.mp3, so operators got it
in the topic as an audio file (sendAudio). It is now sent with sendVoice;
with voice_record.convert_command set (e.g. ffmpeg to OGG/Opus) a converted
copy is uploaded, otherwise the MP3 itself. A refused sendVoice falls back to
sendAudio. The chat file is not changed.
mysubcult added a commit to mysubcult/telegram that referenced this pull request Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant