How to manage URL Params and Query strings

As an admin user, you can load a different flow studio flow based on the webpage the chatbot user launches the chatbot from. This document will brief you on how to use the URL Parameters and Query Strings in your Experience Designer flows.

URL Parameter

Defining a URL Parameter

You should first define a variable in URL/Endpoint fields of the http in nodes and the Bot View Template node.

<chatbot endpoint>/:<variable-name>

The URL Parameter used in the chatbot URL will be available at msg.req.params.<variable-name>

In the Bot In Parser of the Bot Provider V2 Node, you should assign the fetched URL Parameter to the originalRequest object.

msg.payload.originalRequest.data.<userPARAM> = msg.req.params.<variable-name>;

Using the URL Parameter

You can then obtain the URL Parameter in the msg object at msg.payload.originalDetectIntentRequest.payload.<userdefined variable>

For example, it is msg.payload.originalDetectIntentRequest.payload.URLPARAM

Invoking the Chatbot with the URL parameter

You can add any string as the URL Parameter to the Chatbot URL.

https://<domain-name>.orbita.cloud:8443/oeapi/<ChatbotURI>/<URL Parameter>

For example, you can use the https://<domain-name>.orbita.cloud:8443/oeapi/<ChatbotURI>/button to invoke the corresponding flow studio flow.

If you have defined a URL Parameter, you cannot load the chatbot without a URL Parameter.

Query strings

Defining a query parameter

The query params used in the chatbot URL will be available at msg.req.query.<query parameter>

In the Bot In Parser of the Bot Provider V2 Node, you should assign the fetched Query to the originalRequest object.

msg.payload.originalRequest.data.<userdefined variable>=msg.req.query.<query parameter>;

Using the query

You can then obtain the Query value in the msg object at msg.payload.originalDetectIntentRequest.payload.<userdefined variable>

Invoking the Chatbot with the query parameter

You can add the query parameter to the Chatbot URL.

https://<domain-name>.orbita.cloud:8443/oeapi/<ChatbotURI>?<queryparameter>=<query value>

For example, you can use https://<domain-name>.orbita.cloud:8443/oeapi/bot/url-params?flowId=5fe082b28e97c439b7206355

Sample flow

Import the sample flow attached to this document into the Experience Designer.

After importing the flow into the Experience Designer, ensure you do the following:

  1. Disable any other Bot Manager flows you have in the project.

    1. Doubleclick on the Bot Manager flow tab.

    2. Set the status to “Disabled“.

  2. Delete the launch node in the Launch flow.

  3. Open the Assign Query Function node and update the Flow IDs and the URL parameters you will use in the chatbot URL.

You can use any string as a URL Parameter, a Flow ID, and a Control ID in the URL Query String.

Below is an example of the chatbot URL.

https://<domain-name>.orbita.cloud:8443/oeapi/<Chatbot-URL>/<URL-Parameter>?flowId=5fe47a91ac00e9007de98973&controlId=564344216038117574

  File Modified

File URL_Params_and_Queries_Flow.json

Dec 24, 2020 by Rajkiran Alla

Related Articles