Search code examples
botswebhooksdialogflow-esfulfillmentkommunicate

How to use Dialogflow's fulfillment code with Kommunicate


Sorry if this question is dumb but I don't have much experience using Javascript or Dialogflow yet. I have a Dialogflow bot that I've integrated through Kommunicate into a test website. The bot works with responses set through intents, but fulfillment code seems to not run, as any response that's set through fulfillment doesn't happen. The fulfillment is coded through the inline editor.

Here's some responses set through intents:

Intents

And here's a response set through fulfillment:

Fulfillment

Here, you can see the fulfillment response working through the Dialogflow console:

Console Response

And finally, here you can see that it doesn't work through Kommunicate, but the intent response does:

Kommunicate Response

I'm pretty sure my problem is that fulfillment code just isn't running on Kommunicate, and needs to be integrated into Kommunicate in some way that I don't know of. Does anyone know what I need to do?

Edit: I may have found the reason for this. At the bottom of the fulfillment doc it says this: "Network calls originating from your Cloud Function for Firebase to destinations outside Google's network require billing to be enabled for the underlying Google Cloud or Firebase project." Can anyone confirm that this is what I need to do before I try to convince my boss to spend money on it?


Solution

  • You Do not need to enable billing to use Dialogflow. Dialogflow comes with Free Edition and you can develop and test a Bot without enable billing.

    Kommunicate supports Dialogflow's default response as well as custom webhook. working with default response straightforward. Enter text response or any Actionable message supported by kommunicate in Custom Payload and Kommunicate will automatically render it in chat UI.

    If you have enabled webhook call for the Intent, You can use fulfillmentText field to return array of text messages or fulfillmentMessages field to return Actionable message as described in Dialogflow docs.

    Kommunicate uses these fields to determine what message will be shown in the UI. If both fields present Both will be rendered in UI. Here is an example how your webhook response look like:

    {
        "fulfillmentText": "render a text message from webhook",
        "fulfillmentMessages": [{
          // message 1 (optional)- render actionable message 
            "payload": {
                "message": "render a Actionable message from webhook",
                "platform": "kommunicate",
                "metadata": {
                    // replace this with metadata JSON supported by kommunicate 
                }
            }
        }, {
          // message 2 (optional)- render a text message  
            "text": {
                "text": ["render array of  text message from webhook"]
            }
        }]
    }
    

    This JSON will render messages on UI. You can customize this as per your need. Here is more information on dialogflow fulfilment with kommunicate.

    If You still not able to get it working, send your queries at [email protected].

    PS: I work for Kommunicate.