{"id":14909,"date":"2025-10-23T16:02:58","date_gmt":"2025-10-23T21:02:58","guid":{"rendered":"https:\/\/www.mrc-productivity.com\/docs\/?post_type=ht_kb&#038;p=14909"},"modified":"2025-10-24T11:29:55","modified_gmt":"2025-10-24T16:29:55","slug":"passing-parameters-to-the-ai-assistant","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/passing-parameters-to-the-ai-assistant","title":{"rendered":"Passing Parameters to the AI Assistant"},"content":{"rendered":"\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">Parent article:<strong> <a href=\"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/ai-assistant-template\" data-type=\"ht_kb\" data-id=\"14783\" target=\"_blank\" rel=\"noreferrer noopener\">AI Assistant template<\/a><\/strong><\/p>\n\n\n\n<p>Similar to how other m-power applications can be supplied parameters at runtime, the AI Assistant is no exception to this. This documentation will walk through how to pass parameters at runtime to the AI Assistant.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setup with the AI Assistant<\/h2>\n\n\n\n<p>Here&#8217;s how that setup with the AI Assistant looks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Data Model<\/h3>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p>A new parameter called CZIP is defined in the data model, which will serve as the appropriate placeholder to store in this case a zip code parameter:<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69d3da757ceb9&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69d3da757ceb9\" class=\"wp-block-image size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/docs\/vue-images\/ai_assistant_zipcode_parm.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><figcaption class=\"wp-element-caption\">Figure 1. The AI Assistant with a custom parameter for storing a zip code value.<\/figcaption><\/figure>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>System Prompt<\/strong><\/h3>\n\n\n\n<p>The AI Assistant is this example, is given instructions to verify if a zip code is valid or invalid, but does not need the parameter defined here. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>##ROLE\nYour role specifically is to take is to take a zip code and verify if that's a valid or not.\n\n##GUIDELINES:\nYou need to respond ONLY with two options once an address is provided.\n\nOption 1. \"valid\" if the zip is valid.\nOption 2. \"invalid\" if the zip is invalid or not found.<\/code><\/pre>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h3 class=\"wp-block-heading\">3. <strong>User Prompt<\/strong><\/h3>\n\n\n\n<p>The user prompt will need the parameter defined here, as it done like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Zip Code: <strong>${CZIP}<\/strong><\/code><\/pre>\n\n\n\n<p>As can be seen, the default variable <code>${message}<\/code> has been removed, replaced by the above code. Defining the parameter in the user prompt, allows the chatbot to &#8220;see&#8221; the zip code as a dynamic value, and appropriately pass a zip code into the substitution.<\/p>\n\n\n\n<p>By removing, default user message substitution, this means chatbot will no longer be utilized interactively via the chat window.  Now every time the chatbot is invoked it will send this as the message:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Zip Code: VALUE<\/code><\/pre>\n\n\n\n<p>If an application that calls my AI Assistant ends up passing a zip code value of 60107 to it, then the message to the assistant evaluates as:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Zip Code: <strong>60107<\/strong><\/code><\/pre>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">Any parameter that will be sent into the AI Assistant at runtime <strong>must <\/strong>be defined in both the Data Model, as well as the User Prompt page, in order for the value to be passed in.<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h3 class=\"wp-block-heading\">Calling your AI Assistant via a URL<\/h3>\n\n\n\n<p>When testing m-Power applications, passing parameters via the URL is common tactic to visually see what results are coming back. In situation where the AI Assistant chatbot is not ran interactively, but rather invoked as workflow behind-the-scenes, it can be called via a URL for testing purposes to confirm the response coming back. <\/p>\n\n\n\n<p>To test the response from any AI Assistant, append the append the chat=1 parameter to the URL, along with a value for my zip code field, CZIP.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\/mrcjava\/servlet\/ESPINDOLA_AI.I00070s?slnk=1<strong>&amp;chat=1<\/strong>&amp;CZIP=60107<\/code><\/pre>\n\n\n\n<p>When a valid zip code is passed, I see the returned response from the chatbot is &#8220;valid&#8221;. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/ai_assistant_url_debug1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>When an invalid zip code is passed, the chatbot&#8217;s returned response is &#8220;invalid&#8221;:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/ai_assistant_url_debug2.png\" alt=\"\"\/><\/figure>\n<\/div><\/div>\n\n\n\n<p>At this point, this AI Assistant is ready to accept a value for a zip code when it&#8217;s invoked. To see an example of how this parameter would be utilized in a real-world application, continue onto the next section below. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Real-world application<\/h2>\n\n\n\n<p>I have a Data List with Web Form maintainer that allows new customers to be entered. When a customer is entered, the zip code associated to their address will be verified by the AI Assistant as valid or invalid. The workflow in totality is as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The customer maintainer form is submitted.<\/li>\n\n\n\n<li>The Workflow Designer within the customer maintainer looks up the AI Assistant, passing the entered zip code.<\/li>\n\n\n\n<li>The AI Assistant retrieval returns a result of &#8220;invalid&#8221; or &#8220;valid&#8221; depending on if the zip code is valid.<\/li>\n\n\n\n<li>If the AI Assistant returns &#8220;invalid&#8221;, then a workflow condition is utilized to throw an error message back to a web form.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Workflow Designer (maintainer)<\/strong><\/h2>\n\n\n\n<p>The AI Assistant retrieval, is called via the &#8220;Call AI Assistant&#8221; action and importantly maps the zip code from the maintainer form, to the zip code parameter in the chatbot (refer to Figure 2).<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69d3da757da34&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69d3da757da34\" class=\"wp-block-image size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/docs\/vue-images\/ai_assistant_zip_workflow.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><figcaption class=\"wp-element-caption\">Figure 2. The workflow of the maintainer, which maps the from field (CZIPCODE) to the parameter (CZIP) in the AI Assistant.<\/figcaption><\/figure>\n\n\n\n<p>Recall from earlier, the AI Assistant&#8217;s system prompt was instructed to return &#8216;invalid&#8217; if the zip code is not a valid zip code and &#8216;valid&#8217; when it is a legitimate zip code. <\/p>\n\n\n\n<p>Therefore after the AI Assistant call, a condition that checks the assistant response for &#8216;invalid&#8217; is what follows (Figure 3).<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69d3da757dc2c&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69d3da757dc2c\" class=\"wp-block-image size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/docs\/vue-images\/ai_assistant_pass_parms_workflow2.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><figcaption class=\"wp-element-caption\">Figure 3. Checking the AI Assistant response via a condition<\/figcaption><\/figure>\n\n\n\n<p>At runtime, when an invalid zip code is passed, the form correctly returns an error message:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/ai_assistant_pass_parms_runtime1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to pass values from other m-Power applications into your AI Assistant&#8217;s parameters. <\/p>\n","protected":false},"author":2,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[313],"ht-kb-tag":[],"class_list":["post-14909","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-artificial-intelligence-ai"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/14909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/comments?post=14909"}],"version-history":[{"count":17,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/14909\/revisions"}],"predecessor-version":[{"id":14946,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/14909\/revisions\/14946"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/media?parent=14909"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=14909"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=14909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}