Saluev / suppgram

Simple Telegram-based support system written in Python
https://suppgram.readthedocs.io
MIT License
22 stars 2 forks source link

Quickstart, While trying to "Assign to me" a conversation, i get exception #1

Open ermolalex opened 1 month ago

ermolalex commented 1 month ago

While trying to "Assign to me" a conversation, i get exception: ERROR:telegram.ext.Application:No error handlers are registered, logging exception. Traceback (most recent call last): File "/home/alex/Suppgram/venv/lib/python3.10/site-packages/telegram/ext/_application.py", line 1264, in process_update await coroutine File "/home/alex/Suppgram/venv/lib/python3.10/site-packages/telegram/ext/_handlers/basehandler.py", line 157, in handle_update return await self.callback(update, context) File "/home/alex/Suppgram/venv/lib/python3.10/site-packages/suppgram/frontends/telegram/manager_frontend.py", line 394, in _handle_callback_query await self._backend.assign_agent(agent, agent, conversation_id) File "/home/alex/Suppgram/venv/lib/python3.10/site-packages/suppgram/backends/local.py", line 176, in assign_agent workplace = await self._choose_workplace(assignee) File "/home/alex/Suppgram/venv/lib/python3.10/site-packages/suppgram/backends/local.py", line 269, in _choose_workplace return available_workplaces[0] # TODO handle index out of range IndexError: list index out of range

Saluev commented 1 month ago

Hi! Can you show how you run it? (Don't forget to censor bot tokens.) Absence of available workspaces might mean that you didn't specify any tokens for agent bots.

ermolalex commented 1 month ago

I have inserted prints in code of local.py: async def _choose_workplace(self, agent: Agent) -> Workplace: existing_workplaces = await self._storage.get_agent_workplaces(agent) print('***', existing_workplaces) extra_workplaces = await self._create_all_missing_workplaces(agent, existing_workplaces) print('***', extra_workplaces) all_workplaces = existing_workplaces + extra_workplaces available_workplaces = await self._filter_all_available_workplaces(agent, all_workplaces) print('***', available_workplaces) return available_workplaces[0] # TODO handle index out of range

and get:

* [Workplace(id=1, telegram_user_id=542*18, telegram_bot_id=69929, agent=Agent(id=1, deactivated=False, telegram_user_id=542**18, telegram_first_name='Александр', telegram_last_name=None, telegram_username=None))] ** [] []

Saluev commented 1 month ago

Hmmm. Is it possible that the only agent bot you have is already taken? Does this traceback happen on first "Assign to me" click or second?

By the looks of it I'll definitely have to fix the exception, but still if you've exceeded chats capacity you're not going to be able to assign a conversation to yourself.

ermolalex commented 1 month ago

I think it was second click. Moreover, i missed step "go to the Agent bot and click "Start"" When i sent /postpone to agent bot, everything is running. You can close issue. Thank you!