Create AI Assistants with Magic Cloud
Tags: ai, lowcode, openai, chatgpt
Published: 2024-05-28 14:37:06

Today we release our newest addition to the Magic Cloud AI toolchain; AI assistents - Or _"AI functions"_ as we refer to them as.

An AI functions is just a special training snippet that allows OpenAI to construct function invocations, that is locally executed on your cloudlet, for then to transmit the response back to OpenAI again.

This allows you to ask questions such as; _"Retrieve the 5 last customers from my CRM system, and return their email address to me"_ - All from within your familiar AINIRO AI chatbot. To understand the feature it might be beneficial to watch the following video.

{% embed https://www.youtube.com/watch?v=HVWngzO68YY %}

## How it works

We already had [Hyperlambda workflows](https://docs.ainiro.io/workflows/), and the ability to create such workflows using No-Code constructs and Low-Code constructs. The only thing we really needed to do to create assistents logic, was to implement support for declaratively add workflows into your machine learning type. This is done as follows.

1. Open the Machine Learning component in your Magic dashboard
2. Click training data
3. Choose your type in the filter select dropdown listbox
4. Click the _"Add function"_ button

Once you've done the above steps, you'll end up with something resembling the following.

![Adding an AI function to your machine learning type](https://ainiro.io/assets/images/blog/adding-an-ai-function-to-machine-learning-type.png)

**Warning!** This feature is an experimental BETA feature. We might change the logic in future releases resulting in that you'll have to modify your code. If you're comfortable with this, feel free to play with the AI assistents logic in Magic as much as you wish.

Once you've selected a workflow from the above screen, you can prompt engineer your training snippet as much as you wish. Just make sure its core logic stays as it is when created by Magic, since the AI function feature in Magic depends upon OpenAI returning a very specific result when it wants to invoke such workflows.

AI function invocations can be chained, something illustrated in the above video, where I provide a prompt that invokes OpenAI multiple times, once for each function, where the output from one function invocation is used as input to another function invocation. To understand how this works, consider the following screenshot.

![Invoking two AI functions with one prompt](https://ainiro.io/assets/images/blog/invoking-two-ai-functions.png)

## No-Code Hyperlambda Workflows

Currently, out of the box, Magic doesn't have many workflows - But creating workflows is extremely easy. Just create a new module, or use an existing module, make sure your module has a folder called _"workflows"_, and add Hyperlambda files into this folder as you see fit.

The process can be done completely without manually having to create code. To understand the concept, you might want to watch the following video. Notice, your workflow Hyperlambda files _does not_ need to be HTTP endpoints.

{% embed https://www.youtube.com/watch?v=ITz1ASqsWoM %}

Then when you go click the _"Add function"_ button on your type's training snippets, your workflow will automatically pop up and be possible to select.

## Future Development

In the future we will add lots of pre-existing workflows, covering all sorts of scenarios. Examples could be for instance.

* Scrape website
* Create customer in CRM system
* Send summary of conversation to my email address
* Etc, etc, etc

However, for the time being, the only real workflow we've got out of the box is _"Send owner an email"_, which serves kind of like an alternative to _"Contact us"_ forms. In addition we are considering bridging the backend generator and scaffolding parts of Hyperlambda with such AI functions, allowing you to rapidly add _"CRUD AI functions"_ to your AI chatbot.

In addition, we are considering re-animating our _"AI Expert System"_, in a new form, allowing you to have privately accessible AI chatbots that you only expose to those you want to expose these to. This would provide an alternative to GPT assistents, possibly with integrated monetization capabilities, allowing you to rapidly create your own SaaS-based AI chatbots.

## Conclusion

Having AI assistents capabilities in your AI chatbots opens up a completely new axiom, and is an addition to all the nifty features we already have in Magic Cloud. With this feature, our core technology have taken a huge leap forward in regards to usability and usefulness. If you want to discuss how we can help you out solving your particular needs related to AI, you can contact us below.

* [Contact us](https://ainiro.io/contact-us)

**Disclaimer**; This part of Magic is not completely stabilised yet, and should be considered an experimental feature. However, this is something we will spend a lot of energy on stabilising and expanding upon - So expect to see a lot more from this feature in the future.