
I am reading through everything and trying to wrap my head around functions. Is it possible to call/invoke one function from another function? I see the Events, but not sure that is ideal and it smells like a hack. And probably not workable if I need to get a return from the child function in the parent, calling function. I could do a second http call to the child function and handle that way, but using the network layer again seems like overhead. Do you have any documentation or recommended way of handling these scenarios? Thanks in advance.

it depends on what you're trying to achieve...

Yes, you can execute a function from a function.
People typically use the event system to execute a function on document or file create/update

Hmm. Take the notion of push notifications. I need to be able to send them out at numerous times under numerous scenarios - user mentioned in chat, event closed and winner determined, event about to start and players not picked so they aren’t officially entered, etc. There are multiple scenarios. Some can be tied easily to document update/create (like the users name mentioned in chat) but others are not so easily done (players not picked and a day before tournament starts so notification needs sent). My idea was to have a PushNotification function and call it from various other functions (like before record is updated on chat insert, or the function that determines who hasn’t made their picks before a tournament starts). Writing to a temp table/document seems like a hack. While I can do it, not sure I should. Can you point to the documentation that shows how to call a function from another function? And also any best practices around this situation?

hit send to early >.< hold on
It's all up to you how you want to architect things. In my opinion, having a Push Notification Appwrite Function seems like it would add some overhead.
if you want to reuse code, you could have a common folder with code that is shared across multiple functions.
As for the actual Appwrite Functions, you could have 1 Appwrite Function for each notification and trigger based on event or cron.
Or you could make 1 giant Appwrite Function and then based on the event or whatever, send the appropriate push notification.
Again, it's all up to you how you want to architect things.
Can you point to the documentation that shows how to call a function from another function?
There's nothing special to this. You'd execute a function just like from client: functions.createExecution()

Ah! Looks like I was overthinking it. The common folder might be perfect. Next time I will search the client documentation too and see if the solution is there. Thanks so much for all your help. Have a great day!

FYI, the best thing to do to avoid having a duplicate common folder in each one of your functions would be to put the common folder in your functions folder (along side your other functions) and then symlink to that common folder from inside your functions

Beautiful. Thanks so much! Feel free to close this

[SOLVED] Function invoking other function
Recommended threads
- What's the correct way to send a file to...
Hello everyone! 😊 I have a hard time figuring out the right way to send a file to an Appwrite function. Lets say I have an image that I'd like to pass to a f...
- Function Cannot be deleted
I think this shouldn't happen!
- Domain not available
Message: After creating a function using the Functions API, the domain is not created automatically, even though the documentation says a domain should be creat...
