Installing
The library is installed as a standard limeplug:
$ limeplug install traml
The most common usage for traml
is to send an email based on an event in Lime CRM. If your addon doesn't have an event-handler already, you can add one:
$ lime-project generate event-handler
Configuration
The following BizWizard configuration parameters are required:
- api-key
- URL
- username (email address)
⚠️ Make sure your customer/user has a BizWizard account!
Add your credentials to C:\ProgramData\Lundalogik\LIME Pro Server\Event Handler\configs\Event Handler\configs\config.ini
[plugins.traml] apikey=<string> apiurl=<string> apiuser=<string> dryrun=true
⚠️ See 'DRY-RUN' section below for more information.
Usage
Step 1: Import the library into your addon:
import transactional_message_library.traml as traml
Step 2: Initialize the library event handler:
Inside your-addon-folder/event_handlers/__init__.py
, at the bottom of the register_event_handler
function, add the following line:
traml.register_event_handler(worker, 'my-addon')
Change my-addon
to a unique name. It's important that you chose a unique name in case your solution has several addons using TRAML.
Step 3: Inside your eventhandler or your limeobject class, add Email
instances to an empty list:
emails = [] emails.append( traml.Email( sender_name='Agent X', sender_email='[email protected]', subject='Helpdesk status changed to assigned', recipient_name='Agent Y', recipient_email='[email protected]', template_name="standard text", merge_codes=dict( monkey='Orangutang', katt='Nisse' ))) # append some more emails...
Step 4: Tell the library to send the new emails:
traml.notify(application, 'my-addon', emails)
Step 5: Profit 🥇
Dry Run Mode
It's possible to test-drive TRAML without actually sending any emails. By setting the configuration parameter dryrun
to true
, you can check that everything is working as expected, up to the point of actually posting to the bedrock API. TRAML will log the following info to the standard logger:
*** TRAML DRY RUN MODE *** Ready to POST 7 message(s) to the API but will stop here.
Make sure to set dryrun
to false
before deploying to production or no emails will be sent out!