Introduction
This article describes how to create a task that processes incoming SMS requests which request account balance statuses.
For this article, we will use the BPA Platform training database in place of a live customer database; where appropriate, substitute database and account details for your own when building this task. It is also assumed you have a ToucanText account with an inbound mobile number assigned.
The Scenario
Your customers have a credit limit on the accounts they have with your company. They can request the current balance for their account by texting the phrase BAL followed by their account number to a number you have set up in ToucanText, for example, BAL ASL001.
To fulfil this scenario, two tasks are required: the first to retrieve the balance for the requested account, and the second to process the incoming and outgoing data.
Part 1: Retrieving the Account Balance
This task retrieves the balance for the requested account number.
Required Tools
| ► | Parse Text |
| ► | Database Query (ODBC) |
| ► | Run VBScript |
The following exercises only focus on the settings needed to fulfil the task. For a detailed description of how to use each tool, refer to the product help.
Part 1A — Creating Task Variables
We use task variables
Variables are created and used extensively throughout and can either have fixed values or values that are dynamically populated when a task is run.
Task variables are only available for the specific task they are created for. Users with Task Administrator rights can create task variables. to ensure all aspects of the task are processed according to the account number sent by the customer. Task variables are created in the task itself and are not available for use by other tasks.
- Launch the BPA Platform client.
- Create a new task called Message Processing Task.
- Go to the Design tab.
- From the Task Browser, go to the Environment tab.
- Change Scope to be Task.
- Right-click on Variables and select New.
- Name the variable: MessageRequest.
- Go to the Details tab.
- Set Type to be Variant.
This ensures the variable can store any type of text.
- Enable Parameter.
This ensures the variable can store task data.
- From the Parameter Attributes, select In.
This indicates the variable only receives data for its values.
- From the Scope drop-down, select Task Instance.
This ensures the variable is reset every time the task completes — we don't want the task to fire for the same account number.
- Click OK to save the variable.
- Create the remaining task variables with the following details:
| Name | Type | Parameter Attributes | Scope |
|---|---|---|---|
| Balance | Variant / Parameter | Out | Task Instance |
| SenderNumber | Variant / Parameter | In, Out | Task Instance |
| AccountNumber | Variant / Parameters | In, Out | Task Instance |
- Save and Close the task.
Part 1B — Creating the Connection to the Database
You must create a connection to the training database that can be used by any task — this is referred to as a "global connection".
- Launch BPA Platform.
- From the resources tree, go to System > Tools > Data Connectors > Database Query (ODBC).
- Click Add.
- Expand ODBC Drivers and select SQL Server.
- Click OK.
- Choose (local) from the Server drop-down as the SQL Server database is on the same training machine. If your machine has multiple database instances or uses a remote connection to SQL Server, select the relevant server.
- We must supply the credentials for this database as we are not using Windows authentication; clear the selection for Use Trusted Connection and the enter the credentials used to access SQL Server.
- Click Options.
- Choose BPAPlatformTrainingDB from the Database drop-down.
- Leave all other settings with their default values, and click OK.

- Configure a meaningful name for this ODBC data source, then click OK.
The new connection appears in the ODBC Connections window.
- Use Test to ensure a working connection.
Part 1C — Extracting the Account Number from the Received SMS
The SMS message contents are saved to the MessageRequest variable by a different task. This stage extracts the account number from the variable — we use the Parse Text tool for this.
- Open the Message Processing Task.
- Add a Parse Text step to the design area.
- Name your step: Extract Account Number.
- Go to the Main tab.
- From the Task Browser, go to the Environment tab.
- Change Scope to be Task.
- From the Variables node, drag the MessageRequest variable to Data in the Main tab.
- Click Add to create a new rule.
- Name this rule: Remove BAL.
- Change Type to be: Extract after word [C].
- In the Parameters table, enter BAL as the Value — the Parse Text step will look for this phrase and extract everything after it.
- From Variable output, select the AccountNumber variable created previously.
- Enable Remove leading spaces and Remove trailing spaces.
- Click OK to save the rule and OK again to save the changes in the Parse Text step.
Part 1D — Extracting the Account Information
We now need to retrieve the account balance according to the account number received. We do this using the Database Query (ODBC) tool.
- Ensure Part 1B — Creating the Connection to the Database has been completed first.
- Open the Message Processing Task.
- Add a Database Query (ODBC) step to the design area.
- Name the step: Retrieve Balance and Account.
- From the Connection drop-down, select the global connection created in Part 1B.
- Go to the Query tab — here, we specify the columns that contain the data we are interested in.
Tip: The extracted data forms a BPA Platform recordset which can be used by other task steps to "forward the data" on.
- Expand the SALES_LEDGER table and drag the following columns into the Columns pane:
| ■ | ACCOUNT_REF |
| ■ | TELEPHONE_2 |
| ■ | BALANCE |
Click the image to view full size.
- The query we have created so far extracts all accounts, telephone numbers, and balances; we just want the details for the account number sent in the SMS request. We do this by adding the account number extracted in Part 1C — Extracting the Account Number from the Received SMS
- Drag ACCOUNT_REF from the Columns pane to the Criteria pane.
- From the Select a criteria drop-down, choose equals [C].
- From the Task Browser, go to the Environment tab.
- Change Scope to Task.
- From the Variables node, drag AccountNumber to the ACCOUNT_REF criteria.
Click the image to view full size.
- For extra security, we can also match the mobile number held for this account to the number that sent the SMS. This ensures only valid contacts receive the balance response.
- Drag TELEPHONE_2 from the Columns pane to the Criteria pane.
- From the Select a criteria drop-down, choose equals [C].
- From the Task Browser, go to the Environment tab.
- Change Scope to Task.
- From the Variables node, drag SenderNumber to the TELEPHONE_2 criteria.
The AND between the two criteria indicates that both entries must be met to continue.
- Click OK to save the query.
Part 1E — Saving the Balance to a Variable
The final step of this task makes the retrieved balance available for the second task. You use the Run VBScript tool for this.
- Open the Message Processing Task.
- Add a Run VBScript step to the design area.
- Name the step: Balance.
- Got to the Main tab.
- From the Task Browser, go to the Environment tab.
- Change Scope to Task.
- From the Variables node, drag Balance to the script area followed by <space>=<space>.
- From the Task Browser, expand Steps > Retrieve Balance and Account > Recordset and drag BALANCE to complete the current line.
The script should now look like:

- Click OK to save the step.
Part 1F — Linking the Steps
To ensure BPA Platform runs the steps in the correct order, the individual task steps must be linked. You do this by clicking a step to display the step controls — click and hold
and draw the connector to its successor.
If required, you can add a label to the connection. Double-click the connection line and add the label, up to a maximum of 100 characters. Note that this is a pure-text field so variables, formulas, functions, and Task Browser properties cannot be used in this area.
- Link Extract Account Number to Retrieve Balance and Account.
- Link Retrieve Balance and Account to Balance.
Your task should now look like this:

- Click OK to save this task.
That completes part 1 of this scenario. In parts 2 and 3, we're going to create the task that handles the sending of the account balance back to the sender.
Part 2: Processing the Inbound SMS Request
This task retrieves the inbound SMS requesting the balance.
Required Tools
| ► | Retrieve Text Message |
| ► | Call Task |
| ► | Decision |
| ► | Run VBScript — This step ends the task if there are no more SMS requests to process |
The following exercises only focus on the settings needed to fulfil the task. For a detailed description of how to use each tool, refer to the product help.
Part 2A — Creating the Connection to ToucanText
You must create a connection to your ToucanText account to retrieve the incoming SMS requests.
- Launch the BPA Platform client.
- From the resources tree, go to System > Tools > Input > Retrieve Text Message.
- Click Add.
- Enter a meaningful Name for this connection.
- Enter the API Username and API Password for your ToucanText account.
- Click Test to ensure the connection can be made.
- Click OK then OK again to save the connection.
Part 2B — Retrieving the Inbound SMS Requests
For this part of the business process, we will create a new task to handle this part.
- Create a new task in the same location as the Message Processing Task created in Part 1: Retrieving the Account Balance.
- Name this task: Picks Up Inbound Messages.
- Go to the Design tab and add a Retrieve Text Message step.
- Leave this with its default name and ensure No data source is selected as the Data source.
- Go to the Connection tab.
- Select the Connection created in Part 2A — Creating the Connection to ToucanText.
- Go to the Mapping tab.
- From the Object drop-down, select Message.
- From the Operation drop-down, select Retrieve Inbound Message.
- Now we need to add two new task variables:
| Name | Type | Parameter Attributes | Scope | Default Value |
|---|---|---|---|---|
| ACK | Variant | N/A | Task Instance | true |
| MaxMsgCount | Variant | N/A | Task Instance | 50 |
- Drag both variables to the input data source pane (left) in the Mapping tab.
- Map the ACK variable to the AcknowledgeMessages field — this sends an acknowledgement back to ToucanText that the inbound message has been picked up and processed by the task so must not be included in future message requests.
- Map the MaxMsgCount to the MaxMessageCount field — this is a required field that must be mapped to and controls the number of messages that are retrieved from ToucanText for this task instance.
Click the image to view full size.
- Click OK to save and close the step.
Part 2C — Initiating the Message Processing Task
The next stage of the task is to send the details from the Retrieve Text Message step to the Message Processing Task. You do this with the Call Task tool. First, we need to create a global connection to the folder containing the task — even if you have placed your tasks in the top-level Tasks folder, you must still create the connection.
Creating a Dedicated Call Task User
We must create a dedicated user for the Call Task step to use — this prevents clashes with other user accounts that may be logged into the BPA Platform client at the same time:
- Save and close the Picks Up Inbound Messages task.
- From the resources tree, right-click on Users and select New User.
- Enter calltask as the User name.
- Enable BPA Platform Authentication and enter a password that adheres to your organisation's security policies. Confirm the password.
- Go to the Server Roles tab and ensure all server roles are cleared.
- Click OK to save and close the user.
Creating the Global Connection to the Task Folder
Now we can create the global connection to the relevant task folder:
- From the resources tree, go to System > Tools > Execute > Call Task.
- Click Add.
- Enter a Connection Name of Balance Enquiry Tasks.
- As the tasks are run on the same computer as this BPA Platform client, enter localhost as the Server.
- Enter the calltask user's details in Username and Password.
- Go to the Folder tab and select the folder containing these tasks.
- Click OK to save and close the global connection.
Click the image to view full size.
Adding the Call Task Step
Finally, we add a Call Task step to the task.
- Open the Picks Up Inbound Messages task.
- Add a Call Task step to the task design area.
- Name this step Call Message Processing Task.
- Enable Task step and ensure Output Data from Retrieve Text Message is selected in the drop-down.
- Go to the Connection tab and select the connection created previously.
- Go to the Mapping tab.
- From the Object drop-down, select Message Processing Task.
- From the Operation drop-down, select Run Sync — this operation ensures that the Picks Up Inbound Messages task is paused until the Message Processing Task is finished so that the generated task data from the Message Processing Task can be used.
- Make the following mappings:
| ■ | SourceAddress » SenderNumber |
| ■ | MessageContents » MessageRequest |
Click the image to view full size.
- Click OK to save and close the step.
Part 2D — Ensuring the Task Only Runs When There's a Message to Process
In this exercise, we're going to add logic to the task to check whether there are any unprocessed inbound messages. If there are none, the task terminates cleanly. Without this, the task will attempt to initiate each step in the task which results in the Event Log being filled with failed task messages.
- Add a Decision step to the Picks Up Inbound Messages task — this chooses whether the task should continue based on rules you add.
- Name this step: Any more messages?.
- Click Add.
- Name this branch: Yes.
- From the To drop-down, select Call Message Processing Task.
- Go to the Script tab.
- From the Task Browser, go to the Environment tab.
- Change Scope to Task.
- Expand Steps > Retrieve Text Message and drag the MessageCount node to the Expression box.
- Add
>0to the end of the expression so you have:Steps("Retrieve Text Message").MessageCount>0 - Click OK to save this branch.
Now we need to add the No branch.
- Click OK to save and close the Decision step so far.
- Add a Run VBScript step to the task.
- Name this step: No Messages.
- No further configuration or scripting is required for this task so click OK to save and close the step.
- Re-open the Decision step and click Add to add a new branch.
- Name this branch: No.
- From the To drop-down, select No Messages.
- Go to the Script tab and enable Else — this is the catch-all branch that indicates whatever doesn't fulfil the other branch should follow this one.
- Click OK to save this branch, then OK again to save the step.
Because you have nominated the steps to take for different scenarios, the Decision step automatically creates the connections:

- At this point, you can link the Retrieve Text Message step to the Decision step.
That's part 2 complete. In part 3, we're going to finish this task to complete the full business process.
Part 3: Sending the Account Balance via SMS
This final part completes the task so the account balance is sent back to the sender.
Required Tools
| ► | Convert XML to Recordset |
| ► | Format as Text |
| ► | Send Text Message |
| ► | Schedule |
Part 3A — Creating a Global Connection to ToucanText
For the Send Text Message tool to send the balance, we must create a connection to the same ToucanText account used for the Retrieve Text Message tool (see Part 2A — Creating the Connection to ToucanText).
Installing the Send Text Message Message Gateway Modules
If you haven't already installed the required Message Gateway modules, do the following (these are the modules that sit between the Send Text Message tool and the SMS centre):
- Launch the Configurator
You use the Configurator to install third-party software that may be required by available tools. Connection to required agents are also configured here. Note that you can only launch the Configurator if logged into the machine with Administrator rights.. - Expand Tool Specific > Send Text Message > Prerequisites.
- Click Install where prompted for any missing modules.
- Click Next to move to the Message Gateway Agent > Prerequisites node.
- Click Install where prompted for any missing modules.
- Click Next.
- Register the Message Gateway Agent and click Save.
Creating the ToucanText Connection
Now we can create the connection to your ToucanText account.
- Launch the BPA Platform client.
- From the resources tree, go to System > Tools > Output > Send Text Message.
- Click Add.
- Enter a meaningful Connection name.
- Leave Provider as ToucanText Message Gateway.
- For Server, enable Local Computer.
- Enter the API Username and API Password for your ToucanText account.
- Click Test to ensure the connection can be made.
- Once the test is successful, click OK to save and close this connection.
- Click Close.
Part 3B — Processing the Task Data from the Call Task Step
The Call Task tool outputs task data in XML form. This cannot be read by the tools required to complete this task so we must convert the data to a BPA Platform recordset first. You use the Convert XML to Recordset tool for this.
- Re-open the Picks Up Inbound Messages task.
- Add a Convert XML to Recordset step.
- We'll leave this with the default name so go straight to the Main tab.
- Enable Task Step and select Output Data from Call Message Processing Task.
- From the Output recordset configuration pane, expand all nodes and enable OutputData — this selects all child nodes as well. Each child node then forms a column in the recordset created by this task.
- Click OK to save and close this step.
Part 3C — Creating the SMS Response
We now need to create the message that is sent; we do this in the Format as Text tool. Although you can create the message directly in the Send Text Message tool, it cannot loop through a recordset and send an SMS for each row found (we previously set the Message Processing Task to retrieve a maximum of 50 messages, with each message becoming a single row (a record) in the recordset). Instead, we leave this "job" up to a Format tool which sends each processed row individually to the Output tool.
- Add a Format as Text step to the Picks Up Inbound Messages task.
- Name this step: Create SMS Message.
- Enable Use a Recordset and select Results from Convert XML to Recordset from the Input Recordset drop-down.
- Go to the Formatting tab.
- Enable New document for each row — this forces the Format as Text step to loop through the recordset and create a separate SMS document for each record found.
- In the free text area, type:
Your balance is: £
Note: The training database does not hold the currency symbol as part of the
BALANCEcolumn; if using a different database, adjust the currency symbol here for your organisational needs. - From the Task Browser, go to the Environment tab.
- Change Scope to This Step.
- Expand Format as Text > RecordSource and drag OutputData_Balance and drop it after the currency symbol.
Your SMS message should now look like: Your balance is: £{=ThisStep.RecordSource("OutputData_Balance")}
When the task is run, {=ThisStep.RecordSource("OutputData_Balance")} is replaced with the value from the
BALANCEcolumn in the database. - Click OK to save and close this step.
Part 3D — Sending the SMS Message
This part of the task sends the SMS back to the original sender.
- Ensure Part 3C — Creating the SMS Response has been completed first.
- Add a Send Text Message step to the Picks Up Inbound Messages task.
- Leave Name as the default.
- Enable Read documents from a source and select Documents from Create SMS Message [Text] from the drop-down.
- Go to the Connection tab and select the Connection created in part 3c.
- Go to the Main tab.
- Click To then Add.
- From the Task Browser, go to the Environment tab.
- Change Scope to This Step.
- Expand Send Text Message > DocumentSource > Recordset and drag OutputData_SenderNumber to Mobile / Pager Number:

- Click OK twice to return to the main Send Text Message interface.
- Ensure Document Output in the Message Contents pane is selected — this ensures the body of the SMS sent only contains the contents of the Format as Text step.
- Click OK to save and close the step.
Part 3E — Joining the Steps
To ensure BPA Platform runs the steps in the correct order, the individual task steps must be linked. You do this by clicking a step to display the step controls — click and hold
and draw the connector to its successor.
If required, you can add a label to the connection. Double-click the connection line and add the label, up to a maximum of 100 characters. Note that this is a pure-text field so variables, formulas, functions, and Task Browser properties cannot be used in this area.
- Link Call Message Processing Task to Convert XML to Recordset.
- Link Convert XML to Recordset to Create SMS Message.
- Link Create SMS Message to Send Text Message.
Your task should now look like this:
Part 3F — Scheduling the Task
Currently, the task must be manually queued for it to check for and reply to SMS balance requests. Using an Event tool, we can have the task trigger based on an external event — the most suitable tool for this task is the Schedule tool which triggers tasks to run based on a date schedule.
- Add a Schedule step to the Picks Up Inbound Messages task.
- Name this step: Run every minute.
- Go to the Main tab.
- From the Schedule pane, enable Minutes.
- Leave all options with their defaults so this task runs every minute and click OK to save and close the step.
- Connect this step to the Retrieve Text Message step so it becomes the first step in the task.
- Click OK to save and close the task.
Part 3G — Testing the Task
We can now test the whole task by sending a balance request SMS to ToucanText.
- Add a test record to your customer database containing your mobile number, a customer account number, and a balance value.
- Send an SMS message starting with the word BAL followed by the test account number to the ToucanText inbound number assigned to your account.
- Watching the BPA Platform client, you can see the task fire in the Active Tasks pane; you should receive an SMS back from ToucanText containing the text added in the Format as Text step.
That completes this task.
Why not see if you can expand this task to send replies to customer satisfaction surveys, order status requests, and so on.
Why not watch the task being constructed? Visit our Training Videos webpage.