Hello, I’m trying to connect a bot running on localhost to Viber using ngrok. I achieved a basic echo functionality following the Viber Python Bot API | Viber Developers Hub and Viber Python Bot API | Viber Developers Hub but when I try to do the same using a custom InputChannel in Rasa and then after the server runs to run from another script the
from viberbot import Api
from viberbot.api.bot_configuration import BotConfiguration
bot_configuration = BotConfiguration(
name='xxx',
avatar='',
auth_token='xxxxxxxxxxxx'
)
viber = Api(bot_configuration)
viber.set_webhook('http://xxxxxxxxxxxx.ngrok.io')
I get a 405 Method Not Allowed . Can anyone please guide me on how to fix it? In the ViberInput(InputChannel) I have a very basic functionality at that moment to mimic echo.
class ViberInput(InputChannel):
"""Viber input channel implementation. Based on the HTTPInputChannel."""
@classmethod
def name(cls) -> Text:
return "viber"
@classmethod
def from_credentials(cls, credentials: Optional[Dict[Text, Any]]) -> InputChannel:
if not credentials:
cls.raise_missing_credentials_exception()
return cls(
credentials.get("viber_name"),
credentials.get("avatar"),
credentials.get("auth_token")
)
def __init__(self, viber_name: Text, avatar: Text, auth_token: Text) -> None:
"""Create a Viber input channel.
"""
self.viber_name = viber_name
self.avatar = avatar
self.auth_token = auth_token
self.viber = Api(
BotConfiguration(
name=self.viber_name,
avatar=self.avatar,
auth_token=self.auth_token
)
)
def blueprint(
self, on_new_message: Callable[[UserMessage], Awaitable[Any]]
) -> Blueprint:
viber_webhook = Blueprint("viber_webhook", __name__)
@viber_webhook.route("/", methods=["POST"])
async def incoming(request: Request) -> HTTPResponse:
viber_request = self.viber.parse_request(request.get_data())
if isinstance(viber_request, ViberMessageRequest):
message = viber_request.message
# lets echo back
self.viber.send_messages(viber_request.sender.id, [
message
])
return response.text("success")
return viber_webhook