Every switch responds to a Yetto event with an action. An action might be something external, like an HTTP call, or something internal, like applying labels. Actions power the automations behind switches.
Each action behaves a little differently and may require other object properties to work. The actions available for your switches and their requirements are described below.
HTTP request
The http_request
action requires a to: url
object and a with: method
object. The url is the target of the http request and the method is the http method to use when sending the data. As an example:
{
"name": "Send to server",
"uses": "http_request",
"to": {
"url": "https://norse.org"
},
"with": {
"method": "GET",
"headers": [
{
"RECEIVER-HEADER": "expected_value"
}
]
}
}
The name
property is optional, as is headers
. We send Yetto specific headers with the request, but you can send additional headers if you want to use them for your own validation.
Additionally, you can specify what data you want to receive by including a with: body
object. If you don't include that, we'll send the relevant payload for the event (the message
payload for a message.created
event, for example). However, if you include a with: body
object, we will send that instead of the default payload. For example:
{
"name": "Send to server",
"uses": "http_request",
"to": {
"url": "https://norse.org"
},
"with": {
"method": "GET",
"body": {
"some": "thing",
"message_id": "{{ data.yetto.message.id }}"
}
}
}
The above switch will send the body
defined in the JSON object rather than the message
payload that Yetto would normally send for a message.created
event.
Assign conversation
The assign_conversation
action adds and removes assignees from a conversation. It requires either an add
object or a remove
object, or both. These must be arrays of strings with the handles of the organization members you want to assign or unassign. The remove
object can be a string, rather than an array, if it includes only the asterisk character ("*"
). This will remove all assignees from a conversation before adding any of the members in the add
object array. For example:
{
"uses": "assign_conversation",
"with": {
"add": [
"billy"
]
}
}
Apply labels
The apply_labels
action adds and removes labels from a conversation. It requires either an add
object or a remove
object, or both. These must be arrays of strings with the names of the labels you want to add or remove. The remove
array can include "*"
, which will remove all labels from a conversation. For example:
{
"uses": "apply_labels",
"with": {
"add": [
"bug.urgent"
]
}
}
Here, we're using the apply_labels
action to add
the bug.urgent
label when an event triggers the switch.
Summarize
If you have AI features enabled, you can use the summarize
action to summarize a message. summarize
takes one argument: scope
.This can be either first_message
or public_thread
. scope
determines whether only the first message in a conversation is summarized, or, if the entire public conversation should be summarized.
To enable AI features:
- Go to your organization settings page at
https://web.yetto.app/orgs/[organization name]/settings
. - Click on Content references in the left sidebar.
- Click Enable AI features.
You can also incorporate content references into the summarization. To learn more about how to do that, see "Enabling content references."
Autoreply
autoreply
is an action which automatically creates a new message on a conversation. It takes two properties:
visibility
: eitherpublic
orinternal
text_content
: this is the body of the message content
For example:
{
"uses": "autoreply",
"with": {
"visibility": "public",
"text_content": "Hello. We will get back to you soon.",
}
}
Set conversation state
If you need to change the conversation state, you can use the set_conversation_state
action. It takes one property:
state
: eitheropen
orclosed
For example:
{
"uses": "set_conversation_state",
"with": {
"state": "closed"
}
}