How to Access Variables From the Code on Output Step
- Getting Started
- Bot Building
- Smart Agent Chat
- Conversation Design
-
Developer Guides
Code Step Integration Static Step Integration Shopify Integration SETU Integration Exotel Integration CIBIL integration Freshdesk KMS Integration PayU Integration Zendesk Guide Integration Twilio Integration Razorpay Integration LeadSquared Integration USU(Unymira) Integration Helo(VivaConnect) Integration Salesforce KMS Integration Stripe Integration PayPal Integration CleverTap Integration Fynd Integration HubSpot Integration Magento Integration WooCommerce Integration Microsoft Dynamics 365 Integration
- Deployment
- External Agent Tool Setup
- Analytics & Reporting
- Notifications
- Commerce Plus
- Troubleshooting Guides
- Release Notes
Every time we add a code step, there is some functionality that is added to it. And to enable the functioning, we use variables for storing the various types of data, like email id, username, user id, etc.
Let us consider this example, wherein a user is trying to create a ticket on the Haptik platform.
In the above image, we see 5 steps, namely:
- Create ticket (Code step)
- Response for external users without platform (Output step)
- Response for external users with the platform (Output step)
- System Error (Output step)
- Try Again (Static step)
So in the above image, the flow goes from Create Ticket step to all the Output steps.
Whereas, the System Error output steps direct us to the Try again step, which brings us back to Create ticket step. Well, this is a basic flow.
So, the Create ticket code step will trigger any one of the output steps. It can either trigger Response for external users without platform step, Response for external users with platform step, or System Error step. All of this depends on the conditions that have been added by the user.
These conditions are added in the Connections, which determine which output step would be triggered next. As shown in the image below, if the Variable is Status, and its value is true, then it would trigger the System Error output step.
Similarly, there are conditions specified for other output steps as well.
Accessing Variables
Since Create Step is the Code step here, we would be using certain code in the code editor for making it functional. Now, the variables that we have used in this code step, if we want to access those variables in the Output steps as well, we would have to follow certain stages.
- Navigate to the Create Ticket code step by selecting it.
- In the Sample Output JSON format text box, you need to add all the variables that you want to access in the following output steps., as shown in the image below.
- Once you have added all the variables that you need, you can select the Output steps.
- Let's consider the System Error Output step here, and select the Bot response message, as shown in the image below.
- After selecting the Bot response message, you would be able to edit the text, and you would also see the Add variable button, as shown in the image below.
- Upon selecting Add variable, you would be able to access all the variables from the code step, that we had previously added in the Sample Output JSON format text box, of the Create Ticket Code step.
- You can select the required Variables, by tapping the Select button alongside the variable, and it would reflect in the bot response, the message, as shown below.
- Here, I had selected status, user_type, and name. And you can see at the Left-hand side of the image, the Bot Response message does reflect these variables.
So, this is how you can access the variables from the code on the Output step.