hi! I can’t seem to send a pdf to (telegram) user via rasa custom action
Can someone please help?
class ActionIACOIForm(Action):
def name(self):
return 'action_IACOI_Form'
def run(self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
bot = Bot(token="62XXXXX0")
file2 = "https://github.com/CKaranD/researchbot/blob/ee1936a2cd1fc67b14bb898d3ccb2b84769f8246/Template-IA-HOD-IA-form.pdf"
raw_url = file2.replace("/blob/", "/raw/")
pdf_url = f"{raw_url}?raw=true"
try:
file_content = requests.get(pdf_url).content
print(file_content)
bot.send_document(chat_id=tracker.sender_id, document=InputFile(file_content, "IA_form.pdf"))
except TelegramError as e:
print("Error sending document: {}".format(e))
dispatcher.utter_message(response="utter_IACOI_Form")
return []