Testing an Automation : YAML help #58
-
On request of Jeff , I'm sharing this here to get additional help. Using Bots , I'm able to get instant gratification by simulating tickets and know if my code has worked or not . I don't understand the same with Automation yet Purpose : Closing all tickets from Kotak.com older than 2 days Request for YAML for testing this code
This is a sample I tried which gives me
ERROR
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @pakiyabhai! This is a great question, and the docs on cerb.ai need to cover simulating automations better. You actually have much more visibility into what's going on with an automation than you ever did with bot behaviors. I'm going to assume we're using an automation policy like: commands:
record.search:
deny/type@bool: {{inputs.record_type is not record type ('ticket')}}
allow@bool: yes
record.update:
deny/type@bool: {{inputs.record_type is not record type ('ticket')}}
allow@bool: yes An automation will run all commands like normal during simulation unless you implement an So in your example, the For instance, in your example we probably don't want to actually close any tickets while simulating. So you'd add an # Close the ticket
record.update/ticket:
inputs:
record_type: ticket
record_id: {{ticket_id}}
fields:
status: closed
on_simulate: When You can always toggle between Simulate and Execute mode on the Run tab of the automation editor: I think Github also munged your search query, but it would look like: # Search for tickets from Kotak.com older than 2 days
record.search/tickets:
output: tickets
inputs:
record_type: ticket
record_query@text:
messages.first:(sender:(host:"kotak.com")) created:"-2 days" status:open limit:50 If you run that without any Inputs: you'll see in the Outputs: panel that the The only time you'd put something in Inputs: is if the automation event expects inputs. For instance, the Those would be simulated like: inputs:
message__context: message
message_id: 123
is_new_ticket: no If for some reason you wanted to provide mock results for a command during simulation (like your # Search for tickets from Kotak.com older than 2 days
record.search/tickets:
output: tickets
inputs:
record_type: ticket
record_query@text:
messages.first:(sender:(host:"kotak.com")) created:"-2 days" status:open limit:50
on_simulate:
set:
tickets:
1:
created@date: -2 days
initial_message_sender_host: kotak.com
initial_message_content: "Hello, I have a question about my account."
ticket_id: 1
2:
created@date: -2 hours
initial_message_sender_host: kotak.com
initial_message_content: "I need to reset my password."
ticket_id: 2 That's useful if you know your automation isn't going to match any live data at this moment. But in most cases, you'd just create some test data that you know will match. You can also simulate error conditions (including randomly), like: # Search for tickets from Kotak.com older than 2 days
record.search/tickets:
output: tickets
inputs:
record_type: ticket
record_query@text:
messages.first:(sender:(host:"kotak.com")) created:"-2 days" status:open limit:50
on_error:
error: It broke!
on_simulate:
outcome/chaos:
if@bool: {{random(1,10) <= 2}}
then:
simulate.error:
set:
# ... On the
I'll make sure this finds its way to the docs. Let me know if anything could be made more clear. 😃 |
Beta Was this translation helpful? Give feedback.
Hi @pakiyabhai!
This is a great question, and the docs on cerb.ai need to cover simulating automations better. You actually have much more visibility into what's going on with an automation than you ever did with bot behaviors.
I'm going to assume we're using an automation policy like:
An automation will run all commands like normal during simulation unless you implement an
on_simulate:
event for a command. It can even be empty.So in your example, the
record.sea…