...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
ruleset io.picolabs.twilio_v2 { meta { configure using account_sid = "" auth_token = "" provides send_sms } global { send_sms = defaction(to, from, message) { base_url = <<https://#{account_sid}:#{auth_token}@api.twilio.com/2010-04-01/Accounts/#{account_sid}/>> http:post(base_url + "Messages.json") with , form = { "From":from, "To":to, "Body":message }) } } } |
The configure
pragma's defaults are the empty string since there's no workable default for the Twilio keys. You can see that those variables are referenced in the send_sms()
action to create the based URL for the Twilio call.
...
Code Block | ||||
---|---|---|---|---|
| ||||
ruleset io.picolabs.use_twilio_v2 { meta { use module io.picolabs.twiliolesson_keys use module io.picolabs.twilio_v2 alias twilio with account_sid = keys:twilio("account_sid") auth_token = keys:twilio("auth_token") } rule test_send_sms { select when test new_message twilio:send_sms(event:attr("to"), event:attr("from"), event:attr("message") ) } } |
...