Today (4/17/24) in AppSheet I learned: You can press any action button through the API

It just clicked to me that when making an API call, the “Action” we’re providing for the API call (add, edit, delete, find) is literally the name of the action (add, edit, delete - not find though, lol) in the Action panel for that table. :eyes:

When we say:

sendToAppSheet(“Add”, “user@email.com”, “myAppId”, “myTableName”, “myAccessKey”, {“Locale”: “en-US”, “RunAsUserEmail”: useremail}, [{“Column1”: “Value1”, “Column2”: “Value2”}]);

We’re really saying:

  • Go to the Actions panel
  • Run the “Add” action
  • Use the following values for the columns

And the system does exactly that!

  1. It essentially “pushes” that add button
  2. The form conceptually opens for the bot
  3. The bot enters the details you provided into the columns
  4. The bot hits save, and whatever automations are triggered
    • Thought any form save events won’t fire off, since we’re not really inside the form. :wink:

The revelation

A way of thinking about this is: we’re actually pressing action buttons through the API.

When we want to add a record, we’re pressing the action:
image
- We’re literaly pressing this button

And when we’re making an edit…
image

And when we’re deleting a record:
image


Putting it all together

So this means that we can hit ANY (???) action button through the API?

The documentation reveals some restrictions, but essentially… YES!

So if I wanted to mark a newly paid subscription in the Answer Portal as Active… and I have a button that I already press…

image

Can I basically hit this button with the API, say from a script?

YES!!

  • This button only executes a data change action, which changes the status to “Paid”, sets the start date to TODAY(), and sets a trigger value for an automation bot.
    • These action types are within the limitations; so, yes, this “should work”. (^_^)

Testing proves true

  • I was able to take my Stripe payment catcher script, adapt it to send a trigger to the AppSheet API when someone pays their subscription, and just ran a test.
    • Indeed; the system worked.

It was able to take the email from the Stripe webhook, execute a “Find” appsheet call to find their unpaid subscription record…

Then take the ID from that record and run the data change action (from the button I press to activate the subscription),

This updated the record - and triggered the bot, which then kicked off the complicated chain I’ve already got built to handle everything - just as if I had gone into the app and pressed that button on that record. :muscle:

wooHOO! :tada::confetti_ball::partying_face: This opens up so much more flexibility and possibilities.

1 Like

Hey Matt, this is a really cool find…

I have not been using appscripts much except for here and there basic things.

My question is based on a lack of knowledge and reading documentation I suppose but let’s try.

I beleive using scheduled bots requires a deployed app, so in essence I’m leaning towards using your finding as a workaround, one can set a scheduled trigger in appscript to find rows and then use and existing action in appsheet? Is using API only for specific plans or can i use on undeployed apps.

I hope I make sense and if you up for making a video on this, I would jump over the moon :smile:

1 Like

Yes it does

If I remember right, there’s even a note inside the editor when you create a scheduled bot - letting you know it will only run on deployed apps.

From the documentation:

I’m pretty sure this is a no.

I’m betting an app must be deployed before the external API would work for it. I could be wrong, never tested (would be interested to know if anyone else has tried).