How to Create an AI Chat with Gemini in Construct 3

UpvoteUpvote 1 DownvoteDownvote

Index

Features on these Courses

Stats

22 visits, 34 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 26 Aug, 2025.

Step 5: Connecting the Function to the UI

Now that our ask function is written, let's wire it up to the Construct 3 interface using event sheet scripting. We'll trigger this function when the user presses the 'Enter' key in the text input field.

// TypeScript code in a Construct 3 Event Sheet
const key = runtime.globalVars.API_KEY;
const question = runtime?.objects?.Question?.getFirstInstance()?.text || "";
const answer = question.trim().length > 0 ? await Gemini.ask({key, question, runtime}) : "Missing Question!";
const textAnswer = runtime.objects.Answer.getFirstInstance();
if (textAnswer) { textAnswer.text = answer};
  • 0 Comments

Want to leave a comment? Login or Register an account!