webxdc-requests-bot
v0.3.0
Published
DeltaChat bot that allows Webxdcs to make http(s) requests
Downloads
213
Readme
webxdc-requests-bot
DeltaChat bot that allows Webxdcs to make http(s) requests.
Install
npm install -g webxdc-requests-botUsage
Add an account to the bot:
webxdc-requests-bot init dcaccount:https://nine.testrun.org/newNow get the bot's link:
webxdc-requests-bot linkRun the bot:
webxdc-requests-bot serveTo see all commands:
webxdc-requests-bot --helpUse the bot's link to add it in Deltachat, after that you can send a webxdc to a chat with the bot and use its API to make http(s) requests with the webxdc.
Example:
window.webxdc.setUpdateListener((update) => {
if (update.payload.response) {
const response = update.payload.response;
if (response.id === "my-unique-request-id") {
if (response.error) {
console.log("Error making the request:", response.error);
} else {
if (response.status === 200) {
console.log("Response headers:", response.headers);
console.log("Response body:", JSON.parse(response.body));
}
}
}
}
});
window.webxdc.sendUpdate({
payload: {
request: {
id: "my-unique-request-id", // the same id will be sent with the response
url: "https://api.github.com/users/DavidSM100/repos",
method: "GET",
responseBodyEncoding: "utf-8", // default is base64
},
},
});The check the full format of requests and responses see webxdc-requests.d.ts
