# Upload file to Telegram

**URL:** https://forum.rasa.com/t/upload-file-to-telegram/9363
**Category:** Rasa Open Source
**Created:** [May 6, 2019, 6:02am UTC](https://forum.rasa.com/t/upload-file-to-telegram/9363 "2019-05-06T06:02:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![itsecstudy](https://avatars.discourse-cdn.com/v4/letter/i/a587f6/32.png) [@itsecstudy](https://forum.rasa.com/u/itsecstudy)
#### Post date: [May 6, 2019, 6:02am UTC](https://forum.rasa.com/t/upload-file-to-telegram/9363/1 "2019-05-06T06:02:42Z")

</div>

Hi,

I would like to use my telegram bot to provide capability for the user to upload a file via Telegram and then have RASA upload the file to an external system via an existing API they provide.

Can I check if this is possible and also how best to approach this?

Example would be

user: I would like to upload a file BOT: Sure please upload file User: Action uploads file via Telegram BOT: Receives file and uploads to external API and then return results to user.

I am happy for the file to reside on the local file system if this is a requirement or use Telegram to upload the file directly to the target API, I am just not entirely sure how to approach this. Any advice would be much appreciated.

Thanks

---

<div class="post-metadata">

### Author: ![custodio](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/custodio/32/520_2.png) [@custodio](https://forum.rasa.com/u/custodio)
#### Post date: [May 14, 2019, 7:27pm UTC](https://forum.rasa.com/t/upload-file-to-telegram/9363/2 "2019-05-14T19:27:59Z")

</div>

Hi @itsecstudy,

I made something similar to the facebook channel. But I had to change the facebook channel on rasa\_core a little bit. You probably could do something similar to telegram.

What I did was: In facebook when you send a file or image facebook will send a webhook with this parameters:

```
 "attachments": [
      {
        "type": "<image|video|audio|file>",
        "payload": {
          "url": "<ATTACHMENT_URL>"
        }
      }
    ]

```

So in the facebook channel on the message method, here is the current code of the current version:

```
    async def message(self, message: Dict[Text, Any]) -> None:
    """Handle an incoming event from the fb webhook."""

    if self._is_user_message(message):
        text = message["message"]["text"]
    elif self._is_audio_message(message):
        attachment = message["message"]["attachments"][0]
        text = attachment["payload"]["url"]
    else:
        logger.warning(
            "Received a message from facebook that we can not "
            "handle. Message: {}".format(message)
        )
        return

    await self._handle_user_message(text, self.get_user_id())

```

I added a new static method to the channel, for exemplo, “self.\_is\_file”. And if this method returned true. Instead of sending to the bot:

```
await self._handle_user_message(text, self.get_user_id())

```

You would send:

```
await self._handle_user_message('/file_msg{"url": THE_URL_HERE}', self.get_user_id())

```

So in my bot I have an intent called “file\_msg” and you execute a custom action that would get the URL and send the URL or file to whatever api you want to.

Regards,

---

<div class="post-metadata">

### Author: ![Shark](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/shark/32/14536_2.png) [@Shark](https://forum.rasa.com/u/Shark)
#### Post date: [June 9, 2021, 1:03am UTC](https://forum.rasa.com/t/upload-file-to-telegram/9363/3 "2021-06-09T01:03:15Z")

</div>

Hi @custodio

Do you mind sharing your action server code where you accept video or file? I am trying to so something similar but I am not sure how to get file in action server
