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

Bot webhook is setup but bot is not responding. Webhook does not seem to be be reciving anything #41

Closed
akshaykadidal opened this issue Sep 4, 2023 · 18 comments

Comments

@akshaykadidal
Copy link

  • Webex Bot version: webex-bot 0.4.0
  • Python version: Python 3.9.2
  • Operating System:linux (GCP defaul VM)

Description

Websocket is open. But the bot does not respond.

image
2023-09-04 14:04:23  [INFO]  [webex_bot.webex_bot.webex_bot.get_me_info]:90 Running as bot 'testbot1' with email ['testbotcan@webex.bot']
2023-09-04 14:04:59  [INFO]  [webex_websocket_client.webex_bot.websockets.webex_websocket_client._connect_and_listen]:160 Opening websocket connection to wss://mercury-connection-partition1-a.wbx2.com/v1/apps/wx2/registrations/xxxxxx-xxxxxx-xxxxx-xxxx-xxxxxxxxxxxx/messages
2023-09-04 14:04:59  [INFO]  [webex_websocket_client.webex_bot.websockets.webex_websocket_client._connect_and_listen]:163 WebSocket Opened.
@gconklin
Copy link
Contributor

gconklin commented Sep 4, 2023

Hi @akshaykadidal-

How are you initializing your bot? Have you set an "approved_*" parameter on the constructor to allow yourself to talk to the bot. There's 3 approved parameters:

  • @param approved_users: List of email address who are allowed to chat to this bot.
  • @param approved_domains: List of domains which are allowed to chat to this bot.
  • @param approved_rooms: List of rooms whose members are allowed to chat to this bot.

To allow your specific user, you would do something like this:

bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
               approved_users=["myemail@domain.com"], # add your e-mail address here
               bot_name="My Teams Ops Bot",
               include_demo_commands=True)

@akshaykadidal
Copy link
Author

akshaykadidal commented Sep 4, 2023

I have not filled in any of these optional parameters. I see that I get a warning.
[WARNING] [webex_bot.webex_bot.webex_bot.approval_parameters_check]:117 Your bot is open to anyone on Webex Teams. Consider limiting this to specific users, domains or room members via the WebexBot(approved_domains=
I update the code to add the approved domains and my email IDs.
I readded the bot the result is the same.

how can I check if my requests are reaching the websocket?

@gconklin
Copy link
Contributor

gconklin commented Sep 4, 2023

In a 1:1 conversation with a bot, I see log messages like:

2023-09-04 17:39:59  [INFO]  [webex_bot.webex_bot.webex_bot.process_incoming_message]:198 Message from my.email.com: Webex Teams Message:
{
...json blob...
}
2023-09-04 17:39:59  [INFO]  [webex_bot.webex_bot.webex_bot.process_raw_command]:216 New user_command: a test message
2023-09-04 17:39:59  [INFO]  [webex_bot.webex_bot.webex_bot.process_raw_command]:217 is_card_callback_command: False
2023-09-04 17:39:59  [WARNING]  [webex_bot.webex_bot.webex_bot.process_raw_command]:236 Did not find command for a test message. Default to help card.

My "driver" script is really simple with a fresh checkout:

~/dev/webex_bot$ cat tester.py 
import os

from webex_bot.commands.echo import EchoCommand
from webex_bot.webex_bot import WebexBot

# Create a Bot Object
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
               bot_name="My Teams Ops Bot",
               include_demo_commands=True)

# Add new commands for the bot to listen out for.
bot.add_command(EchoCommand())

# Call `run` for the bot to wait for incoming messages.
bot.run()

@akshaykadidal
Copy link
Author

No other events are recorded nothing in the logs to show that an event was recieved.

image

time stamps are diffrent because the VM is probably showing GMT.

@yli758
Copy link

yli758 commented Nov 14, 2023

Where are we on this issue? I'm having the exact same observation.

@fbradyirl
Copy link
Owner

Are you behind a proxy?

@yli758
Copy link

yli758 commented Nov 14, 2023

I don't think so, but I don't want to give the false response. I'm in the campus network and I'm waiting the response from IT.

@yli758
Copy link

yli758 commented Nov 15, 2023

I worked with IT and they guided me to disable the virtual proxy in the cloud. However after that, I'm still having the same observation.

On the terminal, it only shows the following logs. No events displayed when webex client chats to the bot.

...
2023-11-15 10:18:06 [INFO] [webex_bot.webex_bot.webex_bot.init]:49 Registering bot with Webex cloud
2023-11-15 10:18:06 [INFO] [restsession.webexteamssdk.restsession.user_agent]:169 User-Agent: webexteamssdk/0+unknown {"implementation": {"name": "CPython", "version": "3.10.11"}, "system": {"name": "Windows", "release": "10"}, "cpu": "AMD64", "organization": {}}
2023-11-15 10:18:07 [INFO] [webex_bot.webex_bot.webex_bot.get_me_info]:90 Running as bot 'CCReport' with email ['CCReport@webex.bot']
2023-11-15 10:18:07 [INFO] [webex_websocket_client.webex_bot.websockets.webex_websocket_client._connect_and_listen]:160 Opening websocket connection to wss://mercury-connection-partition2-a.wbx2.com/v1/apps/wx2/registrations/a26872de-a8ce-44ab-b414-143081f04e57/messages
2023-11-15 10:18:07 [INFO] [webex_websocket_client.webex_bot.websockets.webex_websocket_client._connect_and_listen]:163 WebSocket Opened.

The network connection looks all OK.
nc -zv 170.72.231.161 443
Connection to 170.72.231.161 port 443 [tcp/https] succeeded!

Any suggestions?

@gconklin
Copy link
Contributor

gconklin commented Nov 15, 2023

Are you doing a 1:1 chat or in a room? If it's a room, you need to invite the bot and @tag it.

You can turn on debug logging and see if that reveals anything. You should see some PING/PONG messages.

logging.getLogger("webex_bot.websockets").setLevel(logging.DEBUG)
logging.getLogger("websockets").setLevel(logging.DEBUG)

@yli758
Copy link

yli758 commented Nov 16, 2023

I'm on 1:1 chat. Here is what I did:

1, Deleted the bot and recreatd Report1116@webex.bot on developer.webex.com. Just in case.

2, Updated the example.py with 3 new lines per your suggestion:
import logging
ogging.getLogger("webex_bot.websockets").setLevel(logging.DEBUG)
logging.getLogger("websockets").setLevel(logging.DEBUG)

3, Set the environment and run python example.py on my Windows machine:
2023-11-16 09:43:16 [INFO] [webex_bot.webex_bot.webex_bot.init]:49 Registering bot with Webex cloud
2023-11-16 09:43:16 [INFO] [restsession.webexteamssdk.restsession.user_agent]:169 User-Agent: webexteamssdk/0+unknown {"implementation": {"name": "CPython", "version": "3.10.11"}, "system": {"name": "Windows", "release": "10"}, "cpu": "AMD64", "organization": {}}
2023-11-16 09:43:17 [INFO] [webex_bot.webex_bot.webex_bot.get_me_info]:90 Running as bot 'Report1116' with email ['Report1116@webex.bot']
2023-11-16 09:43:17 [INFO] [webex_websocket_client.webex_bot.websockets.webex_websocket_client._connect_and_listen]:160 Opening websocket connection to wss://mercury-connection-partition1-a.wbx2.com/v1/apps/wx2/registrations/e207328b-c20c-4785-b413-c8511e66f872/messages
2023-11-16 09:43:17 [INFO] [webex_websocket_client.webex_bot.websockets.webex_websocket_client._connect_and_listen]:163 WebSocket Opened.

4, on the searching header of my webex client, I filled in Report1116@webex.bot. Type something there.

Unfortunately no response. On the terminal, nothing is displayed.

Is there a way to check if Webex cloud receives any info to the given bot and if webex cloud ever tried to send request to my Windows computer?

@gconklin
Copy link
Contributor

Sorry, I forgot the webex bot creates its own logging handler which kind of breaks the normal python logging config.

Try setting env var LOG_LEVEL=DEBUG before starting the bot. My commands didn't actually enable debug logging.

Is there a way to check if Webex cloud receives any info to the given bot and if webex cloud ever tried to send request to my Windows computer?

No, not that I'm aware of.

@yli758
Copy link

yli758 commented Nov 16, 2023

With the update, it does pop up a lot on the terminal. Enve ping/pong looks all good, I still don't see any response in webex client. No updates on logs either.
logs.txt

@gconklin
Copy link
Contributor

I don't have an answer. I agree the logs look ok and don't see an obvious problem. I talked with someone and the recommendation was to try the (supported) project at https://github.com/webex/webex-js-sdk/ to see if that works/fails.
If that also fails, then will have more leverage with webex support.
If it works, then we'd need more info to determine what the difference is. As it is now, I've never seen webex_bot not work in the few years I've been using it, so I can't duplicate this failure case.

@Schenk0
Copy link

Schenk0 commented Nov 17, 2023

I am having the same issue

@Schenk0
Copy link

Schenk0 commented Nov 18, 2023

So I tried running the code on replit, to see if the issue is something on my side, but it still doesn't work, any ideas?

@igorg1312
Copy link

Same issue here. node bot is working well. Could be something related to socket package 10.2?

@igorg1312
Copy link

Hi figure out, Cisco changed some configuration about device data, please register for the notification over the websocket in the device data:

DEVICE_DATA = {
"deviceName": "pywebsocket-client",
"deviceType": "DESKTOP",
"localizedModel": "python",
"model": "python",
"name": "python-spark-client",
"systemName": "python-spark-client",
"systemVersion": "0.1",
"features": {
"user": [
{
"key": "direct-message-notifications",
"val": "true",
"mutable": True,
"lastModified": "2019-07-03T09:18:54.806Z",
"type": "USER",
"deletedTime": 0
},
{
"key": "group-message-notifications",
"val": "true",
"mutable": True,
"lastModified": "2019-07-03T09:26:51.902Z",
"type": "USER",
"deletedTime": 0
},
{
"key": "mention-notifications",
"val": "true",
"mutable": True,
"lastModified": "2019-07-03T09:25:21.164Z",
"type": "USER",
"deletedTime": 0
},
{
"key": "web-color-theme",
"val": "true",
"mutable": True,
"lastModified": "2021-06-08T13:48:46.908Z",
"type": "USER",
"deletedTime": 0
}
]

}

}

@fbradyirl
Copy link
Owner

Closing as duplicate of #48

@fbradyirl fbradyirl closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants