You can use event rules to filter events and route events to Short Message Service (SMS). This topic describes the procedure for routing custom events to SMS.
Prerequisites
EventBridge is activated. For more information, see Activate EventBridge and grant permissions to a RAM user.
A signature and an SMS template are added.
Step 1: Add a custom event source
Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
In the top navigation bar, select a region. On the Event Buses page, click the name of the custom event bus that you want to manage.
In the left-side navigation pane, click Event Sources and then click Add Event Source.
In the Add Custom Event Source panel, configure the Name and Description parameters, select Custom Application from the Event Provider drop-down list, and then click OK.
Step 2: Create an event rule
The event targets that you want to configure for an event rule must reside in the same region as the event rule.
Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
In the top navigation bar, select a region. On the Event Buses page, click the name of the event bus that you want to manage.
In the left-side navigation pane, click Event Rules. On the page that appears, click Create Rule.
In the Create Rule wizard, perform the following steps:
In the Configure Basic Info step, enter a rule name in the Name field and a rule description in the Description field. Then, click Next Step.
In the Configure Event Pattern step, set the Event Source Type parameter to Custom Event Source and select the custom event source that you configured in Step 1 from the Event Source drop-down list. Then, in the Pattern Content code editor, specify an event pattern and click Next step.
For more information, see Event patterns.
In the Configure Targets step, configure event targets and click Create.
NoteUp to five targets can be configured for an event rule.
Service Type: Select Short Message Service.
Phone Number: Select a method to obtain the mobile number.
Partial Event: Obtain the mobile number by defining a field in the data parameter, Example:
.data.mobile.Fixed Value: Enter the mobile number of the recipient.
NoteSeparate multiple mobile numbers with commas (,).
Signature: Enter the signature that is approved in the SMS console.
Template Code: Enter the template code that is approved in the SMS console.
Template Parameters: Events are routed in the format that is defined in a custom template to event targets. You can customize parameters in the template.
The following part shows sample parameters and a sample template:
Sample variables:
{ "mobile":"$.data.mobile", "subject":"$.subject" }Sample template:
{ "code":"${subject}" }For more information, see Event transformation.
Step 3: Publish an event
Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
- In the top navigation bar, select a region.
- On the Event Buses page, find the event bus to which you want to publish an event and click Publish Event in the Operations column. Note You can publish events only to custom event buses in the EventBridge console.
- In the Publish Event to Custom Event Bus panel, select a custom event source from the Custom Event Source drop-down list, enter the event content in the Event Body code editor, and then click OK. For more information about the event parameters, see Overview.