Developer documentation
Examples
Copy-ready patterns for the workflows people usually record and turn into plugins.
Platform productivity card
module.exports = {
manifest: {
id: "productivity-files-plugin",
name: "Productivity and Files",
version: "1.0.0",
permissions: ["ui.transform", "platform.run"]
},
transformApp: function(app, api) {
api.ui.remove(app, "productivityFilesCard");
api.ui.append(app, "rightPanel", {
type: "card",
id: "productivityFilesCard",
children: [
{ type: "text", value: "Productivity and Files" },
{ type: "button", text: "Compose SMS", command: "productivity.sms" },
{ type: "button", text: "Phone dial", command: "productivity.phone" },
{ type: "button", text: "Android APIs", command: "productivity.android" },
{ type: "button", text: "Windows APIs", command: "productivity.windows" }
]
});
return app;
},
commands: {
"productivity.sms": function(ctx) {
return { __action: "platform.run", operation: "composeSms", pluginId: "productivity-files-plugin", resultKey: "sms", to: ["+10000000000"], body: "Draft from BuildAPlugin" };
},
"productivity.phone": function(ctx) {
return { __action: "platform.run", operation: "phoneDial", pluginId: "productivity-files-plugin", resultKey: "phone", number: "+10000000000" };
},
"productivity.android": function(ctx) {
return { __action: "platform.run", operation: "androidSnapshot", pluginId: "productivity-files-plugin", resultKey: "androidSnapshot" };
},
"productivity.windows": function(ctx) {
return { __action: "platform.run", operation: "windowsSnapshot", pluginId: "productivity-files-plugin", resultKey: "windowsSnapshot" };
}
}
};
Bluetooth status and scan card
module.exports = {
manifest: { id: "bluetooth-test-plugin", name: "Bluetooth Test", version: "1.0.0" },
transformApp: function(app, api) {
var data = (app.pluginData && app.pluginData["bluetooth-test-plugin"]) || {};
var result = data.lastBluetoothResult || {};
api.ui.append(app, "rightPanel", {
type: "card",
id: "bluetoothTestCard",
children: [
{ type: "text", value: data.bluetoothStatus || "Bluetooth not tested yet" },
{ type: "button", text: "Run quick test", command: "bluetooth.status" },
{ type: "button", text: "Scan 8 seconds", command: "bluetooth.scan" },
{ type: "textarea", value: JSON.stringify(result, null, 2), readonly: true }
]
});
return app;
},
commands: {
"bluetooth.status": function(ctx) {
return { __action: "bluetooth.run", operation: "status", pluginId: "bluetooth-test-plugin", resultKey: "status" };
},
"bluetooth.scan": function(ctx) {
return { __action: "bluetooth.run", operation: "scan", pluginId: "bluetooth-test-plugin", resultKey: "scan", timeoutSeconds: 8 };
}
}
};
Button that copies URL into body
module.exports = {
manifest: { id: "copy-url-body", name: "Copy URL To Body", version: "1.0.0" },
transformApp: function(app, api) {
api.ui.append(app, "rightPanel", {
type: "card",
id: "copyUrlBodyCard",
children: [
{ type: "text", value: "Copy URL To Body" },
{ type: "button", id: "copyUrlBodyButton", text: "Copy URL", command: "copyUrlBody.run" }
]
});
return app;
},
commands: {
"copyUrlBody.run": function(ctx) {
var url = ctx.dollar("#urlInput").val();
ctx.dollar("#bodyEditor").val(url);
return ctx.dollar("#bodyEditor");
}
}
};
Send, capture response, show popup
commands: {
"capture.send": function(ctx) {
return { __action: "runCommand", command: "core.request.send", payload: { afterSendCommand: "capture.show" } };
},
"capture.show": function(ctx) {
var body = ctx.responseBody || "";
return {
__action: "multi",
actions: [
{ __action: "pluginBus.output", name: "latest.response.body", value: body },
{ __action: "showMessage", title: "Latest response", message: body }
]
};
}
}
Fill header inputs and click Add Header
commands: {
"header.addTrace": function(ctx) {
ctx.dollar("#kvTable.Headers.add.key").val("X-Trace-Id");
ctx.dollar("#kvTable.Headers.add.value").val("trace-123");
ctx.dollar("#core.headers.addButton").click({ key: "X-Trace-Id", value: "trace-123" });
return ctx.dollar("#core.headers.addButton");
}
}
Chain response into another request
hooks: {
afterResponse: function(ctx) {
return {
__action: "request.send",
resultKey: "secondRequestResult",
request: {
name: "Forward response",
method: "POST",
url: "https://example.com/ingest",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ originalBody: ctx.responseBody })
}
};
}
}