53 lines
1.3 KiB
Plaintext
53 lines
1.3 KiB
Plaintext
|
[[input-simple]]
|
||
|
==== Simple Input
|
||
|
|
||
|
An <<input, input>> that enables you to load static data into a watch's execution context as the initial payload.
|
||
|
The `simple` input is useful when the data you want to work with doesn't need to be loaded dynamically, but for
|
||
|
maintainability you want to store the data centrally and reference it with templates.
|
||
|
|
||
|
You can define the static data as a string (`str`), numeric value (`num`), or an object (`obj`):
|
||
|
|
||
|
[source,json]
|
||
|
--------------------------------------------------
|
||
|
{
|
||
|
"input" : {
|
||
|
"simple" : {
|
||
|
"str" : "val1",
|
||
|
"num" : 23,
|
||
|
"obj" : {
|
||
|
"str" : "val2"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
...
|
||
|
}
|
||
|
--------------------------------------------------
|
||
|
|
||
|
For example, the following watch uses the `simple` input to set the recipient name
|
||
|
for a reminder email that's sent every day at noon.
|
||
|
|
||
|
[source,json]
|
||
|
--------------------------------------------------
|
||
|
{
|
||
|
"trigger" : {
|
||
|
"schedule" : {
|
||
|
"daily" : { "at" : "noon" }
|
||
|
}
|
||
|
},
|
||
|
"input" : {
|
||
|
"simple" : {
|
||
|
"name" : "John"
|
||
|
}
|
||
|
},
|
||
|
"actions" : {
|
||
|
"reminder_email" : {
|
||
|
"email" : {
|
||
|
"to" : "to@host.domain",
|
||
|
"subject" : "Reminder",
|
||
|
"body" : "Dear {{ctx.payload.name}}, by the time you read these lines, I'll be gone"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
--------------------------------------------------
|