Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Card messages in the fulfillment ( inline editor) #346

Open
dineshdisprz opened this issue Aug 23, 2022 · 0 comments
Open

Card messages in the fulfillment ( inline editor) #346

dineshdisprz opened this issue Aug 23, 2022 · 0 comments

Comments

@dineshdisprz
Copy link

When I wanted to show rich responses for intent, the webhook throws an error.

ERROR 👎
Webhook call failed. Error: UNAVAILABLE, State: URL_UNREACHABLE, Reason: UNREACHABLE_5xx, HTTP status code: 500.

But when I just return a text. It does not throw any error.

And adding to it, when I deploy the code in the inline editor, the following errors pop up.
I have no idea what it was and wanted to know that, is the following error is responsible for the failure of webhook when I return rich response( card response).

Permission 'cloudfunctions.functions.setIamPolicy' denied on resource 'projects/datascience-306411/locations/us-central1/functions/dialogflowFirebaseFulfillment' (or resource may not exist).

`// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';

const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');

process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

function welcome(agent) {
agent.add(Welcome to my agent! , my name is dinesh);
}
function fallback(agent) {
agent.add(I didn't understand);
agent.add(I'm sorry, can you try again?);
}
function knwldg(agent){
agent.add(Now you are in the knowledge base);
agent.add(new Card({
title: Title: this is a card title,
imageUrl: 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png',
text: This is the body text of a card. You can even use line\n breaks and emoji! 💁,
buttonText: 'This is a button',
buttonUrl: 'https://assistant.google.com/'
})
);
agent.add(new Suggestion(Quick Reply));
agent.add(new Suggestion(Suggestion));
}

// // Uncomment and edit to make your own intent handler
// // uncomment intentMap.set('your intent name here', yourFunctionHandler);
// // below to get this function to be run when a Dialogflow intent is matched
// function yourFunctionHandler(agent) {
// agent.add(This message is from Dialogflow's Cloud Functions for Firebase editor!);
// agent.add(new Card({
// title: Title: this is a card title,
// imageUrl: 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png',
// text: This is the body text of a card. You can even use line\n breaks and emoji! 💁,
// buttonText: 'This is a button',
// buttonUrl: 'https://assistant.google.com/'
// })
// );
// agent.add(new Suggestion(Quick Reply));
// agent.add(new Suggestion(Suggestion));
// agent.setContext({ name: 'weather', lifespan: 2, parameters: { city: 'Rome' }});
// }

// // Uncomment and edit to make your own Google Assistant intent handler
// // uncomment intentMap.set('your intent name here', googleAssistantHandler);
// // below to get this function to be run when a Dialogflow intent is matched
// function googleAssistantHandler(agent) {
// let conv = agent.conv(); // Get Actions on Google library conv instance
// conv.ask('Hello from the Actions on Google client library!') // Use Actions on Google library
// agent.add(conv); // Add Actions on Google library responses to your agent's response
// }
// // See https://github.com/dialogflow/fulfillment-actions-library-nodejs
// // for a complete Dialogflow fulfillment library Actions on Google client library v2 integration sample

// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Knowledge.KnowledgeBase.MTIyMTI3MDcyMDgwMjE5MzQwODA',knwldg);
intentMap.set('Default Fallback Intent', fallback);
// intentMap.set('your intent name here', yourFunctionHandler);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant