Cannot connect my Rasa bot to Telegram (or any other)

Hello!

I created my chatbot thanks to Rasa and now I would like to make it available for everyone to talk with. I thought it was nice to have it on Telegram, so I tried to follow the instructions given here.

However, I’ve not been able to understand what I should specify as webhook URL. I have my own web-server, but what specific file should I insert instead of this: webhook_url: “your_url.com/webhooks/telegram/webhook” ?

By the way, I don’t need to use Telegram, any other way would work, I’m just looking for an easy way to make the bot public.

Thank you Tiziano

Hey Tiziano,

There is a really in-depth tutorial about how to deploy your bot on Telegram in the README of our Medicare Locator Bot. Hope this helps :slight_smile:

Thank you for your answer.

I followed all the passages, but when I was at the point of running make telegram I found that I didn’t have “telegram” in my Makefile. After googleing it, I added the following in the Makefile under “telegram”: rasa run -m models -p 5002 -c telegram --credentials credentials.yml.

Then I tried again with make telegram, but I got this error:

Cattura

Ah of course you wouldn’t have that makefile since the instructions are for that specific repo. If you setup your ngrok to point to port 5005, you’ll also want to update that in your run command.

Yaml parser errors are usually due to an invalid domain file yaml. Did the training of your bot go fine? If so, can you post the whole stack trace that appears if you run

rasa run -m models -p 5005 -c telegram --credentials credentials.yml

Yes, the training was fine.

Here the result of the command you wrote:

/home/tiz/.local/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Parameter ‘endpoints’ not set. Using default location ‘endpoints.yml’ instead. 2019-05-12 17:44:58 INFO root - Generating grammar tables from /usr/lib/python3.6/lib2to3/Grammar.txt 2019-05-12 17:44:58 INFO root - Generating grammar tables from /usr/lib/python3.6/lib2to3/PatternGrammar.txt

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see:

Traceback (most recent call last): File “/home/tiz/.local/bin/rasa”, line 11, in load_entry_point(‘rasa’, ‘console_scripts’, ‘rasa’)() File “/mnt/d/Users/Tiz/Documents/rasa/rasa_nlu/rasa/main.py”, line 68, in main cmdline_arguments.func(cmdline_arguments) File “/mnt/d/Users/Tiz/Documents/rasa/rasa_nlu/rasa/cli/run.py”, line 111, in run rasa.run(**vars(args)) File “/mnt/d/Users/Tiz/Documents/rasa/rasa_nlu/rasa/run.py”, line 61, in run model, channel=channel, credentials=credentials, endpoints=_endpoints, **kwargs File “/mnt/d/Users/Tiz/Documents/rasa/rasa_nlu/rasa/core/run.py”, line 132, in serve_application input_channels = create_http_input_channels(channel, credentials) File “/mnt/d/Users/Tiz/Documents/rasa/rasa_nlu/rasa/core/run.py”, line 30, in create_http_input_channels all_credentials = rasa.utils.io.read_yaml_file(credentials_file) File “/mnt/d/Users/Tiz/Documents/rasa/rasa_nlu/rasa/utils/io.py”, line 137, in read_yaml_file return read_yaml(read_file(filename, “utf-8”)) File “/mnt/d/Users/Tiz/Documents/rasa/rasa_nlu/rasa/utils/io.py”, line 104, in read_yaml return yaml_parser.load(content) or {} File “/home/tiz/.local/lib/python3.6/site-packages/ruamel/yaml/main.py”, line 331, in load return constructor.get_single_data() File “/home/tiz/.local/lib/python3.6/site-packages/ruamel/yaml/constructor.py”, line 109, in get_single_data node = self.composer.get_single_node() File “_ruamel_yaml.pyx”, line 706, in _ruamel_yaml.CParser.get_single_node File “_ruamel_yaml.pyx”, line 724, in _ruamel_yaml.CParser._compose_document File “_ruamel_yaml.pyx”, line 775, in _ruamel_yaml.CParser._compose_node File “_ruamel_yaml.pyx”, line 889, in _ruamel_yaml.CParser._compose_mapping_node File “_ruamel_yaml.pyx”, line 775, in _ruamel_yaml.CParser._compose_node File “_ruamel_yaml.pyx”, line 891, in _ruamel_yaml.CParser._compose_mapping_node File “_ruamel_yaml.pyx”, line 904, in _ruamel_yaml.CParser._parse_next_event ruamel.yaml.parser.ParserError: while parsing a block mapping in “”, line 2, column 3 did not find expected key in “”, line 8, column 31

Ok I solved the problem.

Now running make telegram and changing the Makefile to the 5005 port, it works, and I actually can chat with my bot on Telegram.

However, when I close the console, the server stops and the Telegram bot doesn’t work anymore. Is that because of the ngrok webhook? I was looking for a way to make the bot working permanently… I can use my own webhook, I only would like to know how.

Thank you so far.

I can use my own webhook, I only would like to know how.

By this, do you mean that you have your own hosted domain already?

Yes

Sorry for not noticing your reply. You should simply be able to replace the http://xxxxxxxx.ngrok.io with your hosted domain.

I am also having this issue: Traceback (most recent call last): File “/Users/MerryDeep/.conda/envs/RasaChatbot/bin/rasa”, line 8, in sys.exit(main()) File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/main.py”, line 92, in main cmdline_arguments.func(cmdline_arguments) File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/cli/run.py”, line 114, in run rasa.run(**vars(args)) File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/run.py”, line 56, in run **kwargs, File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/core/run.py”, line 171, in serve_application input_channels = create_http_input_channels(channel, credentials) File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/core/run.py”, line 50, in create_http_input_channels return [_create_single_channel(c, k) for c, k in all_credentials.items()] File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/core/run.py”, line 50, in return [_create_single_channel(c, k) for c, k in all_credentials.items()] File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/core/run.py”, line 57, in _create_single_channel return BUILTIN_CHANNELS[channel].from_credentials(credentials) File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/core/channels/telegram.py”, line 147, in from_credentials cls.raise_missing_credentials_exception() File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/core/channels/channel.py”, line 126, in raise_missing_credentials_exception cls.name(), cls.name(), DOCS_BASE_URL Exception: To use the telegram input channel, you need to pass a credentials file using ‘–credentials’. The argument should be a file path pointing to a yml file containing the telegram authentication information. Details in the docs: Messaging and Voice Channels

The argument should be a file path pointing to a yml file containing the telegram authentication information. if your directory where you are running itself has credential.yml file then rasa shell or rasa x or rasa train is sufficient to solve this issue.But if you have specified credential in different file please mention with as argument .

Refer Command line arguments

this is how I have created, have commented the telegram because I thought might because there is issue on it so I have tried with Facebook but still have issue File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/core/channels/facebook.py”, line 272, in from_credentials cls.raise_missing_credentials_exception() File “/Users/MerryDeep/.conda/envs/RasaChatbot/lib/python3.6/site-packages/rasa/core/channels/channel.py”, line 126, in raise_missing_credentials_exception cls.name(), cls.name(), DOCS_BASE_URL Exception: To use the facebook input channel, you need to pass a credentials file using ‘–credentials’. The argument should be a file path pointing to a yml file containing the facebook authentication information.