Scripting With Archy on macOS/Linux
Let's get started with a demonstration of how to use Archy within a bash script. Below you can find an example bash script, with the corresponding options files and flow YAML that is used within the script.
Please note that the example YAML file that is defined on this page may not work if you do not have the same Data Action and Screen Pop Script configured within your organization. This is just an example and the flow that is used can be replaced with a different flow.
Bash script
Copied
# Created 2020-07-06
# Demo script to show how to create a flow, check in a flow, and check exit codes
echo Create a flow using Archy.
# Call archy to create the flow specified within the options file.
# This assumes that the createOptions.yaml file is found within the user's home directory in the 'demo' directory.
archy create --optionsFile ~/demo/createOptions.yaml
# Checking if the exit code from Archy is greater than or equal to 2 to determine if the flow was created successfully.
if [ $? -ge 2 ]; then
echo Error. Did not create the flow.
fi
echo Checking in a flow using Archy.
# Call archy to check in a flow.
# This assumes that the checkinOptions.yaml file is found within the user's home directory in the 'demo' directory
archy checkin --optionsFile ~/demo/checkinOptions.yaml
# Exit code 110 returned for the above command: Unable to complete the command because the flow is locked to another entity.
# Some commands have parameters such as --forceUnlock which will tell Archy to try and unlock the current flow lock.
# A list of exit codes can be found at https://developer.mypurecloud.com/devapps/archy/appendices/appendix_a_exit_codes.html
# This doesn't cover all exit codes, but shows how to check for one.
if [ $? -eq 110 ]; then
echo Failed to checkin the flow beacuse it is locked.
fi
createOptions.yaml
Copied
###########################################################################
# Example options file showing how to set settings when running commands. #
# Properties here map to command line parameters. #
# When specifying file paths, we encourage you to use a full resolved #
# file path instead of relative file paths. But for this example we will #
# use the shortcut for a user's home directory ('~'). #
###########################################################################
clientId: xxx # Replace with your clientId
clientSecret: xxx # Replace with your clientSecret
debug: false
location: mypurecloud.com # If needed, replace with the correct environment you wish to run Archy against
# Archy 'create' command-specific parameters
file: ~/demo/demoCallDataFlow.yaml
recreate: true
# resultsFile tells Archy to create a JSON file with information about results of the Archy command
# More information can be found at https://developer.mypurecloud.com/devapps/archy/resultsOutputJson.html
resultsFile: ~/demo/createResults.json
overwriteResultsFile: true
# Substitutions that are used when processing the flow YAML
substitutions:
org_name: Demo Architect Org
checkinOptions.yaml
Copied
###########################################################################
# Example options file showing how to set settings when running commands. #
# Properties here map to command line parameters. #
# When specifying file paths, we encourage you to use a full resolved #
# file path instead of relative file paths. But for this example we will #
# use the shortcut for a user's home directory ('~'). #
###########################################################################
clientId: xxx # Replace with your clientId
clientSecret: xxx # Replace with your clientSecret
debug: false
location: mypurecloud.com # If needed, replace with the correct environment you wish to run Archy against
# Archy 'checkin' command-specific parameters
flowName: Archy Hello World
flowType: inboundcall
# resultsFile tells Archy to create a JSON file with information about results of the Archy command
# More information can be found at https://developer.mypurecloud.com/devapps/archy/resultsOutputJson.html
resultsFile: ~/demo/checkinResults.json
overwriteResultsFile: true
Example YAML file
Copied
inboundCall:
name: Demo Inbound Support
defaultLanguage: en-us
startUpRef: /inboundCall/tasks/task[startingTask]
initialGreeting:
tts: "Welcome to {{org_name}}."
tasks:
- task:
name: Starting Task
refId: startingTask
actions:
- decision:
name: Is Call.Ani a telephone number?
condition:
exp: ToPhoneNumber(Call.Ani).isTel
outputs:
yes:
actions:
- callData:
name: My Call Data Action
category:
Salesforce Data Actions:
dataAction:
Get Account By Phone Number:
inputs:
PHONE_NUMBER:
exp: ToPhoneNumber(Call.Ani).e164
successOutputs:
Name:
var: Task.customerName
AccountNumber:
var: Task.accountNumber
outputs:
success:
actions:
- setScreenPop:
name: Set Screen Pop Action
screenPopScript:
Caller Account Info Pop:
inputs:
AccountNumber:
exp: Task.accountNumber
Customer Name:
exp: Task.customerName
- transferToAcd:
name: Transfer to Support
targetQueue:
lit:
name: Support
preTransferAudio:
tts: Now transferring your call to support
failureTransferAudio:
tts: Sorry, please call back later.
- disconnect:
name: Disconnect
Archy - Ver. 2.33.1, generated on January 3, 2025