-
Notifications
You must be signed in to change notification settings - Fork 5.7k
LoopMessage New gen API update; #20459
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
Changes from all commits
e255a5c
20386ac
fcdc485
4777057
7bc7ae8
bf52b15
d402258
f4cfe02
99fee3d
b6a632c
93af02c
cd761db
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,47 @@ | ||
| import app from "../../loopmessage.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "loopmessage-check-message-status", | ||
| name: "Check Message Status", | ||
| description: "Action to get the current outbound message status. Possible values: processing, failed, delivered.", | ||
| type: "action", | ||
| version: "0.0.4", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| messageId: { | ||
| type: "string", | ||
| label: "Message ID", | ||
| description: "Outbound message ID.", | ||
| }, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Props should display a list of async options if possible. Could the message history endpoint be used to retrieve message IDs?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We plan to add it in a future update. |
||
| }, | ||
| methods: { | ||
| getSummary(response) { | ||
| return `Message status: ${response.status ?? "unknown"}`; | ||
| }, | ||
| }, | ||
| async run({ $: step }) { | ||
| try { | ||
| const response = await this.app.getMessageStatus(this.messageId, { | ||
| step, | ||
| }); | ||
| step.export("$summary", this.getSummary(response)); | ||
|
|
||
| return response; | ||
| } catch (error) { | ||
| if (error.response?.status === 400) { | ||
| const message = | ||
| error.response.data?.message ?? | ||
| error.response.data?.error_code ?? | ||
| JSON.stringify(error.response.data); | ||
|
|
||
| throw new Error(message); | ||
| } | ||
| throw error; | ||
| } | ||
| }, | ||
| }; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,107 @@ | ||
| import common from "../common/send-message.mjs"; | ||
| import app from "../../loopmessage.app.mjs"; | ||
| import utils from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "loopmessage-send-text-message", | ||
| name: "Send Text Message", | ||
| description: "Action to send a text in iMessage to an individual recipient. [See the documentation](https://docs.loopmessage.com/imessage-conversation-api/messaging/send-message#send-single-message)", | ||
| name: "Send Outbound Message", | ||
| description: "Action to send a message to an individual recipient.", | ||
| type: "action", | ||
| version: "0.0.3", | ||
| version: "0.0.4", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| props: { | ||
| ...common.props, | ||
| service: { | ||
| app, | ||
| contact: { | ||
| propDefinition: [ | ||
| common.props.app, | ||
| "service", | ||
| app, | ||
| "contact", | ||
| ], | ||
| }, | ||
| text: { | ||
| propDefinition: [ | ||
| app, | ||
| "text", | ||
| ], | ||
| }, | ||
| subject: { | ||
| propDefinition: [ | ||
| common.props.app, | ||
| app, | ||
| "subject", | ||
| ], | ||
| }, | ||
| effect: { | ||
| propDefinition: [ | ||
| common.props.app, | ||
| app, | ||
| "effect", | ||
| ], | ||
| }, | ||
| sender: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "sender", | ||
| ], | ||
| }, | ||
| attachments: { | ||
| type: "string[]", | ||
| label: "Attachments", | ||
| description: "Optional. An array of strings. The string must be a full URL of your image. URL should start with https://. HTTP links (without SSL) are not supported. This must be a publicly accessible file URL: we will not be able to reach any URLs that are hidden or that require authentication.", | ||
| optional: true, | ||
| }, | ||
|
michelle0927 marked this conversation as resolved.
|
||
| replyToId: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "replyToId", | ||
| ], | ||
| }, | ||
| channel: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "channel", | ||
| ], | ||
| }, | ||
| passthrough: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "passthrough", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...common.methods, | ||
| getSummary(response) { | ||
| return `Successfully sent a text message with ID \`${response.message_id}\``; | ||
| return `Request accepted. Message ID: \`${response.message_id}\``; | ||
| }, | ||
| }, | ||
| async run({ $: step }) { | ||
| const { | ||
| app, | ||
| ...data | ||
| } = this; | ||
|
|
||
| try { | ||
| const response = await app.sendMessage({ | ||
| step, | ||
| data: utils.keysToSnakeCase(data), | ||
| }); | ||
| step.export("$summary", this.getSummary(response)); | ||
|
|
||
| return response; | ||
| } catch (error) { | ||
| if (error.response?.status === 400) { | ||
| const message = | ||
| error.response.data?.message ?? | ||
| error.response.data?.error_code ?? | ||
| JSON.stringify(error.response.data); | ||
|
|
||
| throw new Error(message); | ||
| } | ||
| throw error; | ||
| } | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import app from "../../loopmessage.app.mjs"; | ||
| import utils from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "loopmessage-send-voice-message", | ||
| name: "Send Outbound Voice Message", | ||
| description: "Send a voice memo. Supports only in: iMessage, RCS, WhatsApp.", | ||
| type: "action", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| props: { | ||
| app, | ||
| contact: { | ||
| propDefinition: [ | ||
| app, | ||
| "contact", | ||
| ], | ||
| }, | ||
| sender: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "sender", | ||
| ], | ||
| }, | ||
| mediaUrl: { | ||
| propDefinition: [ | ||
| app, | ||
| "mediaUrl", | ||
| ], | ||
| }, | ||
| passthrough: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "passthrough", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| getSummary(response) { | ||
| return `Request accepted. Message ID: \`${response.message_id}\``; | ||
| }, | ||
| }, | ||
| async run({ $: step }) { | ||
| const { | ||
| app, | ||
| ...data | ||
| } = this; | ||
|
|
||
| try { | ||
| const response = await app.sendMessage({ | ||
| step, | ||
| data: utils.keysToSnakeCase(data), | ||
| }); | ||
| step.export("$summary", this.getSummary(response)); | ||
|
|
||
| return response; | ||
| } catch (error) { | ||
| if (error.response?.status === 400) { | ||
| const message = | ||
| error.response.data?.message ?? | ||
| error.response.data?.error_code ?? | ||
| JSON.stringify(error.response.data); | ||
|
|
||
| throw new Error(message); | ||
| } | ||
| throw error; | ||
| } | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed this earlier. All actions should have doc links to the relevant documentation. Applies to all actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michelle0927 The problem is that the documentation URLs may change over time. If we provide a link there and the page is moved, it could confuse users.