the function below is supposed to provides the fulfillment to the share_your_phone_number intent.
When the intent is invoked, the share your phone number keyboard is displayed for the user in telegram.
function share_your_phone_number(agent) {
agent.add(`Welcome.`);
agent.add(new Payload("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"
}
]
]
}
}
));
}
When I deploy the API in the inline editor, only the “Welcome” string is returned in telegram bot chat. the key board buttons are not displayed.
I need a clue to fix fix this.
2
Answers
In creatin the Constructor for Payload object as documented [here]https://dialogflow.com/docs/reference/fulfillment-library/rich-responses#new_payloadplatform_payload, the
platform
andpayload
parameters are required.new Payload(platform, payload)
The
platform
parameter is a property of WebhookClient object and should be defined as such (agent.SLACK, agent.TELEGRAM etc) assuming the webhookClient was instantiated and stored inagent
Examples:
agent.add(new Payload(agent.ACTIONS_ON_GOOGLE, {/*your Google payload here*/});
agent.add(new Payload(agent.SLACK, {/*your Slack payload here*/});
agent.add(new Payload(agent.TELEGRAM, {/*your telegram payload here*/});
ref: https://blog.dialogflow.com/post/fulfillment-library-beta/.
For my use-case outlined in the question this is my full solution:
Here is my result:
Also you must update version of
dialogflow-fulfillment
in package.json to latest. Now I have this version –"dialogflow-fulfillment": "^0.6.1"