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.
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:
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:
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.
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