amplify
amplify copied to clipboard
[Function] Update lob function to append with from
We need to take user input and pass it with merge variable {{constituent_input}}. Template id: tmpl_7aaf42aada49f44
Directions
In File https://github.com/ProgramEquity/amplify/blob/2f7cb92e3140c8753b68abf1ac3c71750b130c47/server/routes/api/lob.js It currently checks payment before creating. We need to check payment from Stripe and if there is a merge variable. If there is, we append it to the object instance of letter template ID. Change after lines 159:
- [ ] Copilot Chat Prompt: Check for stripe payment and if a merge variable exists
- [ ] Copilot Chat Prompt: If merge variable exists, append to letter template ID as variable named constituent_input
- [ ] Copilot Chat Prompt: Highlight appended code and type /tests
Context:
To add a merge variable to the createLetter route handler, you can modify the template_id parameter to include the merge variable in the format of {{merge_variable}}. Here are the steps you can follow:
Modify the template_id parameter in the request body to include the merge variable: name This code sets the template_id parameter to include the merge variable in the format of {{merge_variable}}.
Modify the template in your Lob account to include the merge variable in the same format as the template_id parameter. For example, if your template_id parameter is tmpl_12345{{merge_variable}}, your template should include the merge variable in the format of {{merge_variable}}.
Modify the createLetter route handler to replace the merge variable with the actual value before creating the letter. For example, you can replace the merge variable with the recipient's name:
This code sets the merge_variables parameter to an object that maps the merge variable name to the actual value, and passes it to the lob.letters.create method to create the letter.
That's it! With these changes, you should now be able to add a merge variable to the createLetter route handler. Note that you will need to replace 'tmpl_12345{{merge_variable}}' with your actual template ID and merge variable name, and modify the template in your Lob account to include the merge variable.
@tdo95
Use a variable name like
user_inputoruser_testimony.
@manishapriya94 Please add some screenshots of the templates to help contributor(s) work on this issue.
Hi @paramsiddharth - I added the merge variable userCustomMessage to the request body schema for creating a letter in lob. js. Next step is to edit the templates in ProgramEquity's lob account to include the merge variable {{custom_message}}. Let me know if I'll be able to access the Lob account, or if this is something you'll be able to help with. Thanks!
@rsensenig Good work, Rachel! 😊 I replied to your text on Slack (pardon my delay in doing so!) – If possible, please point me to the respectiver branch/draft PR (create one if you haven't already).