Best practices for writing AI custom actions

The Montoya API enables you to integrate AI-powered functionality into your custom actions. Follow these best practices to ensure your custom action is secure, efficient, and produces high-quality results.

Note

For examples of AI-powered custom actions that have been created by our research team and the community, see our GitHub repository.

To learn how to add AI-powered features to your custom actions, see Developing AI features in custom actions.

To learn how to create your own custom actions, see Writing custom actions.

Mitigate prompt injection attacks

Treat raw output from AI models as untrusted. Escape any AI-generated content before presenting it to users. Make sure that you use proper HTML encoding to neutralize potential threats.

Optimize AI requests for efficiency and security

To ensure AI interactions are efficient, secure, and cost-effective, it's important to control what data is sent, how it's formatted, and when requests are made.

To optimize requests effectively:

Use effective prompts

A well-structured prompt helps the AI to provide relevant and high-quality responses. We recommend that you:

More information

For more information, see Developing AI features in custom actions - Sending prompts and handling responses.

Use lower temperatures for better accuracy

The temperature setting controls the balance between predictability and creativity in AI responses:

The default temperature is 0.5.

More information

For more information, see Developing AI features in custom actions - Setting the temperature.