Issues with Custom message to Telegram from Rasa Action

Hi Guys,

I hope you are doing well, I am using Rasa Action to send a message to Telegram and I am able to see it on telegram, but it appears 5 times in telegram client with exceptions in Rasa. I am using NGROK with https on Rasa Connectors.

Could someone please help?

Here are exception details-

2020-05-10 18:39:39 ERROR    rasa.core.channels.telegram  - Exception when trying to handle message.Wrong url host
[2020-05-10 18:39:39 -0700] [12553] [ERROR] Exception occurred while handling uri: ''
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sanic/", line 976, in handle_request
    response = await response
  File "/usr/local/lib/python3.7/site-packages/rasa/core/channels/", line 252, in message
  File "/usr/local/lib/python3.7/site-packages/rasa/core/channels/", line 83, in handler
    await app.agent.handle_message(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/rasa/core/", line 486, in handle_message
    return await processor.handle_message(message)
  File "/usr/local/lib/python3.7/site-packages/rasa/core/", line 107, in handle_message
    await self._predict_and_execute_next_action(message.output_channel, tracker)
  File "/usr/local/lib/python3.7/site-packages/rasa/core/", line 538, in _predict_and_execute_next_action
    action, tracker, output_channel, self.nlg, policy, confidence
  File "/usr/local/lib/python3.7/site-packages/rasa/core/", line 651, in _run_action
    await self._send_bot_messages(events, tracker, output_channel)
  File "/usr/local/lib/python3.7/site-packages/rasa/core/", line 580, in _send_bot_messages
    await output_channel.send_response(tracker.sender_id, e.message())
  File "/usr/local/lib/python3.7/site-packages/rasa/core/channels/", line 193, in send_response
    await self.send_image_url(recipient_id, message.pop("image"), **message)
  File "/usr/local/lib/python3.7/site-packages/rasa/core/channels/", line 41, in send_image_url
    self.send_photo(recipient_id, image)
  File "/usr/local/lib/python3.7/site-packages/telegram/", line 65, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/telegram/", line 90, in decorator
    result =, data, timeout=kwargs.get('timeout'))
  File "/usr/local/lib/python3.7/site-packages/telegram/utils/", line 309, in post
    headers={'Content-Type': 'application/json'})
  File "/usr/local/lib/python3.7/site-packages/telegram/utils/", line 223, in _request_wrapper
    raise BadRequest(message)
telegram.error.BadRequest: Wrong url host

It sounds like something might be wrong with the image URL; what does the custom action look like?

@mloubser Thanks for helping, it is still unresolved. Please find below code , I look forward to your reply.

class ActionGetName(Action):

    def name(self) -> Text:
        return "action_get_name"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        if tracker.get_slot("name") is None:
            return [UserUtteranceReverted()]
            name = tracker.get_slot("name")

            messages_list = [' Hello '  + name,
                             'How are you']
            message = "".join(messages_list)
            dispatcher.utter_message(message, tracker)
            return []

two things:

  1. you’re not actually using tracker for anything; you can just pass message
  2. If you did need to fill variables in a template from tracker slot values, you’d need to pass **tracker.slots, not just `tracker