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

Allow users to configure incoming webhook bots according to specific parameters (backend implementation) #13029

Closed
wants to merge 4 commits into from

Conversation

Hypro999
Copy link
Member

@Hypro999 Hypro999 commented Aug 18, 2019

Commit 1: Specify config options for an incoming webhook integration.

Basically just update the necessary classes to allow a "bot_config" parameter.

In integrations.py we have a class called Integration which we then usually
subclass and then use to define the meta-data for all of our integrations.
Now, we want to allow all of our bots, specifically incoming webhook bots,
to be configured (i.e. we should let the user provide BotConfigData).

For this we create a new instance member of the Integration class called
config_options which will be a list of tuples containing the displayable
integration name, the configuration key form of the integration name and
the validator that it's value is supposed to adhere to.

Commit 2 (prep commit): Have check_valid_bot_config also take the bot_type.

With this the logical flow of code in the view function can be the same for incoming webhook bot as with embedded bots.

This is a prep commit to allow us to validate user provided bot
config data using the same function for incoming webhook type
bots alongside embedded bots (as opposed to creating a new
function just for incoming webhook bots).

Commit 3: Allow incoming webhook bots to be configured via. /bots endpoint.

Use the bot_config parameter to now allow the backend to receive configuration preferences from users and then do checking before creating the bot or configuration objects.

Without disturbing the flow of the existing code for configuring
embedded bots too much, we now use the config_options feature to
allow incoming webhook type bot to be configured via. the "/bots"
endpoint of the API.

@timabbott can you please review this? After this gets merged, I'll apply it to #10907.

@Hypro999
Copy link
Member Author

Hypro999 commented Aug 18, 2019

Force pushing to re-trigger circle-ci builds. Also, I forgot to commit the documentation changes.

@Hypro999
Copy link
Member Author

Added 1 more commit to send the config_options along with the initial state so that the frontend can use it in page_params (just like with embedded bots).

In integrations.py we have a class called Integration which we then usually
subclass and then use to define the meta-data for all of our integrations.
Now, we want to allow all of our bots, specifically incoming webhook bots,
to be configured (i.e. we should let the user provide BotConfigData).

For this we create a new instance member of the Integration class called
config_options which will be a list of tuples containing the displayable
integration name, the configuration key form of the integration name and
the validator that it's value is supposed to adhere to.
This is a prep commit to allow us to validate user provided bot
config data using the same function for incoming webhook type
bots alongside embedded bots (as opposed to creating a new
function just for incoming webhook bots).
Without disturbing the flow of the existing code for configuring
embedded bots too much, we now use the config_options feature to
allow incoming webhook type bot to be configured via. the "/bots"
endpoint of the API.
Send the config_options for each supported incoming webhook bot along
with the initial state (not present in apply_events since this is
mostly just static data).
@timabbott
Copy link
Sponsor Member

Merged, after a few changes to strings and making the documentation block tighter, thanks @Hypro999!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants