For the ‘test intent’, I have enabled the Enable Webhook Call for this intent
I have correctly setup Telegram integration to the bot.
In the fullfilment code, I am using the Constructor for Payload object(https://dialogflow.com/docs/reference/fulfillment-library/rich-responses#new_payloadplatform_payload)and I have specified the string indicating target platform of payload. Please see in code below the welcome function:
const {WebhookClient} = require('dialogflow-fulfillment');
const {Text, Card, Image, Suggestion, Payload} = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function test(agent) {
agent.add(new Payload(agent.TELEGRAM, {
"text": "Please click on button below to share your number",
"reply_markup": {
"one_time_keyboard": true,
"resize_keyboard": true,
"keyboard": [
[
{
"text": "Share my phone number",
"callback_data": "phone",
"request_contact": true
}
],
[
{
"text": "Cancel",
"callback_data": "Cancel"
}
]
]
}
}));
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('test Intent', test);
agent.handleRequest(intentMap);
});
Dialogflow is not returning the payload response in the fulfillment code to telegram on invocation of the intent.
I have taken a look at the project function logs but their is no errors being logged.
Their is no reason for my code not to work
Is the payload class deprecated in dialogflow?
2
Answers
The dialogflow WebhookClient used in the Dialogflow fulfillment webhook logic returns an Express HTTP response object that contains the send method. I hooked into this method to send response back to dialogflow's webhook fulfillment API. See code below.
However this work-around does not answer my question "Is the Dialogflow Payload Class deprecated?"
I had the same problem today and with this is running now