Activechat Essentials

E-commerce Chatbots

Advanced Chatbot Tools

Tracking code installation

Tracking page visits

Natural Language Chatbots

Intents and Entities

NLP contexts

Building Dialogflow agent and connecting to Activechat

Sending user input to NLP engine

Triggering bot skills by intents and events

Working with entities

Slot filling

Using contexts

NLP best practices 

Referral chatbot script

Building a referral chatbot? Easy as 1-2-3 with Activechat!

We’ve built a set of scripts that will allow you to track referral users in bots that you build on our platform. You’ll be using JSON block to call these scripts and you can find example in “Referral chatbot” template in Templates section.

The logic is quite simple – every time one chatbot user invites another user to your offer (achieved easily with sharing  card with your offer on Messenger, use “Share” button type) you can use “ADD” script to add referral points to inviting user and store names and IDs of invited users. 

Later you can use “GET” script to check the amount of points earned by any user and trigger “CLEAR” script to remove data that is already collected in the database.

Please check “Referral chatbot” template to see example usage of these scripts for a simple referral program chatbot. 

Script endpoints

Three basic endpoints help you track referrals, add points, get current amount of referred users and clear data in case you need to start from scratch.

 

https://e-commerce-referral.herokuapp.com/ref_click/add (POST)

Calling this script will add one referral point to the user with refID and add userID and first_name last_name to the list of referred users in the database. 

Returns $ok value which is set to true when points were added successfully and false in case of an error.

 

Parameters

ID of your chatbot. Can be obtained from $_agentid system variable.

Messenger ID of referring user. Can be obtained from “ref=” parameter of bot Messenger link.

Messenger ID of user that is being referred. Can be obtained from $_id system variable for the current bot user.

First name of user that is being referred. Can be obtained from $_first_name system variable for the current bot user.

Last name of user that is being referred. Can be obtained from $_last_name system variable for the current bot user.

Example call
referral chatbot example

https://e-commerce-referral.herokuapp.com/ref_click/get (POST)

Calling this script will fetch existing points for user with refID from the database. 

Returns $_ref_clicks with total amount of referral points for that user, $_ref_user_ids with the list of IDs of referred users (“|”-separated) and $_ref_user_names with the list of names of referred users (comma-separated).

 

Parameters

ID of your chatbot. Can be obtained from $_agentid system variable.

Messenger ID of referring user. Can be obtained from $_id system variable for the current bot user.

Example call
referral chatbot script

https://e-commerce-referral.herokuapp.com/ref_click/clear (POST)

Calling this script will erase existing points for user with refID from the database. 

Returns $ok value which is set to true when points were erased successfully and false in case of an error.

 

Parameters

ID of your chatbot. Can be obtained from $_agentid system variable.

Messenger ID of referring user. Can be obtained from $_id system variable for the current bot user.

Example call
referral chatbot erase points

Sending messages to referring users

Usually it’s a good practice to add referral points to inviting user only after invited user achieves a specific point in your bot conversation (for example, makes a purchase or shares his/her email and becomes a lead). 

When this happens, you can use Activechat API to trigger specific event for inviting user and send him/her a heads up message – something like “Hey, you’ve just got a new referral and now have XX points!”

Again, please check Referral bot template for example (“new_ref” skill is triggered through API from “start” skill with Zapier webhook).