4 Steps to Integrate cashbot.ai into your Chatfuel bot

Eyelevel.ai
Dev Tutorials
Published in
6 min readDec 16, 2017

--

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. For more information about cashbot.ai, please visit our website at https://cashbot.ai.

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).

Figure 1. Welcome message BUILD-IN BLOCK configuration

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

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.

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.

Figure 4. Example JSON API Plugin settings for getting recommendations

We provide 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.

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.

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. Simply record the response with cashbot.ai.

However, there are a few optional parameters that can enable you to optionally include cashbot.ai recommendations in the response from ‘PostInputText’. In order to do so, you must add a 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 uses 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.

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.

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 blocks predefined, you should be able to drop them into any response you see fit.

Support

If you run into any issues, please reach out to us at support@cashbot.ai. Thanks we love you!

--

--

Writing about innovative ways to use chatbots for lead gen, conversation design, and other cool stuff in the conversational advertising space.