Build your own Ai Chatbot mobile app for iOS [Discussion Thread]

Build your own Ai Chatbot mobile app for iOS


The password to access the recordings is in your email inbox. We emailed everyone that RSVP for the event.


Thank you everyone for joining our workshop series to learn how to build a chatbot for iOS that uses OpenAI’s API (chatGPT) with Eng.Omar Elsayed.
Please drop your questions below, or maybe just say hello and connect with other users that are also attending these sessions! :point_down:

1 Like

I’ll go first! :raised_back_of_hand:

I’m curious to hear how many users here are thinking about writing apps for both iOS and Android. Are you planning on learning one, and then after learn the other? Have you tried learning Kotlin before?

1 Like

Hey everyone, this is the recording of me debugging the problem :

And this is the link of today’s code:

1 Like

I know iOS already and plan on sticking with it for now.
So this series is great. Learning a new skill to add on


where did you learn how to do API calls? Was that on the Codecademy iOS developer course? Because if it is… I’m not there yet!!!

After I make the change. I have dis error.
Thread 1: Fatal error: No ObservableObject of type OpenAIViewModel found. A View.environmentObject(_: ) for OpenAIViewModel may be missing as an ancestor of this view.

my code in the OpenAIViewModel is.

class OpenAIViewModel: ObservableObject {
@Published var message: String = “”
@Published var response: String = “”

private let apiManger = APiManger.shared


extension OpenAIViewModel {
func sendMessageToOpenAI() async {
do {
let result = try await apiManger.apiRequest(messega: message)
response = result.choices[0].message.content
catch {

@sebastiaanel Have you followed the video above steps, because it have the solution for this problem

1 Like

they are going to teach you how to use API but you need to do your own homework by searching and reading on google @mamacitaboricua


this is the solution :
import SwiftUI

struct OpenAIApp: App {
@StateObject var viewModel = OpenAIViewModel()
var body: some Scene {
WindowGroup {

put this in the entry of the app instead of the one you have now. please watch the video for the explanation.

1 Like

This basically happens because we declared in the view that we have an environmental instance of the viewModel but we didn’t gave it this instance, so in the code I sent we do that @sebastiaanel

Yes thank you a have edit environment to environmentObject

Thank you for the video.

Astil don’t have any respons. the breakpoint don’t stop the code can I share it. a see no Dif.
And a have dis error. Error for queryMetaDataSync: 2 if a send the string. @engomarelsayed

Hey @sebastiaanel

please follow this code : GitHub - EngOmarElsayed/OpenAiStarter , try to figure out what did you do wrong. I really want you to get it, to be able to learn and develop your self. But if after you tried and still stick ping me

Hey @engomarelsayed

I have found the breakpoint issue. but in my project and the GitHub branch have the same error’s now.

  1. Error for queryMetaDataSync: 2
  2. The operation couldn’t be completed. (OpenAI.APiManger.(unknown context at $104d2b1a0).error error 1.)
    dis is wit my key and the GitHub key for openAI

@sebastiaanel you should use your own Api Key.

Hey every one,

I hope you enjoyed today’s session, and the code is published on the repo. And don’t forget to use your own OpenAi key

1 Like

Hey @engomarelsayed

I have here the picture of th project. win the error if I run the project.
I have make a video wit edit breakpoints. (private no public)
error The operation couldn’t be completed. (OpenAI.APiManger.(unknown context at $104d2b1a0).error error 1.)

guard (response as? HTTPURLResponse)?.statusCode == 200 else {
print((response as? HTTPURLResponse)?.statusCode)
throw error.invalidResponse

can you add this instead the guard you have to see the status code we have ?

error after the edit


The operation couldn’t be completed. (OpenAI.APiManger.(unknown context at $10482ee6c).error error 1.)

we need to create a new account on openAi.

your credits are expired