abhi007tyagi / Android_Dialogflow_Chatbot_Library

Android Library to easily integrate Dialogflow based chatbots into an existing application with Chat screen.
Other
12 stars 6 forks source link

app stops working when using button template #3

Closed Nazar-Pa closed 4 years ago

Nazar-Pa commented 4 years ago

Hey, sorry for disturbing again. The app stops working when I try show messages with Buttons. I attach the screenshot from Logcat, There occurs error, and I could not find the solution. Do you perhaps have any idea what can be the issue? image

abhi007tyagi commented 4 years ago

@Nazar-Pa make sure you are sending the correct payload {"template": "button", "buttonItems":[{"uiText":"Action 1", "actionText":"action 1 selected", "isPositive": true},{"uiText":"Action 2", "actionText":"action 2 selected", "isPositive": false}], "align": "h", "size":"l", "eventToCall":"android_event" };

Even spelling mistake can cause a null pointer exception at the moment. In the above JSON, make sure all the keys are present with correct spelling and case.

abhi007tyagi commented 4 years ago

@Nazar-Pa see if you are sending buttonItems or not. If yes, check spelling.

Nazar-Pa commented 4 years ago

I got your SampleDialogflowWebhook and using exactly same code without changing anything. image

I also created an "Capture Android Event" and added an "android_event" event to that intent. image

I can only get response when I switch it to "const params = { "template": "text" }", so with text there is no error.

Nazar-Pa commented 4 years ago

As I said it works flawlessly when I am showing a simple text.

image

However I also noticed that in your screenshot you get response as "This is a message section for showing text" with simple text template. I do not know if I am doing something wrong. Because I get response as "Event captured successfully!" (below)

109755590_733425940809343_3624293363880601593_n

abhi007tyagi commented 4 years ago

@Nazar-Pa do you see buttons on UI? How are you sending event if they are not?

abhi007tyagi commented 4 years ago

@Nazar-Pa please uncomment the line const param_context = {name: "param_context", lifespan: 10, parameters: params}; Without this, you cannot set parameters to context!

It should work.

Nazar-Pa commented 4 years ago

It never worked with Heroku. I ran it using Ngrok then it worked only once (with hyperlink) but failed again when I checked it few times more. I did not understand how this might happen if it worked once. Thank you very much anyway. I can send you my ngrok link if you still keep the app working somewhere, to check if it works with you. If not never mind, I will try to find the issue.

abhi007tyagi commented 4 years ago

@Nazar-Pa the screenshot you shared, I see you have one line of code commented. Uncomment it as I said earlier.

Nazar-Pa commented 4 years ago

Yes I did it. Still the same error and no answer. But as I said it worked just one time

On Fri, Jul 17, 2020, 05:38 Abhinav Tyagi notifications@github.com wrote:

@Nazar-Pa https://github.com/Nazar-Pa the screenshot you shared, I see you have one line of code commented. Uncomment it as I said earlier.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/abhi007tyagi/Android_Dialogflow_Chatbot_Library/issues/3#issuecomment-659822742, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANFXD7CQQOO6VE26OVY4HC3R37BR3ANCNFSM4O5JNHMQ .

abhi007tyagi commented 4 years ago

@Nazar-Pa did you restarted your service after the code change? Or stop NGROK and try again? If you still get error, share the NGROK URL

abhi007tyagi commented 4 years ago

@Nazar-Pa use this NGROK URL in your fulfillment https://acdaa9ac76c9.ngrok.io/webhook

Its on my machine and working fine. I will keep it active for 30min

abhi007tyagi commented 4 years ago

@Nazar-Pa use Intent named as "Android Intent" and another with event as "Capture Android Event" as these are mapped to my service. Or let me know your intent names.

Nazar-Pa commented 4 years ago

1.Here are my Intents:

image image I trained by Android Intent in a way as you see above, so when I type "capture android event", the "Android Intent" intent must be detected.

2.And I tried your URL but still same error:

image

  1. Here I share my Ngrok url: https://30107d7eda6c.ngrok.io/webhook

  2. Yes I restart the service everytime the code changes

abhi007tyagi commented 4 years ago

@Nazar-Pa I am testing. For events, you don't need any training phrase, as it will interfere with event.

abhi007tyagi commented 4 years ago

@Nazar-Pa I am not seeing any error at my end! Try to create your project from scratch and try again. I will look into it tomorrow. I will try and share a new update over the weekend.

Nazar-Pa commented 4 years ago
  1. So you mean it worked for you?
  2. I didn't get this sentence "For events, you don't need any training phrase, as it will interfere with event". How the agent understand "test android button action" phrase then? (in your screenshot below)

image

  1. Ok if it works fine for you, I think there is problem in android project side with me. I will download and build it again.
abhi007tyagi commented 4 years ago

@Nazar-Pa test android button action is used in Android Intent not in Capture Android Event. Do not add any training phrase to Intents that have event added to it.

Nazar-Pa commented 4 years ago

I also used those phrases in "Android Intent" intent (as I showed above). I downloaded and built the project again but the error is still there.(

Nazar-Pa commented 4 years ago

hey bro, I could find the issue. It was because I already had 2 output contexts I added to my Welcome Intent. Thank you very much again.

abhi007tyagi commented 4 years ago

Great!