Views:

Scenario Overview

This is a technology sample that demonstrated how to send a text messages to a Contact using a REST API call to Upwire.

You can sign up for a free trial account here.

We are accessing Upwire's Send Raw SMS web service via the CallRestAPI() function call in North52 BPA.
This will demonstrate how to create a JSON Object with North52 and then use it in the CallRestAPI() function.

For this sample when the Description field on a Contact is changed we will automatically text the contents to the Contact. 

North52 Decision Suite

The BPA solution works like this,

  • Formula of type 'Save Perform - Action' is created on the Contact entity
  • The Event is set to Update
  • The Source Property is set to Description
  • We first use CreateJObject() to create a JSON Object 
  • Then we add each key/value pair to the the Object using the CreateJProperty() function
  • Finally we pass the Object into the Rest API call using SetRequestParams() function
  • Upwire supports JSON of type application/json so we identify our object as this type in the first parameter in the SetRequestParams() function.


 

N52 BPA Steps

The following set of steps outline how to create this Formula

  • Create a formula of type 'Save - Perform Action' on the Contact entity
  • Set the Source Properties as Description
  • Copy and paste the formula below into the formula canvas
  • Add in your Username / Password
  • Save and test!

Formula

SmartFlow(  
  SetVar('jsoninput', 
    CreateJObject( 
          CreateJProperty('username”','patrickmci@north52.com'),
          CreateJProperty('password','******************************'),
          CreateJProperty('templateId',''),
          CreateJProperty('allowDuplicates','True'),
          CreateJProperty('callerid','North52'),
          CreateJProperty('jobReference','JobRef238845'),
          CreateJProperty('billcode','SB-API-TEST'),
          CreateJProperty('customReference',''),
          CreateJProperty('columnPhone',''),
          CreateJProperty('columnReference',''),
          CreateJProperty('message',[contact.description]),
          CreateJProperty('destinations',[contact.mobilephone]),
          CreateJProperty('data',''),
          CreateJProperty('features','')
    )
  ),

  CallRestAPI(
    SetRequestBaseURL('https://a.upwire.com/zsms/new.json'),
    SetRequestResource(),
    SetRequestDetails('POST'),
    SetRequestHeaders(),
    SetRequestParams('RawContentApplicationJSON',GetVar('jsoninput')),
    SetRequestAuthenticationBasic(),
    SetRequestFiles(),
    SetRequestExpected('OK'),
    SetRequestActionPass(SetVar('result', GetVarJsonValue('jobnumber'))),
    SetRequestActionFail(SetVar('result', 'ERROR' + GetVarJsonValue('message')))
  ), 

  SmartFlowReturn(GetVar('result'))
)