-
Notifications
You must be signed in to change notification settings - Fork 20
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
WIP support WA template params #1199
Closed
Closed
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
47a9985
WIp support WA template params
norkans7 e9d3824
Add TemplateParam struct and remove unused components field
norkans7 80a02c5
Update tests for params
norkans7 54710ac
Add UUID field templateParam so we can properly support localization …
norkans7 8e80ddc
Adjust templateParam type and struct
norkans7 5e8be07
Adjust templateParam type for static assets
norkans7 55cc248
Extract function to get message from templating
norkans7 5ed7d0d
More tests
norkans7 3f0580a
Use predictable quick replies indexes
norkans7 3497663
More tests
norkans7 b7208db
Replace TemplateParam with ComponentsVariables
norkans7 89da1a5
Make sure old template Variables are passed as body template params
norkans7 4aa514e
Merge pull request #1201 from nyaruka/compVariables
rowanseymour 3af0c28
Merge branch 'main' into WA-template-params
rowanseymour File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,16 +43,20 @@ type TemplateTranslation struct { | |
Locale_ i18n.Locale `json:"locale" validate:"required"` | ||
Namespace_ string `json:"namespace"` | ||
VariableCount_ int `json:"variable_count"` | ||
Components_ []map[string]any `json:"components"` | ||
Params_ map[string][]any `json:"params"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no reason not to use a struct for param There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
} | ||
|
||
// NewTemplateTranslation creates a new template translation | ||
func NewTemplateTranslation(channel *assets.ChannelReference, locale i18n.Locale, content string, variableCount int, namespace string) *TemplateTranslation { | ||
func NewTemplateTranslation(channel *assets.ChannelReference, locale i18n.Locale, content string, variableCount int, namespace string, components []map[string]any, params map[string][]any) *TemplateTranslation { | ||
return &TemplateTranslation{ | ||
Channel_: channel, | ||
Content_: content, | ||
Namespace_: namespace, | ||
Locale_: locale, | ||
VariableCount_: variableCount, | ||
Components_: components, | ||
Params_: params, | ||
} | ||
} | ||
|
||
|
@@ -70,3 +74,9 @@ func (t *TemplateTranslation) VariableCount() int { return t.VariableCount_ } | |
|
||
// Channel returns the channel this template translation is for | ||
func (t *TemplateTranslation) Channel() *assets.ChannelReference { return t.Channel_ } | ||
|
||
// Components returns the components for this template translation | ||
func (t *TemplateTranslation) Components() []map[string]any { return t.Components_ } | ||
|
||
// Params returns the params for this template translation | ||
func (t *TemplateTranslation) Params() map[string][]any { return t.Params_ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we only use Content for generating a preview of the message so I guess components would be the same... couldn't these just be strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep using content for the preview here and make sure each template has that generate properly when syncing them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tho wouldn't we want to convert button components into quick replies etc? I kinda hate putting whatsapp specific knowledge in the engine, right in the send_msg action but I don't see any other way. Let's just try to isolate it in a single function for now that takes a template + parameters and returns a
MsgOut
.The other way to approach this would be to put the onus on the UI to render a preview of the message based on the templating data.. but then the message still looks empty in API fetches, archives etc, so I think I prefer having the engine continue to create a preview.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah ideally we need have the quick replies turned/matched to the buttons of the templates
I have not thought of quick replies so far, I want to make sure we support all components for templates and see how to make the QRs and buttons merged