4 Steps to Integrate cashbot.ai into your Chatfuel Bot

Make money with cashbot.io
Chatfuel Logo

Introduction

Here at BotList, we love the creators of any and all chatbots. That’s why we want to tell you how to make money with them! In this blog post, we will walk you through the process of integrating cashbot.ai into your Chatfuel Facebook bot. cashbot.ai is a monetization platform that empowers developers to create monetization opportunities that feel natural and add value to their chat and conversational experiences.

Getting Started

You will need to do a few things before you can integrate cashbot.ai into your Chatfuel bot:

Registering a New User

You will want to register your users with cashbot.ai during their initial interactions with your bot. Typically these initial interactions occur in the ‘Welcome message’, but if you have a different initial flow for your users, you will want to apply the following changes there.

Assuming you use the ‘Welcome message’ BUILD-IN BLOCK, you should be able to modify it by going to the ‘Build’ section of the Chatfuel dashboard and clicking the ‘Welcome message’ BUILD-IN BLOCK. The configuration settings for the block should load (see Figure 1).

Welcome message BUILD-IN BLOCK configuration

Figure 1. Welcome message BUILD-IN BLOCK configuration


Under ‘ADD A CARD’, click the ‘+’ symbol and select the JSON API Plugin (see Figure 2).

The JSON API Chatfuel plugin

Figure 2. The JSON API Chatfuel plugin


Change ‘TYPE’ from ‘GET’ to ‘POST’. Set ‘URL’ to the following:

https://api.cashbot.ai/recommend/{{ chatfuel user id }}/query/user?apiKey=API_KEY

Substitute your API key in place of ‘API_KEY’ in the URL. Add the following ‘USER ATTRIBUTES’ to the request:

{{ first name }}, {{ last name }}, {{ gender }}, {{ locale }}, {{ profile pic url }}, {{ timezone }}

See Figure 3 for reference.

JSON API Plugin settings for registering a user

Figure 3. Example JSON API Plugin settings for registering a user


That’s it! Initial information about your new user is now registered with cashbot.ai. If you need to update any of the user’s information at a later point in the experience, set up a JSON API plugin just like this one. The POST will overwrite any existing information about the user in the system.

Getting cashbot.ai Recommendations

You will be using the JSON API plugin within an existing block or by creating a new block. The following instructions describe how to create a special ‘GetRecommendations’ block dedicated to getting cashbot.ai recommendations.

Go to the ‘Build’ section of the Chatfuel dashboard and click the ‘+’ symbol under the ‘ADD BLOCKS HERE’ section.

Name your new block something obvious like ‘GetRecommendations’. Under ‘ADD A CARD’, click the ‘+’ symbol and select the JSON API Plugin (see Figure 2).

Set ‘URL’ to the following:

https://api.cashbot.ai/recommend/{{ chatfuel user id }}/query?apiKey=API_KEY

Substitute your API key in place of ‘API_KEY’ in the URL. See Figure 4 for reference.

JSON API Plugin settings for getting recommendations

Figure 4. Example JSON API Plugin settings for getting recommendations


Cashbot provides a few optional parameters to help tailor the recommendations from cashbot.ai.

n: the number of recommendations to present between 1 and 20, default 5
label: the label of the action button within the recommendation widget (must be URL encoded), default 'Check it out'
widget: the type of Facebook widget displayed to the user ('carousel', 'list', 'card'), default 'carousel'
 
Note: the Facebook 'list' widget displays a maximum of 4 recommendations and the Facebook 'card' widget displays a maximum of 1 recommendations, regardless of n

Here is an example URL that uses all of the optional parameters:

https://api.cashbot.ai/recommend/{{ chatfuel user id }}/query?apiKey=API_KEY&n=3&label=Click+Here&widget=list

That’s it! You can now add this block to any response where you want to present recommendations to your user. See Figure 5 for an example.

‘AI RULE’ with ‘GetRecommendations’ block response

Figure 5. Example ‘AI RULE’ with ‘GetRecommendations’ block response


Improving cashbot.ai Recommendations

You will be using the JSON API plugin within an existing block or by creating a new block. The following instructions describe how to create a special ‘PostInputText’ block dedicated to submitting user text inputs, which will be used by cashbot.ai to potentially improve recommendations for your users.

Go to the ‘Build’ section of the Chatfuel dashboard and click the ‘+’ symbol under the ‘ADD BLOCKS HERE’ section.

Name your new block something obvious like ‘PostInputText’. Under ‘ADD A CARD’, click the ‘+’ symbol and select the JSON API Plugin (see Figure 2).

Set ‘URL’ to the following:

https://api.cashbot.ai/recommend/{{ chatfuel user id }}/query?apiKey=API_KEY

Substitute your API key in place of ‘API_KEY’ in the URL. Add the following ‘USER ATTRIBUTES’ to the request:

{{ last user freeform input }}

See Figure 6 for reference.

JSON API Plugin settings for submitting user text inputs to improve recommendations

Figure 6. Example JSON API Plugin settings for submitting user text inputs to improve recommendations


By default, ‘PostInputText’ does not provide a response. This means, when you use the ‘PostInputText’ block in a response, the ‘PostInputText’ block will not affect the interaction with the user in any way. It simply records the response with cashbot.ai.

However, there are a few optional parameters that allow you to include cashbot.ai recommendations in the response. In order to do so, you must add the ‘recommend’ parameter to the URL:

recommend: a true or false variable to optionally return recommendations in the response, default false

Here is an example URL that includes the ‘recommend’ optional parameter:

https://api.cashbot.ai/recommend/{{ chatfuel user id }}/query?apiKey=API_KEY&recommend=true

If you choose to include recommendations in the response, there are a few additional parameters that can be used to tailor the response. These parameters have no impact unless ‘recommend’ is set to ‘true’.

n: the number of recommendations to present between 1 and 20, default 5
label: the label of the action button within the recommendation widget (must be URL encoded), default 'Check it out'
widget: the type of Facebook widget displayed to the user ('carousel', 'list', 'card'), default 'carousel'
 
Note: the Facebook 'list' widget displays a maximum of 4 recommendations and the Facebook 'card' widget displays a maximum of 1 recommendations, regardless of n

Here is an example URL that uses all of the optional parameters:

https://api.cashbot.ai/recommend/{{ chatfuel user id }}/query?apiKey=API_KEY&recommend=true&n=3&label=Click+Here&widget=list

That’s it! You can now add this block to any response where you want to submit what your user says to cashbot.ai in order to improve the recommendations for your users. See Figure 7 for an example.

‘AI RULE’ with ‘PostInputText’ block response

Figure 7. Example ‘AI RULE’ with ‘PostInputText’ block response


If you want to create a block to submit button interactions to cashbot.ai, you simply change the ‘USER ATTRIBUTES’ in the request to:

{{ last clicked button name }}

See Figure 8 for reference.

JSON API Plugin settings for submitting user button clicks to improve recommendations

Figure 8. Example JSON API Plugin settings for submitting user button clicks to improve recommendations


Recommended cashbot.ai Blocks

We recommend you create individual blocks for all the potential use cases for cashbot.ai within your bot. Some recommended blocks include:

GetRecommendations: Get recommendations for user
PostUser: Update user information
PostInputText: Submit user text input (no response)
PostInputButton: Submit user button click (no response)
PostTextGetRecs: Submit user text input, get recommendations
PostButtonGetRecs: Submit user button click, get recommendations

With these pre-defined blocks, you should be able to easily integrate cashbot.ai into Chatfuel bot where ever you want.

Support

If you run into any issues, please reach out to support@cashbot.ai or on the Facebook Page at https://www.facebook.com/BOTMONETIZATION. Thanks!

Save

Comments

Love building cool things, currently working on cashbot.ai and a couple other fun projects.