Giter Club home page Giter Club logo

webex_bot's Introduction

Introduction

Pypi Build Status

By using this module, you can create a Webex Teams messaging bot quickly in just a couple of lines of code.

This module does not require you to set up an ngrok tunnel to receive incoming messages when behind a firewall or inside a LAN. This package instead uses a websocket to receive messages from the Webex cloud.

Features

  • Uses the websockets module to receive incoming messages, thus avoiding the need to have a public IP or use incoming webhooks.
  • Simply add 'commands' which are just strings which instruct the bot to perform some action and reply with some result.
  • Allows for single or multi-post responses. This is useful if you want to reply with a lot of data, but it won't all fit in a single response.
  • Restrict bot to certain users or domains.
  • Uses the webexteamssdk package to send back replies from the bot.

๐Ÿš€ Getting started


โœจ Sample Project

You can find a sample project, using OpenAI/ChatGPT with this library here: https://github.com/fbradyirl/openai_bot


Only Python 3.9 is tested at this time.

  1. Install this module from pypi:

pip install webex_bot

If you need optional proxy support, use this command instead:

pip install webex_bot[proxy]

  1. On the Webex Developer portal, create a new bot token and expose it as an environment variable.
export WEBEX_TEAMS_ACCESS_TOKEN=<your bots token>
  1. Run your script:

python example.py

See example.py for details:

import os

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

# (Optional) Proxy configuration
# Supports https or wss proxy, wss prioritized.
proxies = {
    'https': 'http://proxy.esl.example.com:80',
    'wss': 'socks5://proxy.esl.example.com:1080'
}

# Create a Bot Object
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
               approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
               bot_name="My Teams Ops Bot",
               include_demo_commands=True,
               proxies=proxies)

# 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()

where EchoCommand is defined as:

import logging

from webexteamssdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
    Text, Image, HorizontalAlignment
from webexteamssdk.models.cards.actions import Submit

from webex_bot.formatting import quote_info
from webex_bot.models.command import Command
from webex_bot.models.response import response_from_adaptive_card

log = logging.getLogger(__name__)


class EchoCommand(Command):

    def __init__(self):
        super().__init__(
            command_keyword="echo",
            help_message="Echo Words Back to You!",
            chained_commands=[EchoCallback()])

    def pre_execute(self, message, attachment_actions, activity):
        """
        (optional function).
        Reply before running the execute function.

        Useful to indicate the bot is handling it if it is a long running task.

        :return: a string or Response object (or a list of either). Use Response if you want to return another card.
        """

        image = Image(url="https://i.postimg.cc/2jMv5kqt/AS89975.jpg")
        text1 = TextBlock("Working on it....", weight=FontWeight.BOLDER, wrap=True, size=FontSize.DEFAULT,
                          horizontalAlignment=HorizontalAlignment.CENTER, color=Colors.DARK)
        text2 = TextBlock("I am busy working on your request. Please continue to look busy while I do your work.",
                          wrap=True, color=Colors.DARK)
        card = AdaptiveCard(
            body=[ColumnSet(columns=[Column(items=[image], width=2)]),
                  ColumnSet(columns=[Column(items=[text1, text2])]),
                  ])

        return response_from_adaptive_card(card)

    def execute(self, message, attachment_actions, activity):
        """
        If you want to respond to a submit operation on the card, you
        would write code here!

        You can return text string here or even another card (Response).

        This sample command function simply echos back the sent message.

        :param message: message with command already stripped
        :param attachment_actions: attachment_actions object
        :param activity: activity object

        :return: a string or Response object (or a list of either). Use Response if you want to return another card.
        """

        text1 = TextBlock("Echo", weight=FontWeight.BOLDER, size=FontSize.MEDIUM)
        text2 = TextBlock("Type in something here and it will be echo'd back to you. How useful is that!",
                          wrap=True, isSubtle=True)
        input_text = Text(id="message_typed", placeholder="Type something here", maxLength=30)
        input_column = Column(items=[input_text], width=2)

        submit = Submit(title="Submit",
                        data={
                            "callback_keyword": "echo_callback"})

        card = AdaptiveCard(
            body=[ColumnSet(columns=[Column(items=[text1, text2], width=2)]),
                  ColumnSet(columns=[input_column]),
                  ], actions=[submit])

        return response_from_adaptive_card(card)


class EchoCallback(Command):

    def __init__(self):
        super().__init__(
            card_callback_keyword="echo_callback",
            delete_previous_message=True)

    def execute(self, message, attachment_actions, activity):
        return quote_info(attachment_actions.inputs.get("message_typed"))
  1. Now, just interact 1-1 with the bot. Send it a message with the text:

echo

and off you go!

Help

  • If you are a Cisco employee, you can join the discussion space here.
  • Alternatively, open an issue or PR with a question on usage.

History

0.1.2 (2021-03-15)

  • First release on PyPI.

0.1.4 (2021-03-23)

  • Better retry on websocket connection failure
  • Added support for approved domains
  • Other cleanup

0.1.5 (2021-03-23)

  • Retry websocket connection on socket.gaierror. (#1)

0.1.6 (2021-03-25)

  • Send ack on websocket message received. (#2)

0.1.7 (2021-03-26)

  • Minor cleanup.
  • Log bot email on startup.

0.1.8 (2021-05-04)

  • Fetch incoming message ID as base64.

0.2.0 (2021-05-07)

  • Switch format entirely to use cards.

0.2.1 (2021-05-07)

  • Import fix

0.2.2 (2021-05-08)

  • Typo fix

0.2.3 (2021-05-10)

  • Fix no module found error

0.2.5 (2021-05-10)

  • Pin websockets version

0.2.6 (2021-05-21)

  • Couple of bug fixes and support python 3.8 fully

0.2.7 (2021-09-27)

  • Fix for #11 server rejected WebSocket connection: HTTP 404

0.2.8 (2022-01-06)

Breaking change for existing cards:

  • Pass activity down to execute function so attibutes such as email can be fetched from card actions.
  • Update your existing execute functions to include the extra activity parameter.
    def execute(self, message, attachment_actions, activity):
        log.info(
            f"activity={activity} ")
        email = activity["actor"]['emailAddress']
        return quote_info(f"person email is '{email}'")

0.2.9 (2022-03-03)

  • Fixes for #14 & #16

0.2.10 (2022-03-03)

  • Add new workflow for Github releases.

0.2.11 (2022-03-08)

  • Add pre_execute function to Command. (optional function to overide). Reply before running the execute function. Useful to indicate the bot is handling it if it is a long running task.
  • See echo.py for example usage.

0.2.12 (2022-03-09)

  • Check for duplicate card callback keywords and raise exception if one exists.

0.2.13 (2022-03-09)

  • add support for pre_card_load_reply overide. Reply before sending the initial card. Useful if it takes a long time for the card to load.

0.2.14 (2022-03-09)

  • add support for deleting previous card in a chain.

0.2.15 (2022-03-09)

  • Support for chained cards

0.2.16 (2022-03-10)

  • Add support for approved rooms.

0.2.17 (2022-03-11)

0.2.18 (2022-03-11)

  • Remove pyadaptivecards as it is actually built into webexteamssdk
  • Add options for bot name, help message etc.

0.2.19 (2022-03-14)

  • Bug fix Thanks @muhammad-rafi

0.2.20 (2022-04-07)

  • Fix for #6
  • Fix for #20
  • Use system SSL context when connecting websocket.

0.2.21 (2022-04-07)

  • Fix for #13 - Update websockets lib to latest.

0.2.22 (2022-04-11)

  • Allow for commands to only respond if you are in the approved space.

0.3.0 (2022-04-26)

  • Add chained_commands as a parameter of Command. This allows multiple related cards to be added at once.
  • Updated Echo to use Adaptive Card objects (instead of JSON/Dict blob)
  • Added docs for some function params.

0.3.1 (2022-04-26)

  • Fix old school dict cards

0.3.3 (2022-06-07)

0.3.4 (2022-11-01)

  • Auto re-connect on websockets.exceptions.ConnectionClosedOK

0.4.0 (2023-April-03)

  • Bot will reply in response to the original message via the thread ID. This is not always possible in the case of a card action response due to some server side issue.

0.4.1 (2023-Sept-07)

  • Always ensure there is a thread ID in the Activity before accessing it

0.4.6 (2024-Apr-24)

  • โŒ Bad release. Please do not use this one as there is a startup issue with it.

0.5.0 (2024-Apr-25)

  • Add max backoff time (#55)
  • Attached files. Help, threading and log level overrides. (#54)
  • add stop() call to gracefully exit the bot (#42)
  • feat(20231212): add help image size parameter (#46)
  • update websockets to 11.0.3 (#43)
  • Fix for help_command syntax issue

0.5.1 (2024-Apr-25)

  • Add Proxy Support. (#56)

webex_bot's People

Contributors

0x2142 avatar ciaranjordan avatar davidthoy avatar ecoen66 avatar fbradyirl avatar gconklin avatar jseynaev-cisco avatar liozzazhang avatar luketainton avatar muhammad-rafi avatar sandorzm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webex_bot's Issues

Old messages come again

  • Webex Bot version: 0.1.5
  • Python version: 3.9
  • Operating System: macOS

Description

If the bot process exits and it then restarted, recent messages sent to it from the last 15 minutes will come again from the web socket connection even though they have previously been processed.

ModuleNotFoundError: No module named 'imp'

Webex Bot version: ??? newest (just ran pipenv install webex_bot)
Python version: 3.12.0
Operating System: Windows 10

So I'm trying to get a simple Webex bot running and I am following this tutorial: https://www.youtube.com/watch?v=pC_hj2-czlk
but every time I run python app.py (the driver script) I get the ModuleNotFoundError: No module named 'imp' here is all of my code:

app.py:

from gpt import gpt
from webex_bot.webex_bot import WebexBot

#Create a Bot Object
bot = WebexBot("MY_WebEx_Bot_Access_Token")

#Clear default help command
bot.commands.clear()

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

#Set new command as default
bot.help_command = gpt()

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

gpt.py:

from webex_bot.models.response import Response

class gpt(Command):

    def __init__(self):
        super().__init__()
    
    def execute(self, message, attachment_actions, activity):
        
        return "Hello World!"

What am I doing wrong?

Here is the full error:

PS C:\Users\Bruger\Desktop\WebExBotTest2> python app.py
Traceback (most recent call last):
  File "C:\Users\Bruger\Desktop\WebExBotTest2\app.py", line 1, in <module>
    from gpt import gpt
  File "C:\Users\Bruger\Desktop\WebExBotTest2\gpt.py", line 3, in <module>
    from webex_bot.models.response import Response
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webex_bot\models\response.py", line 3, in <module>
    from webexteamssdk.models.cards import AdaptiveCard
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webexteamssdk\__init__.py", line 40, in <module>
    from .api import WebexTeamsAPI
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webexteamssdk\api\__init__.py", line 33, in <module>
    from webexteamssdk.models.immutable import immutable_data_factory
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webexteamssdk\models\immutable.py", line 42, in <module>
    from webexteamssdk.utils import json_dict
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webexteamssdk\utils.py", line 33, in <module>
    from future import standard_library
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\future\standard_library\__init__.py", line 65, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'

Websockets.exceptions.ConnectionClosedError

  • Webex Bot version: 0.3.1
  • Python version: 3.10.4
  • Operating System: Windows 10

Description

If I run the code with one fresh bot, all work fine. But after 2 days I try again and the error comes.

What I Did

[INFO]  [webex_bot.webex_bot.webex_bot.__init__]:49 Registering bot with Webex cloud

[INFO]  [restsession.webexteamssdk.restsession.user_agent]:167 User-Agent: webexteamssdk/0+unknown {"implementation": {"name": "CPython", 
"version": "3.10.4"}, "system": {"name": "Windows", "release": "10"}, "cpu": "AMD64"}

[INFO]  [webex_websocket_client.webex_bot.websockets.webex_websocket_client._connect_and_listen]:161 WebSocket Opened.

[INFO]  [_common.backoff._log_backoff]:105 Backing off _connect_and_listen(...) for 69.6s (websockets.exceptions.ConnectionClosedError: received 1011 (unexpected error); then sent 1011 (unexpected error))

Install FAILS with python3.12 on Ubuntu 22.04

ubuntu@webexlab:~$ pip install webex_bot
Defaulting to user installation because normal site-packages is not writeable
Collecting webex_bot
Using cached webex_bot-0.4.1-py2.py3-none-any.whl.metadata (10 kB)
Collecting webexteamssdk==1.6.1 (from webex_bot)
Using cached webexteamssdk-1.6.1-py3-none-any.whl.metadata (8.0 kB)
Collecting coloredlogs (from webex_bot)
Using cached coloredlogs-15.0.1-py2.py3-none-any.whl.metadata (12 kB)
Collecting websockets==10.2 (from webex_bot)
Using cached websockets-10.2.tar.gz (83 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

ร— python setup.py egg_info did not run successfully.
โ”‚ exit code: 1
โ•ฐโ”€> [11 lines of output]
Traceback (most recent call last):
File "", line 2, in
File "", line 14, in
File "/usr/lib/python3/dist-packages/setuptools/init.py", line 16, in
import setuptools.version
File "/usr/lib/python3/dist-packages/setuptools/version.py", line 1, in
import pkg_resources
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2172, in
register_finder(pkgutil.ImpImporter, find_on_path)
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

ร— Encountered error while generating package metadata.
โ•ฐโ”€> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
ubuntu@webexlab:$
ubuntu@webexlab:
$ python3 -V
Python 3.12.2
ubuntu@webexlab:$ pip -V
pip 24.0 from /home/ubuntu/.local/lib/python3.12/site-packages/pip (python 3.12)
ubuntu@webexlab:
$

ubuntu@webexlab:~$ neofetch
.-/+oossssoo+/-.
:+ssssssssssssssssss+: ---------------
-+ssssssssssssssssssyyssss+- OS: Ubuntu 22.04.4 LTS x86_64
.ossssssssssssssssssdMMMNysssso. Host: VMware Virtual Platform None
/ssssssssssshdmmNNmmyNMMMMhssssss/ Kernel: 5.15.0-101-generic
+ssssssssshmydMMMMMMMNddddyssssssss+ Uptime: 20 hours, 14 mins
/sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ Packages: 669 (dpkg), 4 (snap)
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Shell: bash 5.1.16

`AttributeError: 'WebexBot' object has no attribute 'command'`

  • Webex Bot version: 0.2.18
  • Python version: 3.8.12
  • Operating System: macOS Monterey v12.2.1

Description

I was writing a basic script as below which is same as https://github.com/fbradyirl/webex_bot/blob/main/example.py

and seeing the following error

AttributeError: 'WebexBot' object has no attribute 'command'

Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Copy the example.py from your https://github.com/fbradyirl/webex_bot/blob/main/example.py and changed the secret token

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= 'my secret token')

# 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()

When I try to run the script, I am getting following traceback

(py_3.8) murafi@MURAFI-M-VC10:chat_bot$ python chattybot.py 
2022-03-13 23:49:07  [INFO]  [webex_bot.webex_bot.webex_bot.__init__]:45 Registering bot with Webex cloud
2022-03-13 23:49:07  [INFO]  [restsession.webexteamssdk.restsession.user_agent]:167 User-Agent: webexteamssdk/0+unknown {"implementation": {"name": "CPython", "version": "3.8.12"}, "distro": {"name": "macOS", "version": "12.2.1"}, "system": {"name": "Darwin", "release": "21.3.0"}, "cpu": "x86_64"}
Traceback (most recent call last):
  File "chattybot.py", line 44, in <module>
    bot = WebexBot(teams_bot_token= 'NTE2OGI2NzQtZTcxYi00MzZmLThhNTItZGQzNTQ2ZjdjNDkxMDE2Y2ZmOGMtZGE4_PF84_1eb65fdf-9643-417f-9974-ad72cae0e10f')
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 65, in __init__
    self.command.add(EchoCommand())
AttributeError: 'WebexBot' object has no attribute 'command'
(py_3.8) murafi@MURAFI-M-VC10:chat_bot$ 

It seems like a bug as there are couple of typos and I am going to create a pull request to fix unless you guys created this like on purpose ? and I am missing something

Bot not receiving messages

  • Webex Bot version: latest
  • Python version: 3.8
  • Operating System: Ubuntu 20 in Windows WSL

Description

Hi there! I am trying to get a bot up and running with a non-cisco webex account - but it seems the bot is never receiving messages.

I have previously used this module to create a bot, but it was all using my cisco.com webex account - and I never hit any issues. However, I am trying to create a bot using a personal email/webex account & it doesn't seem to be working.

What I Did

  1. Created new webex bot API token on the Webex Developer site, using my personal email/webex account
  2. pip install webex_bot
  3. Use basic code snippet below to test
  4. Send message from @cisco.com account - Bot receives message & responds with help card
  5. Send message from non-cisco.com account - Bot never receives message

I also tried enabling debug logging on the bot, but I am never seeing a message come in.

Additionally, if I create a group room with my personal & cisco.com accounts in it - The bot will respond then to a direct @ message from my personal email. However, in a direct 1:1 space it seems the message never makes it to the bot.

from webex_bot.webex_bot import WebexBot
bot = WebexBot(api_token)
bot.run()

default help card is annoying

  • Webex Bot version: 0.2.22
  • Python version: 3.8.9
  • Operating System: macOS

Description

Any option/recommendation to stop sending the default help card (next image) everytime the user type help insted of the one I defined?
image

What I Did

# action.py
class myAction(Command):
    def __init__(self):
        super().__init__(
            command_keyword="help",
            help_message="My Custom Help",
            card=START_CARD,
        )

# bot.py
bot.help_command = myAction()
help = myAction()
bot.add_command(help)

webexteamssdk.exceptions.ApiError: [400] Bad Request - Unable to retrieve content

  • Webex Bot version: 0.2.22
  • Python version: python:3.8
  • Operating System: alpine3.15

Description

Bot was working fine during the week but suddenly start sending the next error:
Any idea about what could be causing this?


2022-04-29 02:12:48  [INFO]  [webex_bot.webex_bot.webex_bot.process_raw_command]:212 New user_command: test
2022-04-29 02:12:48  [INFO]  [webex_bot.webex_bot.webex_bot.process_raw_command]:213 is_card_callback_command: False
2022-04-29 02:12:48  [WARNING]  [webex_bot.webex_bot.webex_bot.process_raw_command]:232 Did not find command for test. Default to help card.
2022-04-29 02:13:33  [ERROR]  [base_events.asyncio.default_exception_handler]:1707 Future exception was never retrieved
future: <Future finished exception=<ApiError [400] Bad Request>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/webex_bot/websockets/webex_websocket_client.py", line 63, in _process_incoming_websocket_message
    self.on_message(teams_message=webex_message, activity=activity)
  File "/usr/local/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 203, in process_incoming_message
    self.process_raw_command(raw_message, teams_message, user_email, activity)
  File "/usr/local/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 278, in process_raw_command
    return self.do_reply(reply, room_id, user_email, reply_one_to_one, is_one_on_one_space)
  File "/usr/local/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 287, in do_reply
    self.teams.messages.create(**reply)
  File "/usr/local/lib/python3.8/site-packages/webexteamssdk/api/messages.py", line 282, in create
    json_data = self._session.post(API_ENDPOINT, json=post_data)
  File "/usr/local/lib/python3.8/site-packages/webexteamssdk/restsession.py", line 487, in post
    response = self.request("POST", url, erc, json=json, data=data,
  File "/usr/local/lib/python3.8/site-packages/webexteamssdk/restsession.py", line 345, in request
    check_response_code(response, erc)
  File "/usr/local/lib/python3.8/site-packages/webexteamssdk/utils.py", line 222, in check_response_code
    raise ApiError(response)
webexteamssdk.exceptions.ApiError: [400] Bad Request - Unable to retrieve content. [Tracking ID: ROUTER_626B4971-A5B2-01BB-4FC9-AC12DC074FC9]

Websocket connection through Proxy Server

  • Webex Bot version: 0.3.3
  • Python version: 3.9
  • Operating System: Windows

Is there an existing way to configure the webex_bot to access webexapis.com through a proxy server? The webexteamssdk module has this functionality but I have not seen anything similar in webex_bot:

proxy = {'https': 'http://<proxy_ip>:<proxy_port>'}
api = WebexTeamsAPI(access_token=WEBEX_TEAMS_ACCESS_TOKEN,proxies=proxy)

import os
import Token

from webex_bot.webex_bot import WebexBot

webex_token = Token.BOT_WEBEX_TEAMS_ACCESS_TOKEN


bot=WebexBot(webex_token,approved_domains=['domainhere.com'])
bot.run()

Without a proxy connection, I get the following error when I execute bot.run().

"ConnectionError: HTTPSConnectionPool(host='webexapis.com', port=443): Max retries exceeded with url: /v1/people/me (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002570BB6FB50>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))"

async send without await

  • Webex Bot version: latest pip
  • Python version: 3.8
  • Operating System: Windows and docker

Description

*****\site-packages\webex_bot\websockets\webex_websocket_client.py:100: RuntimeWarning: coroutine 'WebSocketCommonProtocol.send' was never awaited
  self.websocket.send(json.dumps(ack_message))

What I Did

Just starting the bot

It's just a warning, so I guess just adding 'await' should fix it

removeprefix() is 3.9 only

  • Webex Bot version: lastest pip
  • Python version: 3.8
  • Operating System: windows/docker

Description

Just running the bot

What I Did

After receiving a message from the socket

ERROR:asyncio:Future exception was never retrieved
future: <Future finished exception=AttributeError("'str' object has no attribute 'removeprefix'")>

fix / workaround

removeprefix is only introduced in 3.9, so might be better to replace by something like this
(bottom of the webex_bot.py file)

if message.startswith(command):
    return message[len(command):]
return message

Python 3.10+ Support.

  • Webex Bot version: latest
  • Python version: 3.10.0
  • Operating System: MacOS 11.2.3

Description

Running the bot doesn't work in python 3.10.0. It seems to be an issue with websockets/asyncio per the traceback logs.
It looks like it was fixed in python-websockets/websockets#916

Anyway this library can be updated to support 3.10+?

What I Did

python3.10 bot.py


/lib/python3.10/site-packages/websockets/protocol.py", line 235, in __init__
    self._drain_lock = asyncio.Lock(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/locks.py", line 77, in __init__
    super().__init__(loop=loop)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/mixins.py", line 17, in __init__
    raise TypeError(
TypeError: As of 3.10, the *loop* parameter was removed from Lock() since it is no longer necessary

How to add more command_keyword

  • Webex Bot version: 0.3.1
  • Python version: 3.8.10
  • Operating System: macos

Description

I want to add more command_keyword in 1 class and the bot will execute each keyword
how to do that ?

What I Did

for example
command_keyword=["hello", "hi"]
or somethings else

TypeError: 'staticmethod' object is not callable, when run the 'help' command - Bug

  • Webex Bot version: 0.2.19
  • Python version: 3.8.12
  • Operating System: macOS Monterey v12.2.1

Description

Getting TypeError: 'staticmethod' object is not callable when I run the 'help' command on webex

What I Did

When running the 'help' command on webex, I am seeing the below Traceback on the terminal , I analyse code again and it seems like method response_from_adaptive_card should be a regular method rather than static method as currently showing up in the response.py

import json

from webexteamssdk.models.cards import AdaptiveCard


@staticmethod   --> should be a regular method 
def response_from_adaptive_card(adaptive_card: AdaptiveCard):
    """
    Convenience method for generating a Response from an AdaptiveCard.

    @param adaptive_card: AdaptiveCard object
    @return: Response object
    """

    response = Response()
    response.text = "This bot requires a client which can render cards."
    response.attachments = {
        "contentType": "application/vnd.microsoft.card.adaptive",
        "content": adaptive_card.to_dict()
    }

    return response


class Response(object):

--------- truncated -----------

Traceback on the terminal

(py_3.8) murafi@MURAFI-M-VC10:chat_bot$ python chattybot.py 
2022-03-14 23:16:01  [INFO]  [webex_bot.webex_bot.webex_bot.__init__]:45 Registering bot with Webex cloud
2022-03-14 23:16:01  [INFO]  [restsession.webexteamssdk.restsession.user_agent]:167 User-Agent: webexteamssdk/0+unknown {"implementation": {"name": "CPython", "version": "3.8.12"}, "distro": {"name": "macOS", "version": "12.2.1"}, "system": {"name": "Darwin", "release": "21.3.0"}, "cpu": "x86_64"}
2022-03-14 23:16:01  [WARNING]  [webex_bot.webex_bot.webex_bot.approval_parameters_check]:115 Your bot is open to anyone on Webex Teams. Consider limiting this to specific users, domains or room members via the WebexBot(approved_domains=['example.com'], approved_users=['[email protected]'], approved_rooms=['Y2lzY29zcGFyazovL3VzL1JPT00vZDUwMDE2ZWEtNmQ5My00MTY1LTg0ZWEtOGNmNTNhYjA3YzA5']) bot parameters.
2022-03-14 23:16:01  [INFO]  [webex_bot.webex_bot.webex_bot.get_me_info]:87 Running as bot 'ChattyBot' with email ['[email protected]']
2022-03-14 23:16:01  [WARNING]  [command.webex_bot.models.command.__init__]:40 no card actions data so no entry for 'callback_keyword' for echo
2022-03-14 23:16:01  [INFO]  [command.webex_bot.models.command.set_default_card_callback_keyword]:54 Added default action for 'echo' callback_keyword=callback___echo
2022-03-14 23:16:02  [INFO]  [webex_websocket_client.root._connect_and_listen]:151 Opening websocket connection to wss://mercury-connection-partition0-a.wbx2.com/v1/apps/wx2/registrations/c6792f58-ead1-4aa7-9153-5cfe6c669493/messages
2022-03-14 23:16:02  [INFO]  [webex_websocket_client.root._connect_and_listen]:154 WebSocket Opened.
/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/websockets/webex_websocket_client.py:100: RuntimeWarning: coroutine 'WebSocketCommonProtocol.send' was never awaited
  self.websocket.send(json.dumps(ack_message))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
2022-03-14 23:16:09  [INFO]  [webex_websocket_client.root._ack_message]:101 WebSocket ack message with id=Y2lzY29zcGFyazovL3VzL01FU1NBR0UvYmFmYjY2NTAtYTNlYy0xMWVjLThiMDEtNTdmYjk4YjcwNzM0. Complete.
2022-03-14 23:16:09  [INFO]  [webex_bot.webex_bot.webex_bot.process_incoming_message]:193 Message from [email protected]: Webex Teams Message:
{
  "id": "Y2lzY29zcGFyazovL3VzL01FU1NBR0UvYmFmYjY2NTAtYTNlYy0xMWVjLThiMDEtNTdmYjk4YjcwNzM0",
  "roomId": "Y2lzY29zcGFyazovL3VzL1JPT00vYTRiYzMzNjAtNjFmMi0xMWVjLWJkNGUtNTM5NTE1ZDZlYzEz",
  "roomType": "direct",
  "text": "help",
  "personId": "Y2lzY29zcGFyazovL3VzL1BFT1BMRS80MTZkMDE5Mi0yMDQ1LTRhMTktOTM4Yy03YzI0Mjk5MTU1NGY",
  "personEmail": "[email protected]",
  "created": "2022-03-14T23:16:08.629Z"
}
2022-03-14 23:16:09  [WARNING]  [webex_bot.webex_bot.webex_bot.approval_parameters_check]:115 Your bot is open to anyone on Webex Teams. Consider limiting this to specific users, domains or room members via the WebexBot(approved_domains=['example.com'], approved_users=['[email protected]'], approved_rooms=['Y2lzY29zcGFyazovL3VzL1JPT00vZDUwMDE2ZWEtNmQ5My00MTY1LTg0ZWEtOGNmNTNhYjA3YzA5']) bot parameters.
2022-03-14 23:16:09  [ERROR]  [base_events.asyncio.default_exception_handler]:1707 Future exception was never retrieved
future: <Future finished exception=TypeError("'staticmethod' object is not callable")>
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.8.12_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/websockets/webex_websocket_client.py", line 56, in _process_incoming_websocket_message
    self.on_message(teams_message=webex_message, activity=activity)
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 202, in process_incoming_message
    self.process_raw_command(raw_message, teams_message, user_email, activity)
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 262, in process_raw_command
    reply, reply_one_to_one = self.run_command_and_handle_bot_exceptions(command=command,
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 341, in run_command_and_handle_bot_exceptions
    return command.card_callback(message, teams_message, activity), False
  File "/Users/murafi/py_3.8/lib/python3.8/site-packages/webex_bot/commands/help.py", line 61, in build_card
    return response_from_adaptive_card(adaptive_card=card)
TypeError: 'staticmethod' object is not callable

I am going to raise a pull request, please review it and let me know if you are happy with it.

Thanks,
-Rafi

Commands not being received

  • Webex Bot version: 0.4.1
  • Python version: 3.8.2 / 3.11.7 (tested with both)
  • Operating System: Windows 10 Pro 64 bit (Version 22H2)

Description

I'm trying to do a simple bot following the README.md instructions but I cannot see any commands received

I'm messaging the bot directly (used the bot email to find it on webex)

What I Did

I've tried using the same exact code as it's on the README.md. I've found this issue #12 , maybe it's because i'm messaging the bot from a gmail account? I don't have a cisco account to test it with.

Tried to remove the "approved_..." parameters or add my email to the "approved_users" and the behaviour is always the same.

Log file

image

Steps to reproduce:

  • Install python 3.8.2 or 3.11.7
  • Follow all the steps from README (pip install webex_bot and env variable creation)
  • Messaged the bot with my [email protected] email address = No response

Future exception was never retrieved

  • Webex Bot version: webex_bot-0.2.19
  • Python version: Python 3.8.10
  • Operating System: Ubuntu 20.04.2 LTS

Description

running the included example.py file, send the bot a message, and I get:

2022-04-05 13:01:36  [ERROR]  [base_events.asyncio.default_exception_handler]:1707 Future exception was never retrieved
future: <Future finished exception=<ApiError [404] Not Found>>

What I Did

virtualenv webexbot
pip install webex_bot
export WEBEX_TEAMS_ACCESS_TOKEN='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
(webexbot) ben@ub-box:~/workingDirectory/webexBot/socketBot$ python3 example.py 
2022-04-05 13:14:47  [INFO]  [webex_bot.webex_bot.webex_bot.__init__]:45 Registering bot with Webex cloud
2022-04-05 13:14:47  [INFO]  [restsession.webexteamssdk.restsession.user_agent]:167 User-Agent: webexteamssdk/0+unknown {"implementation": {"name": "CPython", "version": "3.8.10"}, "system": {"name": "Linux", "release": "5.13.0-30-generic"}, "cpu": "x86_64"}
2022-04-05 13:14:48  [WARNING]  [webex_bot.webex_bot.webex_bot.approval_parameters_check]:115 Your bot is open to anyone on Webex Teams. Consider limiting this to specific users, domains or room members via the WebexBot(approved_domains=['example.com'], approved_users=['[email protected]'], approved_rooms=['Y2lzY29zcGFyazovL3VzL1JPT00vZDUwMDE2ZWEtNmQ5My00MTY1LTg0ZWEtOGNmNTNhYjA3YzA5']) bot parameters.
2022-04-05 13:14:48  [INFO]  [webex_bot.webex_bot.webex_bot.get_me_info]:87 Running as bot 'RecurveBot' with email ['[email protected]']
2022-04-05 13:14:48  [WARNING]  [command.webex_bot.models.command.__init__]:40 no card actions data so no entry for 'callback_keyword' for echo
2022-04-05 13:14:48  [INFO]  [command.webex_bot.models.command.set_default_card_callback_keyword]:54 Added default action for 'echo' callback_keyword=callback___echo
2022-04-05 13:14:48  [INFO]  [webex_websocket_client.root._connect_and_listen]:151 Opening websocket connection to wss://mercury-connection-partition0-a.wbx2.com/v1/apps/wx2/registrations/c471a9c9-958e-48d6-b392-7a115b12b43f/messages
2022-04-05 13:14:49  [INFO]  [webex_websocket_client.root._connect_and_listen]:154 WebSocket Opened.
/home/ben/workingDirectory/webexBot/webexbot/lib/python3.8/site-packages/webex_bot/websockets/webex_websocket_client.py:100: RuntimeWarning: coroutine 'WebSocketCommonProtocol.send' was never awaited
  self.websocket.send(json.dumps(ack_message))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
2022-04-05 13:15:02  [INFO]  [webex_websocket_client.root._ack_message]:101 WebSocket ack message with id=Y2lzY29zcGFyazovL3VzL01FU1NBR0UvYjBkNjcxZTAtYjUx. Complete.
2022-04-05 13:15:02  [INFO]  [webex_bot.webex_bot.webex_bot.process_incoming_message]:193 Message from [email protected]: Webex Teams Message:
{
  "id": "Y2lzY29zcGFya...",
  "roomId": "Y2lzY29zcGFya....",
  "roomType": "group",
  "text": "RecurveBot test",
  "personId": "Y2lzY29zcGF...",
  "personEmail": "[email protected]",
  "html": "<p><spark-mention data-object-type=\"person\" data-object-id=\"Y2lzY29zcGFyazovL3VzL1BFT1BMRS82ZWMzYWRj\">RecurveBot</spark-mention> test</p>",
  "mentionedPeople": [
    "Y2lzY29zcGFyazovL3VzL1B"
  ],
  "created": "2022-04-05T19:15:01.246Z"
}
2022-04-05 13:15:02  [WARNING]  [webex_bot.webex_bot.webex_bot.approval_parameters_check]:115 Your bot is open to anyone on Webex Teams. Consider limiting this to specific users, domains or room members via the WebexBot(approved_domains=['example.com'], approved_users=['[email protected]'], approved_rooms=['Y2lzY29zcGFyazovL3VzL1JPT00vZDUwMDE2ZWEtNmQ5My00MTY1LTg0ZWEtOGNmNTNhYjA3YzA5']) bot parameters.
2022-04-05 13:15:02  [ERROR]  [base_events.asyncio.default_exception_handler]:1707 Future exception was never retrieved
future: <Future finished exception=TypeError("'staticmethod' object is not callable")>
Traceback (most recent call last):
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/ben/workingDirectory/webexBot/webexbot/lib/python3.8/site-packages/webex_bot/websockets/webex_websocket_client.py", line 56, in _process_incoming_websocket_message
    self.on_message(teams_message=webex_message, activity=activity)
  File "/home/ben/workingDirectory/webexBot/webexbot/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 202, in process_incoming_message
    self.process_raw_command(raw_message, teams_message, user_email, activity)
  File "/home/ben/workingDirectory/webexBot/webexbot/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 262, in process_raw_command
    reply, reply_one_to_one = self.run_command_and_handle_bot_exceptions(command=command,
  File "/home/ben/workingDirectory/webexBot/webexbot/lib/python3.8/site-packages/webex_bot/webex_bot.py", line 341, in run_command_and_handle_bot_exceptions
    return command.card_callback(message, teams_message, activity), False
  File "/home/ben/workingDirectory/webexBot/webexbot/lib/python3.8/site-packages/webex_bot/commands/help.py", line 61, in build_card
    return response_from_adaptive_card(adaptive_card=card)
TypeError: 'staticmethod' object is not callable
^CTraceback (most recent call last):
  File "example.py", line 13, in <module>
    bot.run()
  File "/home/ben/workingDirectory/webexBot/webexbot/lib/python3.8/site-packages/webex_bot/websockets/webex_websocket_client.py", line 164, in run
    asyncio.get_event_loop().run_until_complete(_connect_and_listen())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 603, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
    self._run_once()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1823, in _run_once
    event_list = self._selector.select(timeout)
  File "/usr/lib/python3.8/selectors.py", line 468, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
KeyboardInterrupt

issue happens inside and outside a vitrualenv
future is installed
is there a recommended python version i should be using?

Help get user info within command function..

  • Webex Bot version: Latest
  • Python version: 3.8.10
  • Operating System: Windows

Description

Hello- I am trying to build a simple BOT that would relay questions from a Webex (person) room, post the question in a group space with subject-matter-experts (SMEs) and then relay the answer back to the originating space (user).

Not knowing if such a bot already exists, I started building one, and am basing it off the Webex-bot.

Thanks to the authors, this makes the bot building so simple!

I am now able to post a question and have it relayed on the SME team space!

I am now trying to relay the response, from the SME team, back to the originator.

Any tips (or example) on how to extract the originating room (and/or user email), from the callback?

What I Did

**pyton bot.py**
If there was a crash, please include the traceback here. N/A

warning 'open to everyone' still there when defining approved_domains

  • Webex Bot version: latest pip
  • Python version: 3.8
  • Operating System: windows/docker

Description

Starting the bot, limited to my domain, still displays the warning

What I Did

bot = WebexBot(
    teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN", BEARER_TOKEN),
    approved_domains=['mydomain.com'])

Fix

problem is with line

if len(self.approved_users) == 0 and len(self.approved_users) == 0:

pretty sure it should not be 'users' twice ;-)

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

  • 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 ['[email protected]']
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.

server rejected WebSocket connection: HTTP 404 (code = 1006, reason = [no reason])

  • Webex Bot version: 0.2.6
  • Python version: 3.8.0 64-bit
  • Operating System: win10

Description

Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen.

Server rejected websocket connection, don't know how to fix it, can you give me some advice?
i replaced some phrases with "xxxxxx" in the following logs to hide some id's (because i'm not shure if they are access tokens or something like that).

2021-07-06 16:10:56 [INFO] [webex_websocket_client.root._connect_and_listen]:152 Opening websocket connection to wss://mercury-connection-partition0-a.wbx2.com/v1/apps/wx2/registrations/xxxxxxxxxxx/messages

2021-07-06 16:10:56 [DEBUG] [protocol.websockets.protocol.init]:244 client - state = CONNECTING

2021-07-06 16:10:56 [DEBUG] [protocol.websockets.protocol.connection_made]:1340 client - event = connection_made(<_ProactorSocketTransport fd=956>)

2021-07-06 16:10:56 [DEBUG] [protocol.websockets.protocol.data_received]:1412 client - event = data_received(<39 bytes>)

2021-07-06 16:10:56 [DEBUG] [client.websockets.client.write_http_request]:82 client > GET /v1/apps/wx2/registrations/xxxxxx/messages HTTP/1.1

2021-07-06 16:10:56 [DEBUG] [client.websockets.client.write_http_request]:83 client > Headers([('Host', 'mercury-connection-partition0-a.wbx2.com'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key',
'ivFtcbfe+SeI0BHDHkZVDg=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/8.0.2')])

2021-07-06 16:10:57 [DEBUG] [protocol.websockets.protocol.data_received]:1412 client - event = data_received(<1135 bytes>)

2021-07-06 16:10:57 [DEBUG] [client.websockets.client.read_http_response]:108 client < HTTP/1.1 404 Not Found

2021-07-06 16:10:57 [DEBUG] [client.websockets.client.read_http_response]:109 client < Headers([('TrackingID', 'ROUTER_60E46470-F3B4-01BB-256B-3E9C9709256B'), ('Cache-Control', 'no-cache, no-store'), ('Upgrade', 'websocket'), ('Connection', 'upgrade'), ('Sec-WebSocket-Accept', 'xxxxxxx'), ('Content-Type', 'text/html;charset=utf-8'), ('Content-Language', 'en'), ('Content-Length', '714'), ('Date', 'Tue, 06 Jul 2021 14:10:56 GMT'), ('Server', 'Redacted'), ('Strict-Transport-Security', 'max-age=63072000; includeSubDomains; preload')])

2021-07-06 16:10:57 [DEBUG] [protocol.websockets.protocol.fail_connection]:1257 client ! failing CONNECTING WebSocket connection with code 1006

2021-07-06 16:10:57 [DEBUG] [protocol.websockets.protocol.close_connection]:1203 client x closing TCP connection

2021-07-06 16:10:57 [DEBUG] [protocol.websockets.protocol.connection_lost]:1354 client - event = connection_lost(None)

2021-07-06 16:10:57 [DEBUG] [protocol.websockets.protocol.connection_lost]:1356 client - state = CLOSED

2021-07-06 16:10:57 [DEBUG] [protocol.websockets.protocol.connection_lost]:1361 client x code = 1006, reason = [no reason]

2021-07-06 16:10:57 [ERROR] [webex_websocket_client.root.run]:167 runException: server rejected WebSocket connection: HTTP 404

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

runException: server rejected WebSocket connection: HTTP 404
code = 1006, reason = [no reason]

Thank you very much!

How to do multi-post responses

  • Webex Bot version: 0.4.1
  • Python version: 3.11.4
  • Operating System: MacOS 14.2.1

Description

You mention in the documentation, that Webex BOT "allows for single or multi-post responses". How can you make multi-post responses?

What I Did

from webex_bot.webex_bot import WebexBot
from webex_bot.models.command import Command

class MyBot(Command):
    def __init__(self, important_parameter):
        super().__init__(
            command_keyword="my-command-name",
            help_message="my command description",
            card=None,
        )
        self.important_parameter = important_parameter

    def pre_execute(self, message, attachment_actions, activity):
        return "This could take a minute..."

    def execute(self, message: str, attachment_actions: list, activity):    
        for long_message in self.important_parameter.do_something(message.strip()):
            # How can I respond multiple times here????
        return ???

Bot not responding to messages with attachments (no log output either).

  • Webex Bot version: latest
  • Python version: 3.10.7
  • Operating System: Windows

Description

I've modified the Help command to my needs and my expectation is that any text that is typed and sent directly to the Bot in a 1:1 space, the help command, is sent back to them. This works great, but if a message is sent with an attachment (such as an image, gif, pdf, or other file) the Bot seems to ignore the message, and it does not even show anything in the logs.

The expected behavior would be for the attachment to be ignored and the help command is returned.

What I Did

When a message is sent directly to the bot, here is the console logs:

2023-01-10 15:50:19  [INFO]  [webex_bot.webex_bot.webex_bot.process_incoming_message]:198 Message from [email protected]: Webex Teams Message:
{
  "id": "Y2lzY29zcGFy_______REDACTED___________TkzNDhm",
  "roomId": "Y2lzY29zcG_____REDACTED____TExOWI2OTA1MDkx",
  "roomType": "direct",
  "text": "ThisIsATest",
  "personId": "Y2lzY29zcGFya____REDACTED_____UtOGE0Yy03N2RjNjc4OTAzYmM",
  "personEmail": "[email protected]",
  "created": "2023-01-10T21:50:18.574Z"
}
2023-01-10 15:50:19  [INFO]  [webex_bot.webex_bot.webex_bot.process_raw_command]:216 New user_command: thisisatest
2023-01-10 15:50:19  [INFO]  [webex_bot.webex_bot.webex_bot.process_raw_command]:217 is_card_callback_command: False
2023-01-10 15:50:19  [WARNING]  [webex_bot.webex_bot.webex_bot.process_raw_command]:236 Did not find command for thisisatest. Default to help card.

This is the expected behavior. When a message is sent with an attachment, I do not see any output in the console logs so it appears that the Bot is not listening for that type of message ("Message with attachment?" or other. is it the case that a message with an attachment is not considered a "command"? Any way to change this behavior?

I'm not too familiar with Python, so I appreciate any assistance! thank you!

Running webex_bot on Ubuntu 20.04 gets TypeError on action response

  • Webex Bot version: 0.3.3
  • Python version: 3.10.4
  • Operating System: Ubuntu 20.04

Description

I have a webex bot that listens for a submit from an adaptive card. The callback triggers a function that makes an API call. I built it on MacOS and it is working fine there, but when i moved it to ubuntu im getting an error after the API call is successfully made. It has no issue making the call but does not seem to like the fact that the API returns a response.

What I Did

Can include my python code if needed, below is traceback

2022-06-13 15:12:48  [INFO]  [webex_bot.webex_bot.webex_bot.process_raw_command]:216 New user_command: pipeline
2022-06-13 15:12:48  [INFO]  [webex_bot.webex_bot.webex_bot.process_raw_command]:217 is_card_callback_command: True
2022-06-13 15:12:48  [INFO]  [webex_bot.webex_bot.webex_bot.process_raw_command]:239 Found command: pipeline
2022-06-13 15:12:49  [ERROR]  [base_events.asyncio.default_exception_handler]:1744 Future exception was never retrieved
future: <Future finished exception=TypeError("We were expecting to receive an instance of one of the following types: 'basestring'or 'None'; but instead we received <Response [201]> which is a 'Response'.")>
Traceback (most recent call last):
  File "/home/craig/.pyenv/versions/3.10.4/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/craig/.pyenv/versions/webex/lib/python3.10/site-packages/webex_bot/websockets/webex_websocket_client.py", line 74, in _process_incoming_websocket_message
    self.on_card_action(attachment_actions=attachment_actions, activity=activity)
  File "/home/craig/.pyenv/versions/webex/lib/python3.10/site-packages/webex_bot/webex_bot.py", line 177, in process_incoming_card_action
    self.process_raw_command(raw_message,
  File "/home/craig/.pyenv/versions/webex/lib/python3.10/site-packages/webex_bot/webex_bot.py", line 282, in process_raw_command
    return self.do_reply(reply, room_id, user_email, reply_one_to_one, is_one_on_one_space)
  File "/home/craig/.pyenv/versions/webex/lib/python3.10/site-packages/webex_bot/webex_bot.py", line 310, in do_reply
    self.send_message_to_room_or_person(user_email,
  File "/home/craig/.pyenv/versions/webex/lib/python3.10/site-packages/webex_bot/webex_bot.py", line 332, in send_message_to_room_or_person
    self.teams.messages.create(roomId=room_id, markdown=reply)
  File "/home/craig/.pyenv/versions/webex/lib/python3.10/site-packages/webexteamssdk/api/messages.py", line 242, in create
    check_type(markdown, basestring, optional=True)
  File "/home/craig/.pyenv/versions/webex/lib/python3.10/site-packages/webexteamssdk/utils.py", line 170, in check_type
    raise TypeError(error_message)
TypeError: We were expecting to receive an instance of one of the following types: 'basestring'or 'None'; but instead we received <Response [201]> which is a 'Response'.

Webex_bot do not work behind proxy

  • Webex Bot version:
  • Python version: 3.8
  • Operating System: Ubuntu

Description

support connecting using the library via a proxy

What I Did

Use a VM that connects to internet via proxy ,

The card displayed for Help restricts the number of buttons to 5

  • Webex Bot version:0.3.1
  • Python version:3.8
  • Operating System: Windows

Description

In the example.py tried to add commands to the bot using add_command.

  • the card displays a maximum of 5 - irrespective of the number of commands added.
  • the text command does work confirming that the command was added but the problem is just the displayed commands

What I Did

  1. added ~10 commands with add_command in the example.py
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

send an attachment .txt or xlsx file ?

  • Webex Bot version: 0.2.8
  • Python version: 3.8.9
  • Operating System: 12.2

Description

Sending plain text messages working fine. But now Im trying to send an attachment .txt or xlsx file but I dont know how I guess we can use attachment_actions. Can you give me a light about how can I use attachment_actions ? or maybe an example

What I Did

(Pdbr) inspect(attachment_actions)

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.