---
sourceDocument: Australia Customer Service Management
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/pt-BR/customer-service-management

 Release :

    - australia

ft:locale :

    - pt-BR

ft:publication_title :

    - Australia Customer Service Management

ft:clusterId :

    - csm

bundleId :

    - csm

workflow :

    - Customer and Industry


---

# Launch a feature using custom code

# Launch a feature in Engagement Messenger using custom code {#ariaid-title1}

* Versão de lançamento: Australia
* 
* Atualizado 12 de mar. de 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 min. de leitura

Use the custom code to enable the deep linking and launch a feature in Engagement Messenger integrated with your website.

## Antes de Iniciar

[Configure Engagement Messenger](https://servicenow-prod.fluidtopics.net/WzCd7bSDUS0OpR7P6cFVpw "Create a Engagement Messenger module and configure its behavior, appearance, and styling. By creating a messenger module, you can customize the appearance and behavior according to your organizational branding and to suit your customer needs.").

[Embed Engagement Messenger in your web application](https://servicenow-prod.fluidtopics.net/nWfOxv1GVnCUHo7AjNG35w "Embed the source code of the messenger module that you configured in your website so that you can enable your customers to start using Engagement Messenger in your website.").

Role required: ec_admin and website administrator

## Por Que e Quando Desempenhar Esta Tarefa

Nota:  
If you're using existing code, verify that you update the script to show `v=3.1`. For example:  

    <script src="https://example.service-now.com/scripts/sn_csm_ec.js?v=3.1"></script>
    <script>
    SN_CSM_EC.init({
          moduleID: "https://example.service-now.com/#aeff0547dd393010f87734cef087e2ba",
          loadFeature: SN_CSM_EC.loadEMFeature()
    });
    </script>

## Procedimento

1. Navigate to Engagement MessengerModules.
2. In the Configure Engagement Messenger Module, open the Implement tab.
3. Copy the code from the Embed code section.
4. In a text editor, open the HTML file of the web page on your website where you integrate Engagement Messenger.
5. Paste the code that you copied before the closing body tag.
6. Define the feature context and specify the variables for the feature.  
   Use the following format to define a feature context:

       { 
       	feature: "<var class="keyword varname">&lt;feature_name&gt;</var>", 
       	openOnLoad: <var class="keyword varname">&lt;true/false&gt;</var>, 
       	params: { 
       		"<var class="keyword varname">&lt;param_name&gt;</var>": "<var class="keyword varname">&lt;param_value&gt;</var>",
       		"<var class="keyword varname">&lt;param_name&gt;</var>": "<var class="keyword varname">&lt;param_value&gt;</var> 
       	} 
       }

   In the format, specify the feature variables.

   feature
   :   The feature name. For more information, see [Feature context parameters supported in Engagement Messenger](https://servicenow-prod.fluidtopics.net/2pPxAiGSRGvnTmbJSKI6uw "Features for contextual launch capability enable you to set the default launch screen in Engagement Messenger.")
       .

   openOnLoad
   :   Include this option and set it to true only if you want Engagement Messenger to open automatically. The default setting for this option is for Engagement Messenger not to open automatically.

   \<param_name\>": "\<param_value\>
   :   Name and value of a parameter associated with the feature. For more information, see [Feature context parameters supported in Engagement Messenger](https://servicenow-prod.fluidtopics.net/2pPxAiGSRGvnTmbJSKI6uw "Features for contextual launch capability enable you to set the default launch screen in Engagement Messenger.").
7. Create a custom wrapper function to pass the feature context to the `SN_CSM_EC.init` function of the embed code.  
   For example, the following code uses the `chatFeatureContext()` custom wrapper function for the chat feature context.


       function chatFeatureContext(){ 
       	return { 
       			feature: "CHAT",
       			openOnLoad: false,
       			params: { 
       				"topic_id": "8708db281bd5b81080df6247b04bcb79",
       				"language": "fr"		
       				} 
       		  } 
       }

   {#contextual-launch-using-script-engagement-messenger__wrapper-creation}
{#contextual-launch-using-script-engagement-messenger__wrapper-creation}
8. Replace the `SN_CSM_EC.loadEMFeature()` function with a custom wrapper function that you created in [step 7](https://servicenow-prod.fluidtopics.net/6K9aBgqqKcNOf~EWKvtMPw "Use the custom code to enable the deep linking and launch a feature in Engagement Messenger integrated with your website.").  
   For example, in the following code, the `chatFeatureContext()` wrapper function is passed as the value of the `loadFeature` attribute.

       SN_CSM_EC.init({ 
       		moduleID: "https://example.service-now.com/#<module_id>", 
       		loadFeature: <var class="keyword varname">chatFeatureContext</var>()
       }); 

9. Save the file.
10. **Opcional:** Verify that the designated feature launches.
    1. Open the website in which you embedded Engagement Messenger.
    2. Select the launcher icon.
    3. Verify that Engagement Messenger launches feature you configured in the embed code.
    {#contextual-launch-using-script-engagement-messenger__substeps_gjt_cts_4qb}

## Resultado

The feature you specified in the embed code is launched by default when Engagement Messenger is opened in the website in which it's embedded.

## Exemplo

The following code initiates the chat feature by default. It also shows how to trigger a Virtual Agent topic by default when chat is loaded by passing the system identifier (sys_id) of the topic. You can also specify a language to initiate chat in that language.

    <script src="https://example.servicenow.com/scripts/sn_csm_ec.js?v=3.1"></script>
    <script>
    function chatFeatureContext(){ 
    	return { 
    			feature: "CHAT",
    			openOnLoad: false,
    			params: { 
    				"topic_id": "8708db281bd5b81080df6247b04bcb79",
    				"language": "fr"		
    				} 
    		  } 
    }

    SN_CSM_EC.init({
    	moduleID: "https://example.service-now.com/#d27c94d6db403810a2a6a0ced39619da",
    	loadFeature: chatFeatureContext()
    });
    </script>

function
:   <var class="keyword varname">chatFeatureContext()</var>: The wrapper function for chat context.

feature
:   <var class="keyword varname">CHAT</var>: The chat feature for initiating Virtual Agent or Live Agent chat.

openOnLoad
:   <var class="keyword varname">false</var>: Disable the automatic launch of Engagement Messenger.

topic_id
:   <var class="keyword varname">8708db281bd5b81080df6247b04bcb79</var>: The module system identifier (sys_id).

language
:   <var class="keyword varname">fr</var>: Sets the default chat language to French.

