Open kanak8278 opened 1 month ago
We need to store API_HOST as well. Until now we were only storing API_KEY against the channel type/name. For e.g. the channel settings for a given bot were stored as follows:
{
"whatsapp": "xlslkdfslkdfjslfd"
}
This needs to move to:
{
"whatsapp": {
"key": "xlslkdfslkdfjslfd",
"host": "https://api.whatsapp.com"
}
}
Phone number also is channel specific. However, we can't make that change immediately because JBBot's primary key is phone number. This needs to be done in a separate issue/PR.
Given that JBBot data model is Column(JSON). We don't need to change it. It can accommodate the change in structure that we want. However, the values need to be flushed out i.e. we need to add a step for alembic migration to delete all the bots.
We will stick to this naming convention. key
, host
Every helper in the lib/whatsapp.py (https://github.com/OpenNyAI/Jugalbandi-Manager/blob/main/lib/whatsapp.py) needs to take API host along with wa_api_key. Change to match naming convention.
WA_API_HOST needs to come from bot_channel_credentials
(https://github.com/OpenNyAI/Jugalbandi-Manager/blob/2c522e3bd578444d420082e89ba4e5d7b446534a/channel/src/__main__.py#L178 ). Change naming convention.
/bot/{id}/activate for whatsapp needs to also store a host. See https://github.com/OpenNyAI/Jugalbandi-Manager/blob/2c522e3bd578444d420082e89ba4e5d7b446534a/api/app/main.py#L139
Also we need to encrypt a nested dict https://github.com/OpenNyAI/Jugalbandi-Manager/blob/2c522e3bd578444d420082e89ba4e5d7b446534a/api/app/main.py#L168C16-L168C28
Add api_host for Whatsapp https://github.com/OpenNyAI/Jugalbandi-Manager/blob/2c522e3bd578444d420082e89ba4e5d7b446534a/frontend/src/components/project/project.tsx#L57
Add validation for capture api_host https://github.com/OpenNyAI/Jugalbandi-Manager/blob/2c522e3bd578444d420082e89ba4e5d7b446534a/frontend/src/components/settings-model/index.tsx#L62
data['channels']['whatsapp'] = inputElements['whatsapp'].value;
this data structure needs to change because we not only need to store API_KEY but also API_HOST (potentially others)
data['channels'][
@shreypandey the PR you have linked to doesn't solve the issue across all the layers. Please see the comment carefully. This change needs to be implemented across Frontend layer as well. The #21 doesn't seem to touch Frontend and it's not clear that it's has addressed all the points in API, Channel, and Lib layers
@sameersegal The PR #21 contains the changes for custom channel implementation which implicitly addresses the issue of storing API host along API key for different channels for each bot.
Describe the bug
Currently WA_API_HOST need to be mentioned in the .env-dev, move it to JB Manager UI, along with the other Whatsapp configs.
Steps to reproduce
No response
Expected Behavior
No response
Screenshots and logs
No response
Additional Information
No response