... | ... | @@ -11,9 +11,9 @@ eg: say we have an [email.smtp_forward channel](https://bip.io/docs/pods/email) |
|
|
|
|
|
Templates can also be interpolated with variables from upstream channels or metadata if they take the form
|
|
|
|
|
|
`[%(source|_client|_bip|channel id)#export_attribute%]`
|
|
|
`[%(source|_client|_bip|channel id)#json_path%]`
|
|
|
|
|
|
"export attribute" in the example means the name of an attribute exported by an upstream channel, keyed by either an explicit channel id, or `source` (ie: whatever the bip receives or generates). This means you can concatenate exports and text together to create a custom import. With the previous email example, lets assume we're using an `smtp` bip and want to pass through some of the details to an email channel on its hub :
|
|
|
`json_path` in the example means the [JSON Path](http://goessner.net/articles/JsonPath/) of an attribute exported by an upstream channel, keyed by either an explicit channel id, or `source` (ie: whatever the bip receives or generates). This means you can concatenate exports and text together to create a custom import. With the previous email example, lets assume we're using an `smtp` bip and want to pass through some of the details to an email channel on its hub :
|
|
|
|
|
|
```
|
|
|
{
|
... | ... | @@ -21,6 +21,35 @@ Templates can also be interpolated with variables from upstream channels or meta |
|
|
"body_text" : "I got an email from [%_client#repr%] : [%source#body_text%]"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## Object and Array Passthrough
|
|
|
|
|
|
Transform templates which only include a single JSONPath will be evaluated in-place, meaning that if the path evaluates to an object or array, then it will be replaced with that structured data.
|
|
|
|
|
|
For example, say we have a channel with a `json_document` import which expects a structured object and you need to map an export object from a complex payload like so (the 2nd object element of an array) :
|
|
|
|
|
|
```
|
|
|
{
|
|
|
"374d9a1d-cc84-456d-9dad-e1e3065e8c4d" : {
|
|
|
"payload" : [
|
|
|
"Payload Title",
|
|
|
{
|
|
|
"name" : "This is the document name",
|
|
|
"value" : "And it has a value"
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
It can mapped as :
|
|
|
|
|
|
```
|
|
|
{
|
|
|
"json_document" : "[%374d9a1d-cc84-456d-9dad-e1e3065e8c4d#payload[1].body%]"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## Bip metadata exports (_bip|_client)
|
|
|
|
|
|
Additional metadata exports are available depending on the type of Bip that is evaluating. These exports are set in `_bip` and `_client` exports which can be discovered by calling the [`/rpc/describe/bip`](https://github.com/bipio-server/bipio/wiki/Describing-Models) RPC.
|
... | ... | |
... | ... | |