Chat (+Openai Integration)

Hi Everyone!

I am trying to build an assistant using the Openai integration (Complete Chat (with history). During the week, I had different problems:

  • Never saw ‘after submit’ works (as part of integration), only if I set up without history on the column;
  • The add row action needed also is not working, which makes the message from the user and assistant be in the same row not differentiating the user from assistant on the bubbles even having the column role;
  • I am not sure if only one ‘Chat History’ table is enough (besides the user table);

Anyone with similar problems who would like to talk through the community chat? (kudos to the team for this feature, very helpful but very hidden haha)

Thanks in advance

Do you mean your on-submit action doesn’t run? If yes, what actions do you have there?

This sounds like something in the setup is wrong. Can you show some screenshots of your set up?

Hey, thanks for answering! Here are my screenshots, let me know if you need any extra information!

after submit:
image

Action (add row):

Openai integration is all ok (API key, the account is active and with funds), and I am sure because when I set it as a column, it works as you can see here:

Openai setup directly on the column:

Ok! I could make it work until it needs to run the “Add row” action. I can’t make it trigger automatically, I tried different logic and nothing worked :frowning:

If I run manually (click on ‘run’ button), it works:
image

Considering that the response of Openai appears in the same row as the user message, I added this Add row so it will add a row with the response info as the main message but with a hardcoded name and email from the “assistant.”
The logic is that if the Content is not empty, the user sent a message, therefore we have Result. Then, change Content to Result so it will display as an “assistant” message, as you can see in the first screenshot.

What am I missing?

Tks in advance

First up, seems like you should have had the model name as “gpt-3.5-turbo” instead of “gpt-3.5 turbo” like the screenshot.

image

For your “add row” action, is there a reason why you don’t add it as part of your on-submit action?

I would do it like this for the chat component’s on-submit action:

  • Add an “AI Result” column in your chat table.
  • In your on-submit action of the chat component, add a new action so you can have multiple steps.
  • Add complete chat with history as your first step, reference the right table (or relation, in this case, since I believe you would have multiple convos going on in that same table). Write the result to “AI Result”.
  • Wait for condition step until “AI Result” is not empty.
  • Add row to the same Chat table with “AI Result” as the content.
2 Likes

Thank you for the answer!
I didn’t add ‘add row’ on submit because I didn’t know I could add more than one action there.

I think I am very close to what you described:

I think the main difference is that my action is not on after submit. The rest, I think, is basically the same: I called Result, what you are calling AI Result, etc

I don’t know how to add a second action there (after submit). It looks like I can only have one action there.

I could create more than one action (it was not clear to me that the action after submit can be edited on actions).

image

But now I have a new problem: the row was created but did not “stay.”

What do you mean by this? Can you provide some screenshots or a video? I think you’re very close.

I will try to record it because it happens right after the action happens - I see the new row with the data collapse and 2s, it disappears - staying only the row from the user message.

glide

Any questions, please let me know!

@Gabriela_Tussolini, what’s your Team ID and App ID?

Your Team ID is in the URL of your Glide dashboard, e.g.
go.glideapps.com/o/your-team-id-here

Your App ID is in the URL of the Glide builder, e.g.
go.glideapps.com/a/your-app-id-here/layout

I’ll pass this along to the team for investigation.

Thank you!

Part of the problem is that it seems you are using a User Specific column to store the user/assistant values in the Role column inside the Users Table. This means those values will be invisible to any other user that logs into the application and the bot user would role value would have to be set manually to “assistant” by every user. You may want to have the Role column as a permanent regular column instead.

It also seems you are using User Specific columns to save your chat messages. If you are logged in as anyone else except the user that created those messages they will disappear.

As for the submit action you can check how I set it up in this tutorial → https://youtu.be/rnz4YEf97os?t=1308

2 Likes

Please check @grumo 's comment above. Unfortunately I can’t view your video.

Usually we use Loom to record and share the Loom link.

B6iVF8ETNFOa2qD27UFt App ID
P4g7czwrixUVGppz792T Team ID

Let me know if you need anything else, thank you!

Thank you for answering! It is a bit frustrating the amount of back-and-forth and still kind to make one chat work by myself :frowning:

I was using the specific user row for saving messages because the idea is to have an assistant that can assist different users (there is only one feature: the chat with the assistant), so indeed, it is supposed to not appear to a different user. But based on other posts I was reading and doc, it looks like this “simple logic” of having one chat history table is not enough to handle one (assistant) x multiples (users, individually). If it was a forum and a post where everybody could answer, I think what you said would make more sense, but maybe I do not understand something here.

Regarding the role, I thought of a specific user column because one row is for the assistant, and the other is for the user, so technically, it is specific, right?

Thank you for the support, I appreciate the help!

You should be using Row Owners instead of User Specific Columns to separate chat between different users.

2 Likes

The concept of user specific columns can be a bit confusing. Data stored in user specific columns is only visible to the user that entered that data. For any parameter that needs to be permanent across all users for the app’s logic to work, you need to use regular columns, otherwise that data is invisible to any other user. For the bot’s role of “assistant” that is a parameter that needs to be the same for all users, therefore it must be a permanent or regular text column type. There is more info on how User Specific columns work here → User-specific columns | Glide Docs

I don’t think using user specific columns is going to save rows. Each message and response is going to require each a row, otherwise the chat component won’t be able to render a chat thread with multiple messages.

I recommend you take a look at my AI Chat tutorial. It explains in detail how to set up an AI chat that multiple users can interact with. It uses Row Owners columns to protect data across different users.

4 Likes
1 Like

I did all the fixes you all mentioned and still see it disappear from the table, not from the layout view.

Maybe I am having trouble explaining what is happening on my end, or maybe I should reread the documentation and the videos since the onboarding clearly did not help me.

Currently, I only have 2 tables, which makes me wonder if it is enough. I understood the differences between row owners and user-specific columns and have made the changes based on the videos and support.
So, technically, I now have:

  • chat history table where only the user e-mail column is the owner of the row;
  • action after submit that contains: condition, openai chat settings, add row
  • user table with the info of the assistant

Can you provide some screenshots of what you have now? It should include your table structures, where you have your row owners, and the actions.