Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unawaited method issue in Telegram channel interface #11818

Merged
merged 3 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog/11818.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixes `RuntimeWarning: coroutine 'Bot.set_webhook' was never awaited` issue encountered when starting the rasa server,
which caused the Telegram bot to be unresponsive.
8 changes: 8 additions & 0 deletions docs/docs/connectors/telegram.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ telegram:
Restart your Rasa server
to make the new channel endpoint available for Telegram to send messages to.

:::note Handling `/start` message

At the beginning of a conversation, the user will press the 'Start' button in Telegram.
This will trigger a message with the content */start* to be sent.
Make sure your bot can handle this intro message by designing a specific intent which can then be used in stories.
ancalita marked this conversation as resolved.
Show resolved Hide resolved

:::


## Supported Response Attachments

Expand Down
3 changes: 2 additions & 1 deletion docs/docs/messaging-and-voice-channels.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ If you're running a Rasa server on `localhost`,
most external channels won't be able to find your server URL, since `localhost` is not open to the internet.

To make a port on your local machine publicly available on the internet,
you can use [ngrok](https://ngrok.com/).
you can use [ngrok](https://ngrok.com/). Alternatively, see this [list](https://github.com/anderspitman/awesome-tunneling)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list is a real gem!

tracking and comparing other tunneling solutions.

After installing ngrok, run:

Expand Down
3 changes: 2 additions & 1 deletion rasa/core/channels/telegram.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import json
import logging
from copy import deepcopy
Expand Down Expand Up @@ -288,7 +289,7 @@ def get_output_channel(self) -> TelegramOutput:
channel = TelegramOutput(self.access_token)

try:
channel.set_webhook(url=self.webhook_url)
asyncio.run(channel.set_webhook(url=self.webhook_url))
except TelegramAPIError as error:
raise RasaException(
"Failed to set channel webhook: " + str(error)
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
logger = logging.getLogger(__name__)


def noop(*args, **kwargs):
async def noop(*args, **kwargs):
"""Just do nothing."""
pass

Expand Down