Buraq Help Center
ProductsBook a demo
  • 😃Welcome to Buraq
    • Buraq Basics
  • šŸGetting Started
    • Building a Chatbot
    • Testing a Chatbot
    • Installation
      • Installation on Website
        • Installation using HTML
        • Installation using Google Tag Manager
      • Installing on Wordpress
      • Installing on SquareSpace
      • Installation on WhatsApp
      • Installation on Facebook
    • Deploying a Chatbot
    • Utility Tools
  • 🟦ACTION BLOCKS
    • Trigger
      • Set values to variables using Trigger
    • Send Message
    • Collect Input
    • Buttons
    • Carousel
    • Calendar
    • Send an Email
    • Condition
    • Image gallery
    • Talk to human
    • Slider
    • Collect file
    • Delay
    • Form
    • Flow
    • Jump
    • Codeblock
      • Dynamic Dialog Generator
    • Options
    • List
    • Reply buttons
    • AI model
    • Dynamic data
  • šŸ¤–AI Studio
    • Overview
      • From URL
      • From File
      • From Intent
  • šŸ”ŒINTEGRATIONS
    • Overview
    • Events
    • HTTP request
    • Javascript
    • Zapier
    • Google Sheets
    • Salesforce
    • Codeblock
    • Airtable
    • Google Calendar
    • Calendly
    • HubSpot
    • Freshdesk
    • DialogFlow
    • Zoho CRM
    • Slack
      • Live Chat for Slack
      • Notification for Slack
    • ActiveCampaign
    • Link Tracking
  • šŸ“²Whatsapp Business API
    • Overview
    • Cost
    • Limitations
    • Getting a WhatsApp API
      • From Meta
        • Creating a Facebook App
        • Adding the phone number
        • Generating permanent token
        • Configuring the webhook on Buraq
  • šŸ’¬Live Chat
    • Overview
      • Live Chat Screen
      • Live Chat Settings
  • āš’ļøTroubleshooting
    • Cloning Bots
    • Connecting Action Blocks
    • Creating Loops
    • Setting up Fallback Variables
    • Setting up Link Tracking
    • Variable Manager
    • Image Dimensions
    • Tracking Facebook Pixel
    • Firing events on Google Analytics
  • ā›”Outbound Bots
    • Overview
    • Building One Off Campaign
    • Building Ongoing Campaign
    • Creating a WhatsApp Template
    • Action Blocks_ Outbound
      • Send WhatsApp
      • Send SMS
      • Delay
      • Branch
  • 🦾CHATBOT CUSTOMIZATION
    • Chatbot Appearance
    • Custom CSS
    • Embed chatbots on website
    • JS functions to show_hide
  • šŸ•µļøā€ā™‚ļøAccount Management
    • Teams
    • Teammates
    • Purchasing a plan
    • Payment Methods
    • Refund Policy
    • Reset Password
    • Deleting Account
  • šŸ“ŠReporting
    • Analytics Dashboard
      • Chatbot Analytics
      • Agent Analytics
    • What are contacts in Buraq?
      • Scheduling a Contact Report
      • Exporting a Contact List
Powered by GitBook
On this page
  • Usecase:
  • Maths Calculations:
  • Rendering values into variables:
  • String Modification:
  • Firing & Tracking events in Google Analytics or any Analytics tool:
  • Triggering day based flow:
  • How do I set it up?
  1. INTEGRATIONS

Javascript

This action block allows you to trigger custom functions of your preference within the flow

Usecase:

Some of the cases where Javascript action block can be used;

  • Performing Maths Calculations

  • Dynamically rendering the values of the variables

  • String Modification

  • Firing & Tracking events in Google Analytics

  • Triggering day based flow

Maths Calculations:

Here are few of the snippets that you can use to perform the maths calculations within the chatbot flow:

Parameter
Snippet
Description

Summation (Addition)

const additionResult = num1 + num2;

  • Num 1 & Num 2 can be any number or variable which has a number stored in it

  • The result will be stored in additionResult variable

Subtraction (Minus)

const additionResult = num1 - num2;

  • Num 1 & Num 2 can be any number or variable which has a number stored in it

  • The result will be stored in additionResult variable

Division (Divide)

const additionResult = num1 / num2;

  • Num 1 & Num 2 can be any number or variable which has a number stored in it

  • The result will be stored in additionResult variable

Multiplication (Multiple)

const additionResult = num1 * num2;

  • Num 1 & Num 2 can be any number or variable which has a number stored in it

  • The result will be stored in additionResult variable

Rendering values into variables:

Here are few of the snippets that you can use to render values in variables.

Parameter
Snippet
Example

Set Variable (Conversation)

wn.setConversationVariable(ā€œvariable_nameā€,ā€variable_valueā€);

Or

Buraq.setConversationVariables({ā€œvariable_nameā€:ā€variable_valueā€})

wn.setConversationVariable(ā€œname_wnā€,ā€ABCā€);

Or

Buraq.setConversationVariables({ā€œt1ā€:ā€123ā€})

Set Variable (Contact)

wn.setContactVariable(ā€œvariable_nameā€,ā€variable_valueā€);

Or

Buraq.setContactVariables({ā€œvariable_nameā€:ā€variable_valueā€})

wn.setContactVariable(ā€œname_wnā€,ā€ABCā€);

Or

Buraq.setContactVariables({ā€œt1ā€:ā€123ā€})

String Modification:

Here are few of the snippets that you can use to calculate the length of the variable or get part of the variable.

Parameter
Snippet
Example

Length of String

const lengthOfString = ā€œvariable_nameā€.length();

const lengthOfString = ā€œsome_string_contentā€.length();

//Output: 19

Calculates the number of characters passed/present in the value

Get part of a string

const partOfString = ā€œvariable_nameā€.slice();

const partOfString = ā€œsome_string_contentā€.slice(5);

Note: We need to pass the starting index from where we need to get the sub-string. The index starts from 0. //Output: string_content Commonly used to pass the phone number without country code

Firing & Tracking events in Google Analytics or any Analytics tool:

Here is the snippet that you can use to push or record events into Google Analytics or any other analytics tool

Tool
Snippet
Example

Google Analytics 4

window.dataLayer = window.dataLayer || [];

function gtag() {

window.dataLayer.push(arguments);

}

gtag("js", new Date());

gtag("config", "YOUR-MEASUREMENT-ID");

gtag("event", "YOUR-EVENT-NAME", {

"send_to": "YOUR-MEASUREMENT-ID"

// Additional parameters that you may want to pass

});

window.dataLayer = window.dataLayer || [];

function gtag() {

window.dataLayer.push(arguments);

}

gtag("js", new Date());

gtag("config", "123");

gtag("event", "WotNot_Test", {

"send_to": "123",

"name": "Test",

"phone": "123456789",

});

Triggering day based flow:

Here is the snippet that you can use to trigger the flow based on specific day

Parameter
Snippet
Description

Get current date

const currentDate = new Date();

Helps to get the today’s date

Check if Fromdate should be more than Todate

isFromDateBeforeToDate(fromDate, toDate) {

const fromDateObj = new Date(fromDate);

const toDateObj = new Date(toDate);

return fromDateObj < toDateObj;

}

Helps to trigger the flow the day specific flow

How do I set it up?

You can follow the following steps to set up the JS action block in Buraq;

  • Add the action block on canvas by clicking on '+'

  • Choose 'Javascript'

  • Double click on 'Javascript' to configure it on the right panel

    • Select 'Execute at' 'Server/Client' based on your preference

    • Define or write the code in the space provided

You can define the variable in the code using '#' at the start and the end of the variable name.

EG: '#name#'

PreviousHTTP request NextZapier

Last updated 1 year ago

šŸ”Œ