Add customisable From display name template for outgoing emails#249
Add customisable From display name template for outgoing emails#249josephsellers wants to merge 2 commits intoabhinavxd:mainfrom
Conversation
|
Hey, Thanks a lot for the PR! |
|
Heads up: I've rebased this branch to remove an unrelated commit (delete private notes API) that was accidentally included. The force push drops that commit — this PR now only contains the From display name template changes as intended. Sorry for the noise! |
490a27c to
75d134a
Compare
|
Hey, I missed this will check over this weekend. |
Allow inbox admins to configure a Go template that controls the
display name in the From header of outgoing emails. When set, agent
and inbox name variables are rendered into the display name while
keeping the inbox email address unchanged.
Template variables: .Agent.FirstName, .Agent.LastName, .Agent.FullName,
.Inbox.Name
Example: "{{ .Agent.FirstName }} at {{ .Inbox.Name }}" renders as
"Jane at Rokesmith Support <support@rokesmith.com>"
Empty template (default) preserves current behaviour.
[Used Claude Code 🤖]
75d134a to
4283299
Compare
|
I've updated the migration to use a descriptive function name ( |
| {"v0.10.0", migrations.V0_10_0}, | ||
| {"v1.0.1", migrations.V1_0_1}, | ||
| // TODO: version TBD -- maintainer to assign the next migration version. | ||
| {"v1.0.2", migrations.FromNameTemplate}, |
There was a problem hiding this comment.
We can add it to the next version v1.1.0
| ) | ||
|
|
||
| // FromNameTemplate adds the from_name_template column to the inboxes table. | ||
| func FromNameTemplate(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error { |
There was a problem hiding this comment.
This migration should go into the v1.1.0.go file. Similar to other migrations in this app.
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
We should skip this if the sender is a System user, as System user sends automated emails.
And log all errors, plus there could be a validation on the frontend for golangs template syntax.
As right now if someone puts incorrect value they would never know what happened.
- Move migration to v1.1.0.go following existing naming convention - Skip System users (automated emails) in template rendering - Log all template errors instead of silently falling through - Add frontend validation for balanced delimiters and known variables [Used Claude Code 🤖]
|
Thanks for the review! I've pushed a commit addressing all three points: Migration (v1.1.0): Renamed the file to System user skip: Added an explicit Error logging: All four error paths (agent fetch, address parse, template parse, template execute) are now logged. The fallback behaviour is the same: if anything fails, the inbox's From address is used as-is and the email still sends. Frontend validation: Added two checks on the form field: balanced |
|
Hi there's a merge conflict due to recent live chat PR merge. |
Closes #248
Summary
from_name_templatefield to inboxes that allows admins to customise the From display name on outgoing emails using Go template syntaxTemplate variables
{{ .Agent.FirstName }}{{ .Agent.LastName }}{{ .Agent.FullName }}{{ .Inbox.Name }}Changes
from_name_template TEXT NOT NULL DEFAULT ''column oninboxessendOutgoingMessage(), plumbed through inbox models/queries/interface/email channelTest plan
Happy to make adjustments based on feedback.