-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Gupshup - new components #19344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gupshup - new components #19344
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import gupshup from "../../gupshup.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "gupshup-send-template-message", | ||
| name: "Send Template Message", | ||
| description: "Send a template message. Requires a paid Gupshup account. [See the documentation](https://docs.gupshup.io/reference/sending-text-template)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| props: { | ||
| gupshup, | ||
| info: { | ||
|
Check warning on line 16 in components/gupshup/actions/send-template-message/send-template-message.mjs
|
||
| type: "alert", | ||
| alertType: "info", | ||
| content: "Note: This action requires a paid Gupshup account.", | ||
| }, | ||
| source: { | ||
| type: "string", | ||
| label: "Source", | ||
| description: "Sender Whatsapp Number", | ||
| }, | ||
| destination: { | ||
| type: "string", | ||
| label: "Destination", | ||
| description: "Receiver Whatsapp Number", | ||
| }, | ||
| templateId: { | ||
| propDefinition: [ | ||
| gupshup, | ||
| "templateId", | ||
| ], | ||
| }, | ||
| params: { | ||
| type: "string[]", | ||
| label: "Parameters", | ||
| description: "List of template parameters", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.gupshup.sendTemplateMessage({ | ||
| $, | ||
| data: { | ||
| source: this.source, | ||
| destination: this.destination, | ||
| template: { | ||
| id: this.templateId, | ||
| params: this.params, | ||
| }, | ||
| }, | ||
| }); | ||
| if (response.status === "success") { | ||
| $.export("$summary", `Successfully sent template message to ${this.destination}`); | ||
| } | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import gupshup from "../../gupshup.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "gupshup-update-subscription", | ||
| name: "Update Subscription", | ||
| description: "Update a subscription. Requires a paid Gupshup account. [See the documentation](https://docs.gupshup.io/reference/updateanexisitngsubscription)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: true, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| props: { | ||
| gupshup, | ||
| info: { | ||
|
Check warning on line 16 in components/gupshup/actions/update-subscription/update-subscription.mjs
|
||
| type: "alert", | ||
| alertType: "info", | ||
| content: "Note: This action requires a paid Gupshup account.", | ||
| }, | ||
| subscriptionId: { | ||
| type: "string", | ||
| label: "Subscription ID", | ||
| description: "The ID of the subscription to update", | ||
| }, | ||
| modes: { | ||
| type: "string", | ||
| label: "Modes", | ||
| description: "The modes of the subscription", | ||
| }, | ||
| url: { | ||
| type: "string", | ||
| label: "URL", | ||
| description: "The subscription URL", | ||
| }, | ||
| version: { | ||
| type: "integer", | ||
| label: "Version", | ||
| description: "The version of the subscription", | ||
| }, | ||
| active: { | ||
| type: "boolean", | ||
| label: "Active", | ||
| description: "Whether the subscription is active", | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.gupshup.updateSubscription({ | ||
| $, | ||
| subscriptionId: this.subscriptionId, | ||
| data: { | ||
| modes: this.modes, | ||
| url: this.url, | ||
| version: this.version, | ||
| active: this.active, | ||
| }, | ||
| }); | ||
| if (response.status === "success") { | ||
| $.export("$summary", `Successfully updated subscription ${this.subscriptionId}`); | ||
| } | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,69 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "gupshup", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| templateId: { | ||
| type: "string", | ||
| label: "Template ID", | ||
| description: "The ID of the template to use", | ||
| async options({ page }) { | ||
| const { templates } = await this.listTemplates({ | ||
| params: { | ||
| pageNo: page, | ||
| }, | ||
| }); | ||
| return templates?.map(({ id }) => id) || []; | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.gupshup.io"; | ||
| }, | ||
| _appName() { | ||
| return this.$auth.appname; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, headers, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: { | ||
| ...headers, | ||
| "apikey": `${this.$auth.apikey}`, | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listTemplates(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: `/wa/app/${this._appName()}/template`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| sendTemplateMessage(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/wa/api/v1/template/msg", | ||
| headers: { | ||
| "Content-Type": "application/x-www-form-urlencoded", | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| updateSubscription({ | ||
| subscriptionId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| method: "PUT", | ||
| path: `/wa/app/${this._appName()}/subscription/${subscriptionId}`, | ||
| headers: { | ||
| "Content-Type": "application/x-www-form-urlencoded", | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.