Return values or Update through the API

Background

Around the start of 2023 I began putting together the Answer Portal and Appster, while also taking on a larger project from a client of mine that runs a medical practice. They saw what I was doing with Ai and wanted to dive head first into Ai, beginning to integrate it into every workflow they could.

In the following months, I got real hands on experience with how to work with these systems:

  • What sort of tasks work well, and what doesn’t
  • How to organize the data you’re presenting
  • The mechanics of handling responses
  • Much more

This post deals with the technical aspect of taking a response from an Ai system and recording it into a database.

When you want to integrate Gen Ai into an AppSheet app, you’ll need a bot that runs a script to handle the Ai API integration; this bot takes the data from your app, prepares it in appropriate ways, and then passes it to the script - which then passes it to the Ai API.

When you get the response, you need to record this value into your database in some way - which means we need a mechanism that will accomplish this task.

There are 2 possible methods you can use to accomplish this:

  1. Return Value
  2. AppSheet API

Method #1: Return Value

The idea wit this method is that you configure your script with a return value(s), which you then configure your bot to accept. In this configuration the recording of the response values are handles through the bot.

Pros

  • You can use the value(s) returned in down-stream tasks (even basing logic off them)
  • You can see the results right away in the app (once the sync finishes)

Cons

  • The sync for the individual edit won’t clear until the response is returned, and the bot finishes - which can lead to some long sync times.
    • This means that someone can’t necessarily “continue moving forward” until the sync finishes
  • Multi-step bots take time
    • Each step in a bot takes a certain amount of time to process (due to the logs being created and all that), so if you have many steps in your bot it can slow down the execution while the system processes through each of the steps.

Method #2: AppSheet API

The idea with this method is that you configure your script to send the updates to the AppSheet API; you trigger the bot, it passes off all the details necessary for the script to run, and then the script takes over.

Pros

  • Faster sync time (once the bot passes things off to the script, it’s done and the sync clears) - meaning users can continue to move forward if they need to.
  • Can trigger additional bots with [Automation_Trigger] keywords
    • Recursive looping is possible with this setup

Cons

  • Can’t base down-stream bot logic directly off the values (but the idea is that the bot hands it off to the script, so this doesn’t much apply really)
  • Must independently sync app to see data in the app

Conclusion

As you can see they both have their strengths and weaknesses, which will play well depending on the situation you’re encountering. There is no one-size-fits-all solution when it comes to this, as each method will work best for their particular situations.


How have you implemented this sort of thing in your apps?

I’m curious to know the thoughts and feelings of others who have implemented Gen Ai in their apps; how have you handled this situation? Is there a particular method that you favor? Let me know in the comments below.