3

I see that Dialogflow has fulfiment and webhook installations to allow for further dynamic and logistic control over the bot responses. I'm trying to peg a database on top of the webhook, but the channel I'm using is Twilio Text Messaging, and I'm having a little trouble with connecting the two. When I do activate fulfillment, the twilio bot does not read it. Any way to solve this?

I already created a few webhooks using Flask, and integrated it through fulfillment briefly using ngrok, but the bot is responding via the text responses I set for it. Its for google assistance, and facebook messenger, but not with the Twilio integration. I also tried using inlineJS to see if that held any difference to specifically define Twilio as the messaging outlet to use, however it did not peak success.

const functions = require('firebase-functions');
const {dialogflow} = require('actions-on-google');

const GOODLOCATION = 'location.good'
const NEARLOCATION = 'location.near'
const CHEAPLOCATION = 'location.cheap'
const WELCOME_INTENT = 'Default Welcome Intent'
const FALLBACK_INTENT = 'Default Fallback Intent'
const CRAVINGCULTUREINTENT = 'CravingCulture'
const CRAVINGITEM = 'CravingItem'

const app = dialogflow()

/*Supported Platforms*/

const PLATFORMS = {
  UNSPECIFIED: 'PLATFORM_UNSPECIFIED',
  FACEBOOK: 'FACEBOOK',
  SLACK: 'SLACK',
  TELEGRAM: 'TELEGRAM',
  KIK: 'KIK',
  SKYPE: 'SKYPE',
  LINE: 'LINE',
  VIBER: 'VIBER',
  ACTIONS_ON_GOOGLE: 'ACTIONS_ON_GOOGLE',
  TWILIO: 'TWILIO'
};

// Platforms that support Rich messaging
const SUPPORTED_RICH_MESSAGE_PLATFORMS = [
  PLATFORMS.FACEBOOK,
  PLATFORMS.SLACK,
  PLATFORMS.TELEGRAM,
  PLATFORMS.KIK,
  PLATFORMS.SKYPE,
  PLATFORMS.LINE,
  PLATFORMS.VIBER,
  PLATFORMS.ACTIONS_ON_GOOGLE,
  PLATFROM.TWILIO
];

app.intent(WELCOME_INTENT, (conv)=> {
  if(agent.requestSource === agent.TWILIO){
    conv.ask('This is working, Congratulations!')
  }
  else{
    conv.ask("Could not be served")
  }
});

app.intent(FALLBACK_INTENT, (conv)=> {
  conv.ask("I am unaware of that phrase, could you repeat that?")
});


exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app)

I want the output to be any thing that the user insert through the twilio that this bot will respond accordingly to what is passed in.

Ty Cooper
  • 41
  • 4
  • I'm a little confused - are you getting an error from this or is something not happening? Can you update your question to make it clear what, exactly, isn't working. – Prisoner Apr 28 '19 at 20:48
  • The purpose of what I'm trying to achieve is when a user sends a message like: "nearby" to the bot via sms in order to find a the local store, I want the bot to take that information, pass it into google maps, then return with a link or an address of that location. But I'm having trouble in executing it. – Ty Cooper Apr 29 '19 at 02:09
  • Ok, what is the trouble? Can you update your question showing the code you're using, errors you're getting, etc? See [How Do I Ask A Good Question?](https://stackoverflow.com/help/how-to-ask) – Prisoner Apr 29 '19 at 10:29
  • The trouble I am having is getting the fulfillment to work with Twilio... – Ty Cooper Apr 29 '19 at 19:38
  • Is the welcome intent you have not working? What is the error or what is happening when you try? Is it another intent that isn't working with Twilio? Can you show the code for that Intent? Show a screen shot about what happens when you try? What errors do you get? What "trouble' are you having specifically? – Prisoner Apr 29 '19 at 20:18
  • I'd love to try to help too. Did you get this working? Can you share the code for the intent that isn't working for you? – philnash May 02 '19 at 02:07
  • No I still wasn't able to get it working. Like I said, it's not the intent. It's just that the intents are not working with webhooks in fulfillment using Twillio. It works for google assistance or facebook, but not Twilio. I already shared the code. It's above you in the question. – Ty Cooper May 02 '19 at 02:32

1 Answers1

1

A little late, perhaps - hopefully this issue isn't still blocking/plaguing you.

I'm thinking you were intending:
if(agent.requestSource === PLATFORMS.TWILIO){
not:
if(agent.requestSource === agent.TWILIO){

However, also the value of agent.requestSource is actually lowercase "twilio".