GoogleCloudPlatform / dialogflow-integrations

Dialogflow integrations with multiple platforms including KIK, Skype, Spark, Twlio, Twitter and Viber
https://cloud.google.com/dialogflow/
Apache License 2.0
256 stars 503 forks source link

Agent Resource type returns null in Dialogflow Fulfilment #34

Closed nidhinkumar06 closed 4 years ago

nidhinkumar06 commented 4 years ago

I have used cloud functions for my action. Based on the agent resource type, I am sending the response back. As per the guidelines provided in the document i have changed the Twilio integration. After deployment when i check the agent.requestSource type it returns null. Earlier it returns 'twilio' or 'GOOGLE_ASSISTANT' but now it returns null.

Logs: Click here to view it

Implementation Code

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(
  (request, response) => {
    console.log("Dialogflow Request body: ", request.body);
    const agent = new WebhookClient({ request, response });
    console.log("agent originalRequest", agent.originalRequest);
    console.log("Agent resource", agent.requestSource);
    const conv = agent.conv();
    let sender;
    let receiver;

    if (agent.requestSource === "twilio") {
      const requestBody = request.body;
      sender = requestBody.originalDetectIntentRequest.payload.data.From;
      receiver = requestBody.originalDetectIntentRequest.payload.data.To;
    }
........
nidhinkumar06 commented 4 years ago

I have added the source in the request body like below and now it works fine

let body = req.body;
body.source = 'twilio';