一个pplies to

Bridge by Smartsheet

Start a Blank Workflow for US Weather Service

PLANS

  • Bridge by Smartsheet

This guide will take you through the steps to create a simplified version of the workflow that is available in the templateGet the Forecast with US Weather Service.

The workflow triggers when a checkbox is checked in a sheet in Smartsheet. It uses coordinates from that row to get the latest weather forecast from the US Weather Service and then populates the same row in Smartsheet with that data.

You will be using the US Weather Service to get forecasts since you do not need an account to access their weather data.

This workflow does not require access to any systems other than Bridge and Smartsheet which is why it contains the workflow elementHTTP Call Utility Function.

To get the forecast you will make two HTTP Calls to the US Weather Service: one to locate thegrid pointa geographical location is in, and a second to get the forecast for that identified grid. You do not need to be comfortable with HTTP Calls to follow the steps in this guide as it will provide everything you need to complete the workflow.

These are the steps to build the workflow:

  • Create the workflow
  • Create the sheet
  • 一个uthenticate with Smartsheet and set up the trigger
  • Set up Get Row
  • Set up the junction
  • Set up the first HTTP Call
  • Set up the second HTTP Call
  • Set up Update Row

Create the workflow

In Bridge, click on the+from theWorkflowsdashboard. Give your workflow a name and selectCreate New. This will take you to the Designer.

NOTE: All workflows start with a trigger and a state.

Creating a new workflow

Create the sheet

Before setting up the trigger in Bridge, you need a sheet in Smartsheet that has at least five columns.

Set up your sheet to have the following column names and types:

  • Date (Column Type: Date)
  • Today (Column Type: Checkbox)
  • 经度(列类型:文本)
  • Latitude (Column Type: Text)
  • Weather Forecast (Column Type: Text)

Example Smartsheet Sheet for weather workflow

TheWeather Forecastcolumn can either be your Primary Column or a regular Text column.

  1. In the first cell of the Today column, paste the following formula:

=IF(Date@row = TODAY(), true, false)

  1. Drag-fill to copy the formula into at least the second row to ensure subsequent rows automatically inherit the formula.
    This will check the checkbox if the date set in theDatecolumn is today's date, which you can then use to trigger your workflow in Bridge.
  2. Before going back to the designer in Bridge, copy theSheet ID. You can find the sheet ID by selectingFile > Properties.

Set up the trigger

In the designer, click on the Trigger element at the top of the workflow. This opens a panel on the right hand side of the designer where you can set up the type of trigger you want to use. Since the workflow should trigger by an event in Smartsheet, the type of trigger used is anIntegration Trigger.

In the panel, click on the link that saysIntegrations Pageunder the automatically expanded sectionIntegrations.

Find Integrations from Trigger Tab

This will open a new tab with the Integrations page.

  1. Find Smartsheet and click on the logo.
  2. SelectContinuein the first tab of the new window.
  3. Select一个uthenticatein the second tab.
  4. This brings up another window asking if you want to allow Bridge Access to your Smartsheet account. Select一个llow.

If the authentication was successful, the window changes to theTriggerstab.

Triggers tab in new window

Expand theTriggerssection and click on the row with theplus icon (+):

  1. In theSheet IDfield, paste the sheet ID you copied when you created the sheet. If you know the sheet name is unique you can also type in the name.
  2. In theEvent Typedropdown list, selectWhen Column Values Are Changed.
  3. In the field that is added when you select theEvent Type, type in the column nameToday.
  4. Finally, in the dropdownSelect Workflowlist, choose the workflow you created earlier and selectSave.
    NOTE: You will know the trigger was set up successfully because the pop-up will reload and collapse the Triggers section.
  5. Close the tab and go back to the designer.

Errors when saving the trigger

If you receive an error message when saving a trigger, review the following items:

  • Make sure you spelled the column name exactly as you did in the sheet.
  • If you typed in the sheet name instead of using the sheet ID, check that you spelled this exactly the same, as well.
  • If you are not the sheet owner, check your sheet permissions to ensure you still have access.

Set Up Get Row

You have now set up the trigger to run the workflow when a change is made in theTodaycolumn. Even though nothing else is specified in the workflow, this action in the sheet will now send some basic information to Bridge. For the first step of your workflow, you will need to retrieve some of this initial information:

  1. Start by simply setting the date cell on the first row to today's date. This should automatically check the box in the Today column because of the formula entered earlier.
  2. Save the sheet and go back to the designer in Bridge.
  3. Open theRun Logby clicking on the arrows on the right hand side of the designer. At first it will be empty so click onRefresh. This will update the panel and one run should appear with the statusCompleted.
  4. To reveal the initial data sent to Bridge from Smartsheet, click on the run and expand the rowTriggerand then the rowEvent.
  5. Hover overrowIdin the trigger data and click on the three dots to reveal a dropdown list.
  6. In the dropdown, selectCopy Data Reference. This copies a reference to the row ID that changed to your clipboard.

By using thereference, rather than the JSON source, the workflow will always get the row that changed instead of always looking at the same row. This is important as the row changing will mostly likely always be different between each run of the workflow.

Copy Data Reference for Weather Workflow

Update the state and add a module:

  1. Click on the greystate and change theNamefield toGet Row.
    TIP: It is good practice to name the states according to what the modules below them do to make it easier to read your workflows.
  2. Next, find the moduleGet Rowin the left hand menu.
    Use the search field or find it by expandingIntegrations > Smartsheet > Get Row.
  3. Drag the module into the workflow, under the grey state. A panel to set up the module opens automatically.
  4. In the field calledRow ID, paste in the reference you copied from the rowId in the Run Log. The pasted value should read {{runtime.event.rowId}}.
  5. To get thesheet ID, open the Run Log again and find the sheetID by expanding the Trigger data. Copy the reference to the sheet ID like you did for the row ID earlier, by clicking on the three dots.
  6. Click on theGet Rowmodule again and paste in the reference in theSheetfield. The pasted value should read {{runtime.sheetID}}.
  7. Select theSaveicon at the top of the page to save the work you’ve just completed.

Get Row Module

Set up the junction

接下来,您需要确定改变checkbox in the sheet was because the box was checked or unchecked. An unchecked box should be ignored, however if the box changes to checked, it means the date set in theDatecolumn is today's date and you want to collect the weather forecast.

To do so, you will need to reference the cell with the checkbox.

  1. Go back to the sheet and change the date in the row you added earlier to uncheck the box, thensavethe sheet.
  2. In Bridge, open theRun Logagain and click on一个ll Runsat the top left of the panel. Refresh the list to see a new completed run at the top of the list.
  3. Open this new run and expand the stepSmartsheet: Get Rowto reveal the row data.
  4. Underrow > cells > Todayyou can see that the value isfalse.
    This tells you that the checkbox in the Today column, in the row that changed, wasunchecked.
  5. Using the dropdown from the three dots, copy thedata referenceof this value.

一个dd a Match conditional junction:

The next step is to add a junction to check if the value matches the text valuestrue(checked) orfalse(unchecked).

  1. In the search field, type inMatchor find the junction by expandingUtilities > Conditional Junctions > Match.
  2. Drag the junction in under theGet Rowmodule and name itTodays Date.

This junction consists of three components: the junction itself and two placeholder states. You can find more states to drag into the workflow at the top of the left hand menu underPinned Items > New State.

一个dd states to the junction:

  1. Drag a new state into thesuccessplaceholder and name ittrue.
  2. Drag another new state into thefailureplaceholder and name itfalse.
  3. In the setup panel that opens for thefalsestate, find the一个nswerfield and type in the wordstop.

This will cause the workflow to stop if it goes down this path, so don't do the same in the true state.

一个dd the data reference to the junction:

  1. Click on the junctionTodays Dateto open the setup panel.
  2. In the fieldFirst Value, paste in the reference you copied earlier.
    The pasted value should be {{states.Get Row.smartsheet.get_row.row.cells.Today.value}}
  3. In the fieldSecond Value,type in the wordtrue.
  4. Savewhat you have created so far.

Match Conditional Junction for Todays date

Set up the first HTTP Call module

The first HTTP Call identifies the grid point of a location entered in the sheet.

  1. Find the moduleHTTP Callusing the search field or by expandingUtilities > Utility Functions > HTTP Call.
  2. Drag it into the workflow under thetruestate.
  3. In theURL field, paste in the following:
    https://api.weather.gov/points/{{states.Get Row.smartsheet.get_row.row.cells.Longitude.value}},{{states.Get Row.smartsheet.get_row.row.cells.Latitude.value}}
  4. Expand the Headers section and the fieldKey #1type inUser-Agent:
  5. In the fieldValue #1, type in your company name and email separated by a comma.

    NOTE: This is a requirement of the US Weather Service so they can contact you if they see unexpected activity or behaviour in their logs.
  6. Finally, check theResponse Handlerbox and save the workflow.

First HTTP call for weather service workflow

Data References for the grid call

The URL above is created for you, since understanding how HTTP requests work isn't required for this guide. This URL references the Longitude and Latitude values on the row that triggered the workflow.

If you want to get these yourself, you need to trigger the workflow again. This time you need to make sure the checkbox gets checked. Add information into a new row rather than using the first one and make sure to set the date to today's date so that the workflow goes down the left branch of the junction.

You will need coordinates to be entered into theLongitudeandLatitudefields as well. For example, you can use 47.6174 and -122.2001 to get the weather for Smartsheet's Bellevue Office.

Coordinates

The US Weather Service requires a maximum of 4 decimal places for the coordinates.

You can adjust the workflow to round values down to the required decimal places like in the templateGet the Forecast with US Weather Service.

Set up the second HTTP Call

The second HTTP call is to retrieve the forecast from the US Weather Service based on the previously located grid points. To set this up, you will need to add a new state and another HTTP Call module to the workflow.

  1. Drag and drop a newstatefrom the pinned items at the top of the left hand menu and name itGet Forecast.
  2. Then drag in anotherHTTP Callmodule under the new state.
  3. In theURLfield, paste in the following:

    https://api.weather.gov/gridpoints/{{states.true.utilities.httpcall.properties.gridId}}/{{states.true.utilities.httpcall.properties.gridX}},{{states.true.utilities.httpcall.properties.gridY}}/forecast
  4. Expand theHeaders节和Key #1field, type inUser-Agent:
  5. In theValue #1field, type in yourcompany nameandemailseparated by a comma.
  6. Finally, check theResponse Handlerbox.
  7. Savethe workflow.

Second HTTP Call for weather workflow

Data References for the forecast call

如果你想要使用的数据引用URL above yourself, trigger the workflow again. Make sure the row changed or added has today's date so the checkbox changes to being checked.

When you have created the new row and saved the sheet, find the last run in the Run Log and expand the last step,Utility Functions: HTTP Call. UnderOutput > properties, locate the fieldsgridId, gridXandgridY. You can then use these references in the URL for the call to the weather service.

Set up Update Row

Now that you can get weather data with the workflow, the last step is to update the sheet with the forecast.

一个dd the Sheet and Row IDs

  1. First, trigger the workflow again. Make sure the row changed or added has today's date so the checkboxchangesto being checked.
  2. 一个dd anotherstateunder the last HTTP call module and name itUpdate Row.
  3. Search for theUpdate Rowmodule or find it by expanding Integrations > Smartsheet > Update Row.
  4. From theRun Log, expand theTriggerof the last run and locate theSheet IDandRow ID values.
  5. Use the data references to set the fieldsSheetandRow IDfor theUpdate Rowmodule.

一个dd the detailed forecast data reference

  1. Go back to theRun Log和扩大最后一步(最后的两个HTTPCall modules). You can find a range of information in the data returned from the US Weather Service, including weather forecasts for seven days.
  2. Find the current weather underOutput > properties > periods > 0.
  3. For this workflow, you will want to use the reference to thedetailedForecast. Copy the data reference.
  4. Open up theUpdate Rowmodule again and expand the section calledCells.
  5. Paste the reference into theValue #field. The pasted value should read:
    {{states.Get Forecast.utilities.httpcall.properties.periods.0.detailedForecast}}
  6. In theKey #1field, enter the column nameWeather Forecast.

If you want to make sure the workflow doesn't fail if the US Weather Service is unable to return information you can adjust the data reference in theValue #field to:

{{states.Get Forecast.utilities.httpcall.properties.periods.0.detailedForecast||Unable to fetch weather data}}

This ensures that if there is no data in the 'detailedForecast' the module updates the row with the text after the symbols '||'.

Update Row Module for Weather Workflow

Completed workflow

Your workflow will run anytime you add a new row (either going down the left or the right branch of the junction), as well as anytime today's date is the date set on an existing row. The Weather Forecast column in your sheet will automatically populate if the workflow goes down the left branch of the junction or if the Today box is checked.


Was this article helpful?
Yes No