sid8491
sid8491

Reputation: 6800

Python alternative of agent.setContext()

In node.js we can set context using agent.setContext(), what will be python alternative of using this way?

Currently I am using below code to set new context:

res = {
    "fulfillmentText = "This is a test",
    "outputContexts": [
        {
            "name": "projects/project_id/agent/sessions/session_id/contexts/your_context",
            "lifespanCount": 5,
            "parameters": {
                "foo": "bar",
                "foo1": "bar1"
            }
        }
    ],
}
return res

Is there any simpler way?
Thanks in advance.

Note : It seems like node.js have dialogflow-fulfillment library to ease up the things. Is there any similar fulfillment library for python as well?

Upvotes: 3

Views: 458

Answers (2)

mattcarrollcode
mattcarrollcode

Reputation: 3479

The Node.js dialogflow-fulfillment library is owned and maintained by Dialogflow/Google. There is no "official" Dialogflow Python fulfillment library but there are a couple community efforts you can fork:

Upvotes: 2

Prisoner
Prisoner

Reputation: 50741

There is no standard python fulfillment library at this time. Sounds like an opportunity for you!

The format for setting output contexts looks correct, and isn't really much more difficult than the equivalent in JavaScript. How much simpler do you want it?

Upvotes: 1

Related Questions