SendCommand
Sends a command to a connector. A full list of commandIdn's can be found here. See the examples below for the arbitrary arguments applicable to each commandIdn.
SendCommand(
commandIdn: str,
integrationIdn: str,
connectorIdn: str,
**arguments: str
)
Where:
- commandIdn: The connector command identifier.
- integrationIdn: The integration identifier (program_timer, twilio, newo_voice, sandbox, etc.).
- connectorIdn: The connector identifier.
- **arguments: Arbitrary arguments sent along with the message.
Example 1 (Make Phone Calls)
In the example below, the connector will call the number +16507000000. If the user picks up the phone, a persona and actor will be created for them if necessary (if this is a new user), and responses will be generated in a new flow instance that has a subscription to the user_message event from the newo_voice/newo_voice_connector connector. Ensure you have created a Newo Voice connector with the connectorIdn as "newo_voice_connector." Additionally, change the "phoneNumber" to call your phone for testing purposes.
{{SendCommand(
commandIdn="make_call",
integrationIdn="newo_voice",
connectorIdn="newo_voice_connector",
phoneNumber="+16507000000",
greetingPhrase="Hello, how can I assist you today?"
)}}
Where:
- phoneNumber: The phone number that will be called when the SendCommand action is activated.
- greetingPhrase: A greeting phrase the agent will say once the call has been answered.
Example 2 (Timers)
In the examples below, timers are set up using various arguments. Programmable timers support "set_timer" or "set_repeatable_timer." Both commands can use the "fireAt" and "interval" parameters.
The below SendCommand action activates a timer once at 2024-02-20[T]22:17.
{{SendCommand(
commandIdn="set_timer",
integrationIdn="program_timer",
connectorIdn="fire_timer",
fireAt="2024-02-20T22:17",
personaId=GetUser(field="id"),
timerName="MyTimer",
repeatable="false"
)}}
Where:
- personaId: The ID of the persona for whom the timer is to be set.
- timerName: The name of the timer (must be unique for the persona).
- fireAt: The date/time of timer activation in the format: YYYY-MM-DD[T]HH:MM[:SS[.ffffff]][Z or HH[:]MM.
- repeatable: Set as "true" or "false." If "true," the timer activation repeats after the interval. The default is "false." If repeatable="true," then the interval is mandatory. If repeatable="false", fireAt and interval are set, then the interval is ignored. If repeatable="true," fireAt and interval are set, then the timer will first activate at fireAt and then will repeat after the interval.
The below SendCommand action activates a timer once after 120 seconds.
{{SendCommand(
commandIdn="set_timer",
integrationIdn="program_timer",
connectorIdn="my_timer",
personaId=GetUser(field="id"),
timerName="followup_timer_2",
interval="120"
)}}
Where:
- interval: The interval after which the timer will activate in seconds.
The below SendCommand action activates a timer at 2024-02-20[T]22:17 and repeatedly activates thereafter every 240 seconds.
{{SendCommand(
commandIdn="set_repeatable_timer",
integrationIdn="program_timer",
connectorIdn="my_timer",
personaId=GetUser(field="id"),
timerName="followup_timer_3",
interval="240",
fireAt="2024-02-20T22:17"
)}}
The below SendCommand action creates a timer but disables it.
{{SendCommand(
commandIdn="set_timer",
integrationIdn="program_timer",
connectorIdn="my_timer",
personaId=GetUser(field="id"),
timerName="followup_timer_3",
enabled="false"
)}}
Where:
- enabled: Set as "true" or "false." Sets whether the timer is active or not.
The below SendCommand action creates a timer and enables it.
{{SendCommand(
commandIdn="set_timer",
integrationIdn="program_timer",
connectorIdn="my_timer",
personaId=GetUser(field="id"),
timerName="followup_timer_3",
enabled="true"
)}}
Example 3 (Send Messages)
In the example below, the connector will send an SMS to the number +16507000000. Ensure you have created a Twilio Messenger connector with the connectorIdn as "sms_connector" for the below Skill Script to work. Additionally, change the "phoneNumber" to call your phone for testing purposes.
{{SendCommand(
commandIdn="send_message",
integrationIdn="twilio_messenger",
connectorIdn="sms_connector",
text="Hello, how can I assist you today?",
phoneNumber="+16507000000"
)}}
Example 4 (HTTP requests)
The send_request command makes HTTP requests to external APIs. The response triggers a result_success event on completion or a result_error event on network failure, allowing downstream actions to handle the results.
{{SendCommand(
commandIdn="send_request",
integrationIdn="http",
connectorIdn="connector_name",
userPersonaId=GetUser().id,
method="GET",
url="https://api.example.com/endpoint",
headers=json.dumps(headers_dict),
targetAction="action_identifier"
)}}
Required arguments:
| Argument | Type | Description |
|---|---|---|
commandIdn | string | Must be "send_request" |
integrationIdn | string | Must be "http" |
connectorIdn | string | Your HTTP connector identifier |
userPersonaId | string | User persona ID, typically GetUser().id |
method | string | HTTP method: "GET", "POST", "PUT", "DELETE", or "PATCH" |
url | string | Full URL of the HTTP request |
Optional arguments:
| Argument | Type | Description |
|---|---|---|
headers | string | HTTP headers as JSON string (use json.dumps()) |
body | string | Request body for POST/PUT/PATCH requests (JSON format) |
data | string | Form data for application/x-www-form-urlencoded requests |
parameters | string | Query parameters or custom parameters as JSON string |
targetAction | string | Action identifier to filter response handling |
runSkill | string | Name of skill to run on a successful response |
params | string | Additional parameters passed to response handlers |
request_parameters | string | Complete request parameters object for context |
Response events:
result_success — Triggered when the HTTP request completes (regardless of status code). Use GetTriggeredAct() and GetAct() to access response data:
{% set triggered_act = GetTriggeredAct() %}
{% set act = GetAct(id=triggered_act.commandActId) %}
{% set status_code = triggered_act.arguments.statusCode %}
{% set body = triggered_act.arguments.body %}
{% set reference_idn = triggered_act.referenceIdn %}
{% set target_action = act.arguments.targetAction %}
{% set original_parameters = act.arguments.parameters %}
result_error — Triggered when the HTTP request fails (network error, timeout, etc.):
{% set triggered_act = GetTriggeredAct() %}
{% set status_code = triggered_act.arguments.statusCode %}
{% set error_message = triggered_act.arguments.errorMessage %}
{% set body = triggered_act.arguments.body %}Updated 4 days ago
