Lineblocs macros allow you to further customize your call flows using the TypeScript language.
Using Lineblocs macros, you can create high-level integrations that include tasks such as sending a lead to a CRM or sending out an email using an API.
In this example, we will set up a call flow that uses a macro to check for local business hours before forwarding a call to an agent.
You will need the following to complete this tutorial:
A DID Number
Lineblocs account
We will first bootstrap our workspace with some timezone values to later route our calls according to the correct timezone.
To access the workspace params screen; in Lineblocs dashboard click "Settings" -> "Workspace Params"
To add a timezone workspace param, please click "Add Param." In the key field, use "timezone," then use any valid timezone name in the value field. For example, "America/Toronto.".
To see a full list of time zones, please use this link.
Your workspace params screen should now look like the following image:
In Lineblocs dashboard click "Create" -> "New Flow"
Enter name "Business Hours Check"
Select "Call Forward" template
Click "Create"
To add a new macro please drag the "Macro" widget from the right pane into the flow graph.
To edit your macro's function, please click the "Macro" widget, and then click in the right pane.
In the template selection screen, choose template "Business Hours Check," then click "Save."
By default the macro will be setup to forward calls from 9AM-5PM Monday to Friday. To confirm these defaults, please click "Save".
Lastly, for the macro's function, you will be shown a code editor screen with the Macro's function.
Please click "Save" on this screen, then give your macro a title such as "business-hours."
We will need to add a playback widget to play a message when our time condition is not satisfied.
To add a playback widget for when your office is closed, please drag a "Playback" widget from the right pane into the flow editor.
In the Playback widget, please use the following settings:
```
Widget Name: ClosedMessagePlayback
```
```
Playback Type: Say
```
```
Text To Say: Our office is currently closed, please call us again from Monday to Friday 9 AM to 5 PM eastern time.
```
```
Language: en-US
```
```
Gender: FEMALE
```
```
Voice: en-US-Standard-C
```
We will add a "Switch" widget to test for our time condition and go to the correct widget.
To add a "Switch" widget, please drag a new "Switch" widget into the flow graph. Rename this widget into "HoursSwitch," then change the "Variable to test" to Macro.result.
Please go to the "Links" tab of the "HoursSwitch" widget and add the following 2 links
```
Condition: Equals
```
```
Value: open
```
```
Cell to link: ForwardBridge
```
```
Condition: Equals
```
```
Value: closed
```
```
Cell to link: ClosedMessagePlayback
```
The "HoursSwitch" link section should now look like the following:
Next, we will need to update the flow to use our widgets.
To make adjustments to your flow so that all of the widgets are working correctly. You will need to connect the "Incoming Call" port from the Launch widget into the Macro's "In" port and add a link from widget Macro's "Completed" port into the HoursSwitch's "In" port.
Below is an example of how the final flow should look like:
To save all your changes please click in the flow editor.
To use your call flow on a DID Number:
In the Lineblocs dashboard, please click DID Numbers -> My Numbers
Click the "Edit" button next to your number
Update the "Attached Flow" field
click "Save"
You should be able to call your number and see your business hours check working. Your callers will hear a message when you are unavailable, and they will be forwarded to you during your business hours.
In this guide, we discussed setting up macros on lineblocs. For other related quickstart posts, please see the guides below: