Run code
Run a JavaScript snippet for anything the other nodes don't cover.
integration.code runs JavaScript. Use it when no other node does what you need.
Settings
| Setting | What it does |
|---|---|
| JavaScript | The body of a function. |
The run's values are on ctx: ctx.user.name, ctx.option.a, ctx.var.score and ctx.secret.API_KEY.
return { total: Number(ctx.option.a) + Number(ctx.option.b) };Ways out
out. Turn on If it fails for a red way out.
Produces
What the function returns. Later steps read it as {code.total}, or {code.result} if the return value isn't an object.
Notes
- The snippet has one second to run and can't reach the network. Put Send an API request before it, and read its answer as
ctx.http.body. - Braces in the code are code, not tokens.
- It needs a gateway bot, which the paid plan includes. See Plans.