tactilenews / 100eyes

Dialogtechnologie für den Pivot to People invented by tactile.news GmbH
MIT License
10 stars 1 forks source link

Fix welcome message template creation/usage #2049

Closed mattwr18 closed 1 month ago

mattwr18 commented 1 month ago

What changed in this PR and Why

This adds a job to create a new welcome message template, which is the only use case at the moment. Adding new request templates is not covered because there is no way to change them from the client side.

This also takes into account that multiple organizations can use an instance and they need to have the ability to create their own welcome messages with unique template names/text.

Fixes #2033

mattwr18 commented 1 month ago

Yeah, we want to create a welcome message for the client after they update the default welcome message with their customized one. So, in theory we could trigger the job from the after_update_commit on the organization, which checks if either of the values that the welcome message is composed of have changed.

The issue with this is that the names must be unique. So, the first time they update it, it should work, but if they update it again, we need to delete the outdated one, wait some time, and then request a new one with the same name.

We could send a request to get all template names for the client, see if they already have a dynamic welcome message and delete it, in the case they do. Then, we could schedule a job to create a new one some time later.

roschaefer commented 1 month ago

Yeah, we want to create a welcome message for the client after they update the default welcome message with their customized one. So, in theory we could trigger the job from the after_update_commit on the organization, which checks if either of the values that the welcome message is composed of have changed.

The issue with this is that the names must be unique. So, the first time they update it, it should work, but if they update it again, we need to delete the outdated one, wait some time, and then request a new one with the same name.

We could send a request to get all template names for the client, see if they already have a dynamic welcome message and delete it, in the case they do. Then, we could schedule a job to create a new one some time later.

Urgh. That's quite an error-prone procedure and it doesn't have great good UX either. Shall we inform the user when they update the welcome message that we need to be informed and do things manually at least?

mattwr18 commented 1 month ago

Urgh. That's quite an error-prone procedure and it doesn't have great good UX either. Shall we inform the user when they update the welcome message that we need to be informed and do things manually at least?

We already send out an email to all admin of the instance when someone updates either attribute that is used to make up the welcome message. See notify_admin_of_welcome_message_change. This is my call to action to do something. We could do as I described :point_up: , but I after looking at the documentation for templates, I noticed that we can edit templates in the 360dialog hub. I've just tested this out and it worked, so there is no need to delete and re-create the template.

mattwr18 commented 1 month ago

In general it's quite hard for me to review, but I'll give this an "Approve" because I cannot see any serious issue. Also the VCR cassette makes me a little less nervous.

That's why I added it. To be honest, there are still some jobs that don't have tests, but they weren't added in this PR so I've left it as is for now.