![]() filter: proxyTelegram # send the request to retrieve file content namespace: extract filter: requestBuilderDownloadFile # Constructing a request to download namespace: extract # the voice file filter: proxyTelegram # send the request to retrieve file path. filter: requestBuilderGetVoiceFile # Constructing a request to convert a alias: processVoice # voice file ID to a path. filter: requestBuilderExtractText alias: processText # alias of the filter namespace: extract # namespace the filter belongs to jumpIf: # conditional jump, begin translation "": translate # if everything is fine, or end the # processing otherwise. Result0: processText # text result1: processVoice # voice result2: processPhoto # photo "": END # ignore, end the processing # text message ![]() filter: buildFinalResponse # detect message type and jump accordingly If we put it at the end, the requests we don't process # will end the process early and no Response will be returned. # we put the final response builder at the top because Telegram requires # us to return a response for every Request, but we only process some of # the requests. Pipelineįirst, let’s check the overall flow that Pipeline orchestrates: Photo Message: Basically, this case is the same as the voice message, but the file content is sent to Google’s Image Annotation service.Īfter the above processing, all three types of messages are turned into text, and then AWS translation service can be called to translate them into target languages, the target languages used in this example are Chinese, Japanese, and English.Voice Message: In this case, the message body only contains the ID of the voice file, so we need to call Telegram’s API to convert the ID to a file address, then download the file and send its contents to Google’s voice recognition service to convert it to text;.Text Message: Extract message text directly;.Upon receiving a notification of a new message from the Telegram server via WebHook, the bot first checks the message type and does the following accordingly: The diagram below shows the workflow of this bot. It is fine for you to use other vendors' translation, speech recognition, or OCR APIs, but this will require you to adapt the examples in the later sections accordingly. Google Cloud’s Token and ensure that you can use Google Cloud’s Speech Recognize API and OCR (Image Annotation) API with this Token. Our bot will receive notifications of new messages through this WebHook.ĪWS Access Key ID and Access Key Secret, and ensure that you can use the AWS translation API with this Access Key. Install the latest version of Easegress according to this document and make sure that external applications can access the Easegress instance on at least one of ports 80, 88, 443, or 8443.Ĭreate a Telegram bot by following this document, set its name ( EaseTranslateBot is used in this article), write down its token, and set up a WebHook that points to the Easegress instance installed in the previous step. Since the bot needs to receive Telegram message notifications and call third-party APIs, we must prepare the following in advance: This bot can automatically translate incoming messages into Chinese, Japanese, and English, and, in addition to text messages, it also supports translating voice and photo messages. This article will demonstrate this feature by building a Telegram translation bot. We released Easegress v2.0 recently, with another significant enhancement to traffic orchestration, allowing users to implement a super API by orchestrating multiple APIs without writing any code. ![]() It is completely architected on top of cloud-native technology, avoiding the shortcomings of traditional reverse proxy in terms of high availability, traffic orchestration, monitoring, service discovery, etc. Easegress is the next-generation traffic-based gateway product developed by MegaEase. ![]()
0 Comments
Leave a Reply. |