question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google.Cloud.Dialogflow.V2 WebHook response card

See original GitHub issue

Hello,

I’m using the Nuget package (.NET): Google.Cloud.Dialogflow.V2 (1.0.0-beta01) This code is a simple example of what I’m trying to do:

 [System.Web.Mvc.HttpPost]
        public WebhookResponse Webhook(WebhookRequest request)
        {
            var message = new Intent.Types.Message
            {
                Card = new Intent.Types.Message.Types.Card
                {
                    Title = "Oh Yeah !",
                    ImageUri = "https://www.google.be/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
                }
            };
            return new WebhookResponse
            {
                FulfillmentMessages = new Google.Protobuf.Collections.RepeatedField<Intent.Types.Message>
                {
                    message
                },
                FulfillmentText = request.QueryResult.FulfillmentText,
                Source = ""
            };
        }

But this code is not working as FulfillmentMessages is read-only. Only get is available from WebhookResponse:

//
        // Summary:
        //     Optional. The collection of rich messages to present to the user. This value
        //     is passed directly to `QueryResult.fulfillment_messages`.
        [DebuggerNonUserCode]
        public RepeatedField<Intent.Types.Message> FulfillmentMessages { get; }

So my question is: How can I send something else that just text from my WebHook ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
jskeetcommented, Apr 18, 2018

Ah, I see. Sorry for misreading the question before. It’s a read-only property, but you just add values to it. All you need to do is get rid of the “new …” part and you can use the collection initializer:

return new WebhookResponse
{
    FulfillmentMessages = { message },
    FulfillmentText = request.QueryResult.FulfillmentText,
    Source = ""
};

Note that RepeatedField<T> has an overload accepting IEnumerable<T> as well, so it’s easy to populate with a LINQ query.

0reactions
rubenvfeliucommented, May 14, 2018

@jskeet thank you so much for your fast respond !!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webhook service | Dialogflow ES
Once your webhook receives a webhook request, it needs to send a webhook response. The body of this response is a JSON object...
Read more >
Webhooks | Dialogflow CX
With standard webhooks, you use Dialogflow-defined request and response messages. The request message provides many details about the session. For example, ...
Read more >
Dialogflow webhook format
This section describes the format of the JSON payload when Actions on Google invokes your fulfillment through Dialogflow v2.
Read more >
Sending back Text & Card in WebhookResponse ...
I am trying to use the API to send back a webhook response message ... NET Core 2.2; Package name and version: Google.Cloud.Dialogflow.V2...
Read more >
How to send FulfillmentMessages as part of Dialogflow v2 ...
Error : Failed to parse webhook JSON response: Cannot find field: Message in message google.cloud.dialogflow.v2.Intent.Message.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found